akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long

//ライブラリ始まり

//定数
//円周率
const double pi = 3.1415926535897932384;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//データ構造
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}
//素数判定 
//一つ一つの判定ではこっちの方が速い(一つ当たりO(√N))
//一方100までに何個あるかなどはEratosthenesの篩の方が良い（O(NlogN))
bool PN(int x) {
  if (x <= 1) return false; // 1や0,-1は素数ではない
  if (x == 2) return true; // √2 + 1 > 2 なので下でやると 2 ％ 2 = 0 となり判定できない
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) return false; // 割れたら素数じゃない
  }
  return true;
}
// A^N mod M を計算する。modしたくなかったらM = LINFとかにすればよい。(O(√N))
ll modpow(ll A, ll N, ll M) {
  long long ans = 1;
  while (N > 0) {
    if (N & 1) ans = ans * A % M;
      A = A * A % M;
      N >>= 1;
   }
  return ans;
}

//ライブラリ終わり
  
//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  string S;
  cin >> S;
  int A = 0, B = 0, C = 0;
  for (int i = 0; i < 3; i++) {
    if (S.at(i) == 'a') {
      A++;
    }
    if (S.at(i) == 'b') {
      B++;
    }
    if (S.at(i) == 'c') {
      C++;
    }
  }
  if (A == B && B == C && A == 1) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3728
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

using namespace std;

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

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

struct Hashing {
    ull seed, mod;
    vector <ull> hs, pw;

    Hashing(ull seed = 31, ull mod = 1000173169) :
        seed(seed),
        mod(mod) {}

    void build(int n, const string& s) {
        hs.assign(n + 1, 0);
        pw.assign(n + 1, 1);
        pw[0] = 1;

        for (int i = 1; i <= n; ++i)
            pw[i] = pw[i - 1] * seed % mod;
        for (int i = 1; i <= n; ++i)
            hs[i] = (hs[i - 1] * seed + s[i]) % mod;
    }

    ull hash(int l, int r) {
        return (hs[r] - hs[l - 1] * pw[r - l + 1] % mod + mod) % mod;
    }
};

int rec(int points, vector<vector<int>> &spells, vector<int> &cache) {

    if (points <= 0)
        return 0;

    if (cache[points] != -1)
        return cache[points];

    int ret = std::numeric_limits<int>::max();

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

        ret = std::min(ret, spells[i][1] + rec(points - spells[i][0], spells, cache));
    }

    return cache[points] = ret;
}


int solve()
{
    int H, N;
    std::cin >> H >> N;

    vector<vector<int>> spells(N, vector<int>(2));
    for (int i = 0; i < N; ++i) {
        std::cin >> spells[i][0] >> spells[i][1];
    }

    vector<int> cache(H + 1, -1);

    int ans = rec(H, spells, cache);

    return ans;
}

int main()
{
    std::cout << solve() << std::endl;

    return 0;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

int main() {
  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  map<ll, ll> mp;
  for (ll i = 2; i * i <= g; ++i) {
    while (g % i == 0) {
      mp[i]++;
      g /= i;
    }
  }
  if (g != 1) mp[g]++;
  ll ans = 1;
  for (auto a : mp) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//Scoring

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int d,m{},c[26];
vector<vector<int>>s;
vector<int>last(26,0);

int scr(int day,int con){
    int q = 0,lc;
    q+=s[day][con];
    lc=last[con];
    last[con]=day+1;
    rep(i,0,26)q-=c[i]*(day+1-last[i]);
    last[con]=lc;
    return q;
}

signed main (){
    cin>>d;
    rep(i,0,26)cin>>c[i];
    s.resize(d);
    rep(i,0,d){
        s[i].resize(26);
        rep(j,0,26)cin>>s[i][j];
    }

    rep(i,0,d){
        int gh=-inf;
        int ans;
        rep(j,0,26){
            int gc = scr(i,j);
            if(gc>gh){
                ans = j;
                gh=gc;
            }
        }
        last[ans]=i+1;
        cout<<ans+1<<nnn;
    }
    return 0;
}

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

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
#define SZ(a) int((a).size())
#define _REP(_1,_2,_3,_4,name,...) name
#define _REP4(i,b,e,s) for(decltype(e) _b=(b),_e=(e),i=_b+(0<(s)?0:(s));(0<(s)?i<_e:_e<=i);i+=(s))
#define _REP3(i,b,e) for(decltype(e) _b=(b),_e=(e),i=(_b<_e?_b:_b-1);(_b<_e?i<_e:_e<=i);(_b<_e?i++:i--))
#define _REP2(i,n) for(decltype(n) i=0,_n=(n);i<_n;i++)
#define _REP1(n) for(decltype(n) _i=0,_n=(n);_i<_n;_i++)
#define REP(...) _REP(__VA_ARGS__,_REP4,_REP3,_REP2,_REP1)(__VA_ARGS__)
#define FOR(it,c) for(auto&& it=begin(c);it!=end(c);it++)
#define ROF(it,c) for(auto&& it=rbegin(c);it!=rend(c);it++)
#define EB emplace_back
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define INT(n) int n;assert(0<scanf("%d",&n))
#define AI(a,size,n) array<int,size> a;REP(i,n){assert(0<scanf("%d",&a[i]));}
#define VI(v,n) vector<int> v(n);REP(i,n){assert(0<scanf("%d",&v[i]));}

int main(){
  INT(n); INT(k); VI(vs, n);
  int ans = 0;
  REP(s, 1, n + 1){
    if (k < s){break;}
    vector<int> w;
    REP(i, s, 0){w.PB(vs[i]);}
    REP(i, n, n - s){w.PB(vs[i]);}
    REP(i, s + 1){
      vector<int> u;
      REP(j, s){u.PB(w[i + j]);}
      sort(u.begin(), u.end());
      int ttl = 0, cnt = 0;
      for(int e: u){
        if (e < 0 && cnt < k - s){
          cnt++;
        } else {
          ttl += e;
        }
      }
      ans = max(ans, ttl);
    }
  }
  printf("%d\n", ans);
  return 0;
}

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

using namespace std;

const long long INF = 1000000000000000009;

int main() {
  int n, m; cin >> n >> m;
  vector<int> a(m), c(m);
  for (int i = 0; i < m; i++) {
    int b; cin >> a[i] >> b;
    int tmp = 0;
    for (int j = 0; j < b; j++) {
      int cc; cin >> cc; cc--;
      tmp += (1<<cc);
    }
    c[i] = tmp;
  }
  vector<vector<long long>> dp(m+10, vector<long long>(1<<n, INF));
  dp[0][0] = 0;
  for (int i = 0; i < m; i++) {
    for (int bit = 0; bit < (1<<n); bit++) {
      // i番目の鍵を使わない
      dp[i+1][bit] = min(dp[i+1][bit], dp[i][bit]);
      // i番目の鍵を使う
      dp[i+1][bit|c[i]] = min(dp[i+1][bit|c[i]], dp[i][bit] + a[i]);
    }
  }
  long long ans = dp[m][(1<<n)-1];
  if (ans == INF) { cout << -1 << endl; }
  else { cout << ans << endl; }

  return 0;
}

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

using namespace std;

int N;
string s, t;

int main(){
  cin >> N >> s >> t;
  int answer = 2 * N;
  for(int i = 0; i < N; i++){
    bool flag = true;
    for(int j = 0; j < N - i; j++){
      if(s[i + j] != t[j]){
        flag = false;
      }
    }
    if(flag){
      answer = N + i;
      break;
    }
  }
  cout << answer << endl;
}


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

int main() {
    int n; cin >> n;
    vector<int> d(n);
    for (int &di: d) cin >> di;
    sort(d.begin(), d.end());
    cout << d[n / 2] - d[n / 2 - 1] << endl; 
    return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rep2(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rev(i, n) for (int (i) = (n) - 1; (i) >= 0; (i)--)
#define rev2(i, a, b) for (int (i) = (a) - 1; (i) >= (b); (i)--)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Pll = pair<long long, long long>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
long long TEN(int i) {return !i ? 1 : TEN(i -  1) * 10LL;}
template<class T, class U> 
bool chmin(T& a, const U& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T, class U> 
bool chmax(T& a, const U& b) {if (a < b) {a = b; return 1;} return 0;}
 
struct IoSetup {
  	IoSetup() {
    	cin.tie(nullptr);
    	ios::sync_with_stdio(false);
    	cout << fixed << setprecision(15);
  	}
} iosetup;

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//

int N;
int a[100005], b[100005];


int main() {
	cin >> N;
	rep (i, N) cin >> a[i];
	rep (i, N) cin >> b[i];

	ll sa = 0, sb = 0;
	rep (i, N) sa += a[i], sb += b[i];

	if (sa > sb) {
		cout << "No" << endl;
		return 0;
	}

	ll betw = sb - sa;

	rep (i, N) {
		if (a[i] > b[i]) {
			betw -= a[i] - b[i];
		}
	}

	if (betw < 0) {
		cout << "No" << endl;
		return 0;
	}

	betw = sb - sa;

	rep (i, N) {
		if (a[i] < b[i]) {
			betw -= (b[i] - a[i] + 1) / 2;
		}
	}
	
	if (betw < 0) cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 3708
#include <iostream>
#include <utility>
#include <vector>
using namespace std;
using Music = pair<string, int>;
int main() {
  int N;
  cin >> N;
  vector<Music> musics(N);
  for(int i = 0; i < N; ++i) {
    cin >> musics[i].first >> musics[i].second;
  }
  string x;
  cin >> x;
  bool is_found = false;
  int ans = 0;
  for(auto m : musics) {
    if(is_found) {
      ans += m.second;
    } else {
      if(m.first == x) {
        is_found = true;
      }
    }
  }
  cout << ans << endl;

  return 0;
}

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

int main(void){
	int a,b,c,d,t;
	
	scanf("%d %d %d %d",&a,&b,&c,&d);
	a=a+b+c+d;
	
	for(t=0;a>=60;t++){
		a-=60;
	}
	printf("%d\n%d\n",t,a);
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
typedef double D;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
//typedef pair<int, int> P;


/** Problem2401 : Equation **/

string s;
int pos, N;

bool formula()
{
	char c = s[pos++];
	if (c == 'T') return true;
	else if (c == 'F') return false;
	else if (islower(c)) {
		return N>>(c-'a')&1;
	} else if (c=='-') return !formula();
	else if (c=='(') {
		bool a = formula();
		char ope = s[pos++];
		if (s[pos]=='>')pos++;
		bool b = formula();
		pos++;
		
		if (ope == '*') return a&b;
		else if (ope == '+') return a|b;
		else return (a&b)|(!a&b)|(!a&!b);
	}
	return false;
}


int main()
{
	while (cin>>s, s!="#") {
		bool ans = true;
		for (N=0; N<2048; N++) {
			pos=0;
			bool a, b;
			a = formula();
			pos++;
			b = formula();
			ans &= a==b;
		}

		cout << (ans?"YES":"NO") << endl;
	}
}

Measured memory_bytes: 1208
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cstring>
#include<queue>

using namespace std;

#define INF 999999999

vector<int> a;

void tori(int n, int k, int m){
	if(n > 1){
		//for(int i=0;i<=n;i++)
		//cout << a[i] << " ";
		//cout << endl;
		int z=(m + k - 1) % n;
		if(z == 0) z = n;
		a.erase(a.begin()+z);
		tori(n-1,k,z);
	}
}

int main(){
	int i, j, n, k, m, z;
	while(1){
		cin >> n >> k >> m;
		if(!n)break;
		a.clear();
		for(i=0;i<=n;i++) a.push_back(i);
		a.erase(a.begin()+m);
		tori(n-1, k, m);
		cout << a[1] <<endl;
	}
	return 0;
}

Measured memory_bytes: 1324
#include <iostream>
#include <cstdlib>
#include <vector>
using namespace std;

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

    vector<int> v(10000000, 0);
    int a = s;
    int ans = 1;
    for(;;){
        if(v[a] == 1) break;
        v[a] = 1;
        if(a % 2 == 0){
            a = a / 2;
        } else {
            a = 3 * a + 1;
        }
        ans++;
    }

    cout << ans << endl;

    return EXIT_SUCCESS;
}


Measured memory_bytes: 39296
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int>pi;
#define elif else if
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define Rep(x,y) for(int k=x;k<y;k++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define vint vector<int>
#define vvint vector<vector<int>>
#define vtr vector<string>
#define vouble vector<double>
#define vvtr vector<vector<string>>
#define vhar vector<char>
#define vvhar vector<vector<char>>
#define mis map<int,str>
#define msi map<str,int>
#define mid map<int,double>
#define mod 100000007
#define elif else if
#define str string
int digitsum(int a){
  int b=0;
  while(a){
    b+=a%10;
    a/=10;
  }
  return b;
}
signed main(){
  int n,m,c=0,c2=0;
  string S,t;
  char C;
  double d;
  cin>>S;
  S=="ABC"?cout<<"ARC"<<endl:cout<<"ABC"<<endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <numeric>

using namespace std;

int main()
{
    int K;
    cin >> K;
    long long po = 0;
    for (int i = 1; i <= K; i++){
        for (int  j = 1; j <= K; j++)
        {
            for (int k = 1; k <= K; k++)
            {
                po = po + gcd<int,int>(gcd<int,int>(i,j),k);
            }
            
        }
        
    }
    cout << po;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<cstring>
#include<algorithm>

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

using namespace std;

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

bool solve(const char *s,const char *t){
	int m=strlen(s)-1,n=strlen(t)-1;

	if(m!=n) return false;

	pair<int,int> p[128];
	int x=0,y=0;
	rep(i,m+1){
		p[i]=make_pair(x,y);
		if(i<m){
			y+=dy[x&1][s[i]-'a'];
			x+=dx[s[i]-'a'];
		}
	}

	rep(k,m+1) rep(d,6) {
		bool ok=true;
		int x=p[k].first,y=p[k].second;
		rep(i,n+1){
			if(find(p,p+m+1,make_pair(x,y))==p+m+1){ ok=false; break; }
			if(i<n){
				y+=dy[x&1][(t[i]-'a'+d)%6];
				x+=dx[(t[i]-'a'+d)%6];
			}
		}
		if(ok) return true;
	}
	return false;
}

int main(){
	int T; scanf("%d",&T);
	for(getchar();T--;){
		char s[128],t[128];
		fgets(s,128,stdin);
		fgets(t,128,stdin);
		getchar(); getchar();
		puts(solve(s,t)?"true":"false");
	}
	return 0;
}

Measured memory_bytes: 1016
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=2e5+10;
const int mod=998244353;
int a[3005][3005];
ll dp[3005][3005][5];


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r,c,k;
    cin>>r>>c>>k;
    while(k--)
    {
        int x,y,z;
        cin>>x>>y>>z;
        a[x][y]=z;
    }
    ll ans=0;
    /*for(int i=1;i<=r;i++)
    {
        dp[i][1][0]=dp[i-1][1][1];
        dp[i][1][1]=dp[i-1][1][1]+a[i][1];
        ans=max(ans,dp[i][1][1]);
    }*/
    for(int i=1;i<=c;i++)
    {
        for(int x=1;x<=3;x++)
        {
            dp[1][i][x]=max(dp[1][i-1][x],dp[1][i-1][x-1]+a[1][i]);
            ans=max(ans,dp[1][i][x]);
        }
    }

    for(int i=2;i<=r;i++)
    {
        for(int j=1;j<=c;j++)
        {
            dp[i][j][0]=max(dp[i][j-1][0],dp[i-1][j][3]);
            ans=max(ans,dp[i][j][0]);
            for(int x=1;x<=3;x++)
            {
                dp[i][j][x]=max(dp[i-1][j][3]+a[i][j],max(dp[i][j-1][x],dp[i][j-1][x-1]+a[i][j]));
                ans=max(ans,dp[i][j][x]);
            }
        }
    }
    cout<<ans<<'\n';


}


Measured memory_bytes: 390944
#include <bits/stdc++.h>
        #define rep(i,n) for (int i = 0; i < (n) ; ++i)
        using namespace std;
        using ll = long long ;
        using P = pair<int, int> ;
         
         
        int main () {
        ll A, B, C, K;
        cin >> A >> B >> C >> K;
        ll ans = 0;
        if ( A > K ){
          cout << K * 1 << endl;
           return 0;}     
        else {ans += A * 1 ;}
        if (K - A > 0 ) {
        ans += (K - A) * 0;} 
        if (K - A - B > 0){
        ans += (K - A - B) * -1 ;}
        cout << ans << endl; 
        return 0;
        }

Measured memory_bytes: 3592
/*-- ILSH  --*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pll >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 

const ll inf=1e18+1e17;
//const ll mod =1e9+7;
const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}


const ll N = 2e5+5;

void solve(){
ll n;
cin>>n;
ll val=sqrt( n);
vii v;
for ( int i=2;i<=val;i++){
	if ( n%i==0){
		v.pb( 0);
		while ( n%i==0){
			v.back()++;
			n=n/i;

		}
	}
}
int ans=0;
if ( n!=1)
	ans++;
for ( int i=0;i<v.sz();i++){
	ans+=(-1+sqrt(1+ 8*v[i]))/2;
}
cout<<ans<<'\n';

}

int main(){
	// ios_base::sync_with_stdio(false);
	// cin.tie( NULL);
	// cout.tie(NULL);
//	#ifndef ONLINE_JUDGE
//		freopen ("INPUT.txt" , "r" , stdin);
//		freopen ("OUTPUT.txt", "w" , stdout);
//	#endif

	int t=1;

	//cin>>t;

	for ( int i=1;i<=t;i++){
   // 	cout<<"Case #"<<i<<": ";
    	solve();
 	}
}

Measured memory_bytes: 3724
from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]
l = []
r = []
for i in range(n):
   l.append(a[i]+i+1)
   r.append(i-a[i]+1)
l = Counter(l)
r = Counter(r)
ans = 0
for i in l:
   ans += l[i] * r[i]
print(ans)

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

int main() {
	int n,k;
  	cin>>n>>k;
  
  	int h[n];
  	rep(i,n){
    	cin>>h[i];
    }
  
  int noreru=0;
  
  rep(j,n){
  	if(h[j]>=k){
    	noreru++;
    }
  }
  
  cout<<noreru<<endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static char[][] table = {{'.',',','!','?',' '},{'a','b','c'},{'d','e','f'},{'g','h','i'},{'j','k','l'},{'m','n','o'},{'p','q','r','s'},{'t','u','v'},{'w','x','y','z'}};

	public static void main(String[] args) throws Exception {
		int N = sc.nextInt();
		for (int i = 0; i < N; ++i) {
			char ch = 0;
			int count = 0;
			StringBuilder sb = new StringBuilder();
			for (char c : sc.next().toCharArray()) {
				if (c == '0') {
					if (count > 0) sb.append(table[ch - '1'][(count - 1) % table[ch - '1'].length]);
					count = 0;
				} else {
					ch = c;
					++count;
				}
			}
			System.out.println(sb);
		}
	}

}

Measured memory_bytes: 21816
import sys
import heapq


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(10 ** 9)


MOD = 10 ** 9 + 7


def dijkstra(start, n_nodes, edge):
    dist = [float("inf")] * n_nodes
    dist[start] = 0
    # 優先度キューの準備
    q = [(dist[start], start)]
    heapq.heapify(q)
    while q:
        # スタートから最も最短距離のものを取り出す
        d, i = heapq.heappop(q)
        # 記録してある情報よりも，取り出した要素に入っている距離情報の方が大きければ
        # 打ち切り．次の要素を取り出す操作に戻る
        if dist[i] < d:
            continue
        # そこから移動できる頂点を探し，最短距離が更新できるものがあれば，
        # 距離を更新して，その頂点への距離と頂点の方法を優先度キューにpush
        for cost, j in edge[i]:
            if dist[j] > dist[i] + cost:
                dist[j] = dist[i] + cost
                heapq.heappush(q, (dist[j], j))
    return dist


def main():
    N = int(input())
    edge = [[] for _ in range(N)]
    for _ in range(N - 1):
        a, b, c = map(int, input().split())
        edge[a - 1].append((c, b - 1))
        edge[b - 1].append((c, a - 1))
    Q, K = map(int, input().split())
    D = dijkstra(K - 1, N, edge)
    for _ in range(Q):
        x, y = map(int, input().split())
        print(D[x - 1] + D[y - 1])


if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)

bool X[100100];
int main(){
    int N;
    cin >> N;
    REP(i,N){
        char c;
        cin >> c;
        if(c == 'x') X[i] = true;
    }

    string start[4] = {"SS", "SW", "WS", "WW"};

    string ans;
    bool find = false;
    for(int k = 0; k < 4; k++){
        ans = start[k];
        for(int i = 1; i < N; i++){
            bool x = X[i];
            bool s = (ans[i] == 'S');
            bool ss = (ans[i-1] == 'S');
            if((s && ss && x) || (s && !ss && !x) || (!s && !ss && x) || (!s && ss && !x))
                ans += "W";
            else
                ans += "S";
        }
        if(ans[0] == ans[N]){
            ans.pop_back();
            bool x = X[0];
            bool s = (ans[0] == 'S');
            bool ss = (ans[N-1] == 'S');
            char next;
            if((s && ss && x) || (s && !ss && !x) || (!s && !ss && x) || (!s && ss && !x))
                next = 'W';
            else
                next = 'S';
            if(next == ans[1]){
                find = true;
                break;
            }
        }
    }

    if(find)
        cout << ans << endl;
    else
        cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 724
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var nm = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
			int n = nm[0];
			int m = nm[1];

			var to = new List<int>[n];
			for (int i = 0; i < n; i++) {
				to[i] = new List<int>();
			}

			for (int i = 0; i < m; i++) {
				var ab = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
				int a = ab[0] - 1;
				int b = ab[1] - 1;
				to[a].Add(b);
				to[b].Add(a);
			}

			var done = new bool[n];
			var front = new List<int>(n);
			front.Add(1);
			done[0] = true;
			var q = new Queue<int>();
			q.Enqueue(0);
			while (q.Count > 0) {
				int cur = q.Dequeue();
				foreach (int next in to[cur]) {
					if (done[next] == false) {
						done[next] = true;
						front.Add(next + 1);
						q.Enqueue(next);
						break;
					}
				}
			}

			var back = new List<int>(n);
			q.Enqueue(0);
			while (q.Count > 0) {
				int cur = q.Dequeue();
				foreach (int next in to[cur]) {
					if (done[next] == false) {
						done[next] = true;
						back.Add(next + 1);
						q.Enqueue(next);
						break;
					}
				}
			}

			var ans = new List<int>(n);
			for (int i = back.Count - 1; i >= 0; i--) {
				ans.Add(back[i]);
			}

			ans.AddRange(front);

			Console.WriteLine(ans.Count);
			Console.WriteLine(string.Join(" ", ans));
		}
	}
}

Measured memory_bytes: 28792
import itertools
n, m, q = map(int, input().split())
lst = [list(map(int, input().split())) for i in range(q)]
ans = 0

for A in itertools.combinations_with_replacement(range(1, m + 1), n):
    flag = 0
    for k in range(n - 1):
        if A[k + 1] < A[k]:
            flag = 1
    if flag == 0:
        point = 0
        for l in range(q):
            if A[lst[l][1] - 1] - A[lst[l][0] - 1] == lst[l][2]:
                point += lst[l][3]
        ans = max(ans, point)

print(ans)


Measured memory_bytes: 9212
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
struct __test {} test;
using namespace std;
template <typename T>const __test &operator<<(const __test& d,
const T& v) {return cerr << "\033[31m" << v << "\033[0m",d;}
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;

int n;
const int N = 1e5+5;
int a[N];

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for(int i = 1; i <= n; ++i) {
		cin >> a[i];
	}
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	int i = 1;
	while(a[i] >= i) ++i;
	--i;
	int j=i;
	int k = 0;
	for(++i;a[i]>=j;++i) {
		++k;
	}
	k = (k%2) + (a[j]-j)%2;
	if(k == 0) cout << "Second\n";
	else cout << "First\n";
	return 0;
}

Measured memory_bytes: 640
def higher(k, v):
    for i in v:
        if h[k - 1] <= h[i - 1]:
            return 0
    return 1


n, m = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

obs = {k: [] for k in range(1, n + 1)}
for _ in range(m):
    a, b = [int(i) for i in input().split()]
    obs[a].append(b)
    obs[b].append(a)

good = 0
for k, v in obs.items():
    if len(v) == 0:
        good += 1
        continue
    good += higher(k, v)
print(good)


Measured memory_bytes: 37840
N = int(input())
A = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
C = [0]*N
D = [0]*N
c = d = 0
for i in range(N):
    a = A[i]
    b = B[i]
    if C[a-1]==0:
        for j in range(c,a): C[j]=C[c]
        c=a-1
        C[c]=C[c-1]+1
    else: C[a-1]+=1
    if D[b-1]==0:
        for j in range(d,b): D[j]=D[d]
        d=b-1
        D[d]=D[d-1]+1
    else: D[b-1]+=1
for j in range(c,N): C[j]=C[c]
for j in range(d,N): D[j]=D[d]
E = [0]*N
for i in range(N):
    if i==0: E[i] = C[i] + D[i]
    else:
        E[i] = C[i]-C[i-1] + D[i]-D[i-1]
#print(C,D,E)
if max(E)>N: print("No")
else:
    for i in range(N):
        if i==0: x=C[i]
        if x < C[i]-D[i-1]: x = C[i]-D[i-1]
    B_ = [0]*N
    #print(x)
    for i in range(N):
        B_[(i+x)%N] = B[i]
    print("Yes")
    print(*B_,sep=' ')

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

int main(){
    string s;
    cin>>s;
    
    replace(s.begin(),s.end(),'?','D');
    
    cout<<s<<endl;
}


Measured memory_bytes: 3720
function Main(input) {
  var dataList = input.split("\n");
  dataList.pop();

  var materials = dataList[0].split(" ");
  var switchNum = parseInt(materials[0]);
  var lightNum = parseInt(materials[1]);
  var remainders = dataList[dataList.length - 1].split(" ");
  dataList.shift();
  dataList.pop();
  
  var cnt = 0;
  for ( var i = 0; i < (1 << switchNum); ++i) {
    var tmpRemainders = [];  
    for ( var j = 0; j < dataList.length; j++) {
      tmpRemainders.push(getRemainder(dataList[j], i));
    }
    if (remainders.toString() == tmpRemainders.toString()) cnt++;
  }
  console.log(cnt);
  
  function getRemainder(data, lights) {
    var dataArray = data.split(" ");
    var length = parseInt(dataArray[0]);
    var cnt = 0;
    for (var i = 1; i <= length; i++) {
      if ((lights >> (parseInt(dataArray[i])-1)) & 1) cnt++;
    }
    return cnt % 2;
  }  
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9776
//b.c B-Great Ocean View
#include<stdio.h>
#include<stdbool.h>

int main(void){
    int n;
    int count=0;
    scanf("%d",&n);
    int h[n];
    for(int i=0;i<n;++i){
        scanf("%d",h+i);
    }
    for(int i=0;i<n;++i){
        int x = h[i];
        bool flag = true;
        for(int j=0;j<i;++j){
            if(x<h[j]){
                flag = false;
            }
        }
        if(flag){
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 10000000007

int main() {
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll ans=1;
	for(ll i=1;i<n;i++){
		if(s[i-1]!=s[i]){
			ans++;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3708
//Tap Dance
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    int count=0;
    for (int i=0;i<s.length();i++) {
      if (i%2==0) {
        if(s.charAt(i)=='L') {
          System.out.println("No");
        return;
       }
      }else{
        if(s.charAt(i)=='R') {
          System.out.println("No");
        return;
       }
      }
    }


    System.out.println("Yes");


  }
}


Measured memory_bytes: 23764
while True:
    x, y = map(int, raw_input().split())
    if x == y == 0: break
    x, y = (x, y) if x >= y else (y, x)
    c = 0
    while y != 0:
        x = x-(x/y)*y
        x, y = y, x
        c += 1
    else:
        print x, c

Measured memory_bytes: 4208
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#else
#define debug(fmt, ...)
#endif

#define INF (1e+9)

int main(void) {
    int bs, ks;
    cin >> bs >> ks;
    // box, price
    vector<pii> keys(ks);
    for(int i = 0; i < ks; i++) {
        cin >> keys[i].second;
        int types;
        cin >> types;
        int boxes = 0;
        for(int j = 0; j < types; j++) {
            int tmp;
            cin >> tmp;
            // 1-indexed -> 0-indexed
            tmp--;
            boxes |= (1<<tmp);
        }
        keys[i].first = boxes;
        debug("%d -> %d %d\n", i, keys[i].first, keys[i].second);
    }

    vector<vector<int>> dp(ks+1, vector<int>(1<<bs, INF+1));
    dp[0][0] = 0;
    for(int i = 1; i <= ks; i++) {
        pii key = keys[i-1];
        // stay
        for(int pat = 0; pat < (1<<bs); pat++) {
            dp[i][pat] = dp[i-1][pat];
        }
        // choose
        for(int prev = 0; prev < (1<<bs); prev++) {
            int cur = prev | key.first;
            dp[i][cur] = min(
                dp[i-1][prev]+key.second,
                dp[i][cur]
            );
            debug("%d: %d\n",cur, dp[i][cur]);
        }
        debug("dp[%d][%d] = %d\n", i, (1<<bs)-1, 
            dp[i][(1<<bs)-1]
        );
    }
    int ans = dp[ks][(1<<bs)-1];
    if(ans > INF) ans = -1;
    cout << ans << endl;
    return 0;
}

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

const int maxn = 100 + 10, inf = 1e9;
int a[3][maxn], dp[3][maxn];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    for (int i = 1; i <= 2; ++i) {
        for (int j = 1; j <= n; ++j) cin >> a[i][j];
    }
    for (int i = 1; i <= n; ++i) dp[0][i] = dp[i][0] = -inf;
    dp[0][1] = dp[1][0] = 0;
    for (int i = 1; i <= 2; ++i) {
        for (int j = 1; j <= n; ++j) dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + a[i][j];
    }
    cout << dp[2][n] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;


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

    vector<vector<int>> edges(n);

    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }

    vector<int> prev(n, -1);

    struct Q {
        int to;
        int prev;
    };
    queue<Q> q;
    q.push(Q{0, -1});

    while (!q.empty()) {
        Q t = q.front();
        q.pop();
        for (int next : edges[t.to]) {
            if (prev[next] != -1) continue;
            prev[next] = t.to;
            q.push(Q{next, t.prev});
        }
    }

    cout << "Yes" << endl;
    rep(i, n) {
        if (i == 0) continue;
        cout << prev[i] + 1 << endl;
    }

}


Measured memory_bytes: 10548
N = int(input())
P = list(map(int, input().split()))
ans = 0
index = 0
while(index < N):
    if P[index] == index + 1:
        if index < N - 1:
            if P[index + 1] == index + 2:
                P[index], P[index + 1] = P[index + 1], P[index]
                index += 2
                ans += 1
                continue
            else:
                P[index], P[index + 1] = P[index + 1], P[index]
                index += 1
                ans += 1
                continue
        else:
            P[index - 1], P[index] = P[index], P[index - 1]
            index += 1
            ans += 1
    else:
        index += 1
print(ans)

Measured memory_bytes: 14008
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = long.Parse(Console.ReadLine());
            var y = x / 500;
            x -= 500 * y;
            var z = x / 5;
            Console.WriteLine(y * 1000 + z * 5);
        }
    }
}


Measured memory_bytes: 11092
import java.util.*;
public class Main {
	
    public static int gcd(int x,int y){
        if(x < y) return gcd(y, x);
        if(y == 0) return x;
        return gcd(y, x % y);
    }
  
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
        int b;
        int ans = 0;
        for(int i=1;i<=a;i++){
        for(int j=1;j<=a;j++){b = gcd(i,j);
        for(int k=1;k<=a;k++){ans+=gcd(b,k);
                           
                            }               
                            }                 
                            }
        
     
		System.out.println(ans);
	}
}


Measured memory_bytes: 35804
h, w = gets.split.map(&:to_i)

canbus = []

h.times do
  canbus << gets.chomp
end

ans = true
catch(:no) do
  0.upto(h-1) do |i|
    0.upto(w-1) do |j|
      if canbus[i][j] == '#'
        ok = false
        # up
        if i - 1 >= 0 && canbus[i-1][j] == '#'
          ok = true
        elsif i + 1 < h && canbus[i+1][j] == '#'
          ok = true
        elsif j - 1 >= 0 && canbus[i][j-1] == '#'
          ok = true
        elsif j + 1 < w && canbus[i][j+1] == '#'
          ok = true
        end

        if ok == false
          ans = false
          throw :no
        end
      end
    end
  end
end

if ans
  puts 'Yes'
else
  puts 'No'
end


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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';
#define N 300000 // prime modulo value 

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	3e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, k, p, m, y;
string s, t;
ld w;
ll a, b;


// <------------- Implement Functions Here ----------> //


// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {	
	//ll a,b,c,d,e;
	cin >> n;
	vll A(5);
	for(ll i=0;i<5;i++) cin >> A[i];
	ll val = *min_element(all(A));
	
	cout<<((n+val-1)/val + 4);newl;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}

Measured memory_bytes: 3664
#include<bits/stdtr1c++.h>
#include<list>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    if (A+B<C+D){
        cout << "Right" << endl;
    }
    else if (A+B==C+D){
        cout << "Balanced" << endl;
    }
    else{
        cout << "Left" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
#define bit(n) 1 << n
using namespace std;
using cd = complex <double>;

typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <pair <int, int> > vii;
typedef map <int, int> mii;

const int Inf = 100000;
const int mod = 1000000007;
const double Pi = acos(-1);

void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n;
char s[25];

void back(int pos, char m)
{
	if(pos == n + 1)
	{
		for(int i = 1; i <= n; i++)
		{
			cout << s[i];
		}
		cout << endl;
		return;
	}
	for(char x = 'a'; x <= m + 1; x++)
	{
		s[pos] = x;
		back(pos + 1, max(m, s[pos]));
	}
}

void Solve()
{
	cin >> n;
	s[1] = 'a';
	back(2, 'a');
}

signed main()
{
	Solve();
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#define M 100000
#define Y second
#define X first
#define N 500
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> P1;
int n,u,v,m,a[2][N][N],b,f1,f2;
bool usa[N][N],nek[N][N];
int usac[N*2+2],cu;
int nekc[N*2+2],cn;
vector<P1> x;
vector<P> d;
set<int> s;
map<int,P> z[2];

int Bynary_Search(int k){
  int L=0,R=d.size();
  while(L<R){
    int Mid=(L+R)/2;
    if(d[Mid].X<k)L=Mid+1;
    else R=Mid;
  }
  if(d[L].X==k)return L;
  return -1;
}

int main(){
  cin>>n>>u>>v>>m;
  for(int i=0;i<2;i++)
    for(int j=0;j<n;j++)
      for(int k=0;k<n;k++){
	cin>>a[i][j][k];
	z[i].insert(make_pair(a[i][j][k],P(j,k)));
	s.insert(a[i][j][k]);
      }
  for(int i=0;i<m;i++){
    cin>>b;
    d.push_back(P(b,i));
  }
  sort(d.begin(),d.end());
  set<int>::iterator ite;
  for(ite=s.begin();ite!=s.end();ite++){
    int r=Bynary_Search(*ite);
    if(r>=0){
      if(z[0].find(d[r].X)!=z[0].end())
	x.push_back(P1(P(d[r].Y,0),P(z[0][d[r].X].X,z[0][d[r].X].Y)));
      if(z[1].find(d[r].X)!=z[1].end())
	x.push_back(P1(P(d[r].Y,1),P(z[1][d[r].X].X,z[1][d[r].X].Y)));
    }
  }
  sort(x.begin(),x.end());
  for(int i=0;i<x.size();i++){
    int p=x[i].X.Y,px=x[i].Y.X,py=x[i].Y.Y;
    if(!p){
      usac[px]++;
      if(n!=1){
	usac[py+n]++;
	if(px==py){
	  usac[n*2]++;
	  if(usac[n*2]==n)cu++;
	}
	if(px+py==n-1){
	  usac[n*2+1]++;
	  if(usac[n*2+1]==n)cu++;
	}
      }
      if(usac[px]==n)cu++;
      if(usac[py+n]==n)cu++;
    }else{
      nekc[px]++;
      if(n!=1){
	nekc[py+n]++;
	if(px==py){
	  nekc[n*2]++;
	  if(nekc[n*2]==n)cn++;
	}
	if(px+py==n-1){
	  nekc[n*2+1]++;
	  if(nekc[n*2+1]==n)cn++;
	}
      }
      if(nekc[px]==n)cn++;
      if(nekc[py+n]==n)cn++;
    }
    if(i+1<x.size()&&x[i].X.X!=x[i+1].X.X){
      if(cu>=u)f1=1;
      if(cn>=v)f2=1;
      if(f1||f2)break;
    }
  }
  if(cu>=u)f1=1;
  if(cn>=v)f2=1;
  if((!f1&&!f2)||(f1&&f2))cout<<"DRAW"<<endl;
  else if(f1)cout<<"USAGI"<<endl;
  else cout<<"NEKO"<<endl;
  return 0;
}

Measured memory_bytes: 35428
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=998244353;
const LL LINF=1LL<<62;




int main(){
    int n;cin >>n;
    int a,b;cin >> a >> b;
    if(n==1) puts("Hello World");
    else cout << a+b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define it 1000000000
int i;

int main(){
	ios::sync_with_stdio(false);
    cin.tie();
    
    int n,k;
    cin>>n>>k;
    ll a[n];
    for(i=0;i<n;i++){
    	cin>>a[i];
	}
    for(i=k;i<n;i++){
    	if(a[i]>a[i-k])cout<<"Yes"<<endl;
    	else cout<<"No"<<endl;
	}
	return 0;
}



Measured memory_bytes: 5172
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    string s,t; cin>>s>>t;
    string ans;
    rep(i,n) {
        ans.push_back(s[i]);
        ans.push_back(t[i]);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256