akhauriyash/Code-Regression huggingface dataset:
from sys import stdin
import sys
import numpy as np
import collections

##  input functions for me
def rsa(sep = ''):
    if sep == '' :
        return input().split() 
    else: return input().split(sep)
def rip(sep = ''):
    if sep == '' :
        return map(int, input().split()) 
    else: return map(int, input().split(sep))
def ria(sep = ''): 
    return list(rip(sep))
def ri(): return int(input())
def rd(): return float(input())
def rs(): return input()
##
def main():
    S = rs()
    K = ri()
    N = len(S)
    key = []
    cnt = []
    key.append(S[0])
    cnt.append(1)
    for i in range(1,N):
        if S[i] == key[len(key) - 1]:
            cnt[len(cnt) - 1] += 1
        else:
            key.append(S[i])
            cnt.append(1)

    if len(cnt) == 1:
        tot = N * K
        print(tot // 2)
        sys.exit(0)

    ans = 0
    for i in range(1,len(cnt) - 1):
        ans += K * (cnt[i] // 2)
    ans += cnt[0] // 2
    ans += cnt[len(cnt) - 1] // 2
    if(key[0] == key[len(key) - 1]):
        ans += (K - 1) * ((cnt[0] + cnt[len(cnt)-1]) // 2)
    else:
        ans += (K - 1) * ((cnt[0]) // 2)
        ans += (K - 1) * ((cnt[len(cnt)-1]) // 2)
    print(ans)






if __name__ == "__main__":
    main()


Measured memory_bytes: 17472
n = int(input())
t = list(map(int,input().split()))
m = int(input())
p = [list(map(int,input().split())) for i in range(m)]
k = 0
tmp = t[:]
for i in range(m):
    k = p[i][0]
    t[k-1] = p[i][1]
    print(sum(t))
    t[k-1] = tmp[k-1]

Measured memory_bytes: 3064
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1000000007
#define mxval 1e9 + 7
#define grt [](auto x,auto y){return x>y;}
#define pii pair<int,int>
/*********VARIABLE****************/
using namespace std;
int i,j,n,m,k,l,q,t,a,b,sum[3],tot[3],cnt[3];
/*********FUNCTIONS**************/
int powom(int a,int b) {
    int result = 1;
    while (b > 0) {
        if (b & 1)
            result = result * a;
        a = a * a;
        b >>= 1;
    }
    return result;
}
/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	string s;
	cin>>s;
	map<char,int> mp;
	for(auto x : s){
		mp[x]++;
	}
	for(auto x : mp){
		if(x._2!=2){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
    return 0;
}
//.........

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s; cin >> s;
	if (s == "SSS") cout << 0 << endl;
	if (s == "SSR") cout << 1 << endl;
	if (s == "SRS") cout << 1 << endl;
	if (s == "SRR") cout << 2 << endl;
	if (s == "RSS") cout << 1 << endl;
	if (s == "RSR") cout << 1 << endl;
	if (s == "RRS") cout << 2 << endl;
	if (s == "RRR") cout << 3 << endl;

}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

vector< vector<int> > m(8, vector<int>(8, 0));
bool inRange(int x, int y) {
	return 0 <= x && x < 8 && 0 <= y && y < 8;
}
int f(int x, int y, int dx, int dy, int turn, bool isReplace) {
//	cout << x << " " << y << " " << endl;
	if ( !inRange(x, y) ) return -inf;
	if ( m[y][x] == 0 ) return -inf;
	if ( m[y][x] == turn ) return 0;
	int res = f(x+dx, y+dy, dx, dy, turn, isReplace)+1;
	if (res > 0 && isReplace) {
		m[y][x] = turn;
	}
	return res;
}
int f(int x, int y, int turn, bool isReplace) {
	int res = 0;
	if (m[y][x] != 0) return 0;
	for (int dx = -1; dx <= 1; ++dx) {
		for (int dy = -1; dy <= 1; ++dy) {
			if (dx == 0 && dy == 0) continue;
//			cout << ":" << dx << " " << dy << endl;
			int dr = f(x+dx, y+dy, dx, dy, turn, isReplace);
			if (dr >= 0) res += dr;
		}
	}
	if (res <= 0) return 0;
	if (isReplace) m[y][x] = turn;
	return res+1;
}
void out() {
	REP(i, 8) {
		REP(j, 8) {
			if (m[i][j] == 0) cout << ".";
			if (m[i][j] == 1) cout << "o";
			if (m[i][j] == 2) cout << "x";
		}
		cout << endl;
	}
}
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	REP(i, 8) {
		string str; cin >> str;
		REP(j, 8) {
			m[i][j] = str[j] == 'o' ? 1 : str[j] == 'x' ? 2 : 0;
		}
	}
	REP(t, 150) {
		{
			vector< tuple<int, int, int> > v;
			REP(i, 8) REP(j, 8) {
				int n = f(j, i, 1, false);
				if (n > 0) v.pb( make_tuple(-n, i, j) );
			}
			if (v.size() > 0) {
				sort( ALL(v) );
				f(get<2>(v[0]), get<1>(v[0]), 1, true);
			}
		}
//		out(); cout << endl;
		{
			vector< tuple<int, int, int> > v;
			REP(i, 8) REP(j, 8) {
				int n = f(j, i, 2, false);
				if (n > 0) v.pb( make_tuple(-n, -i, -j) );
			}
			if (v.size() > 0) {
//				cout << -get<2>(v[0]) << " " << -get<1>(v[0]) << endl;
				sort( ALL(v) );
				f(-get<2>(v[0]), -get<1>(v[0]), 2, true);
			}
		}
//		out(); cout << endl;
	}
	out();
}

Measured memory_bytes: 3228
A, B, C, D, E, F = [int(x) for x in input().split()]

X = []
for i in range(F // (100 * A) + 1):
	for j in range((F - 100 * A * i) // (100 * B) + 1):
		X.append(100 * A * i + 100 * B * j)

Y = []
for i in range(F // C + 1):
	for j in range((F - C * i) // D + 1):
		Y.append(C * i + D * j)

concentrationMAX = 0
ans = [100 * A,0]

for i in X:
	for j in Y:
		if i + j > 0:
			if i + j <= F:
				if i // 100 * E >= j:
					if j / (i + j) > concentrationMAX:
						concentrationMAX = j / (i + j)
						ans[0] = i + j
						ans[1] = j

print(ans[0],end=' ')
print(ans[1])

Measured memory_bytes: 12468
/*input
10 4
40 10 20 70 80 10 20 70 80 60
*/

#include <bits/stdc++.h>
#define ll long long

using namespace std;

void run() {
	int n, k, i, j;
	cin >> n >> k;
	vector<int> a(n);
	for(auto &x : a)
		cin >> x;
	vector<int> dp(n, 1.5e9);
	dp[0] = 0;
	for(i=1; i<n; i++) {
		for(j=max(0, i-k); j<i; j++) {
			dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
		}
	}
	cout << dp[n-1] << endl;
}

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


Measured memory_bytes: 1024
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int countDigit(int n)
{
  int digit = 1;
  while((n /= 10) != 0)
    digit++;
  return digit;
}

int main()
{
  //5000兆日＝5*1,000,000,000,000,000 5 = 5* 10^15
  string s; cin >>s;
  double k; cin >> k;
  double wordlen = 0;
  double n = 1000000000000000;
  int ans;
  rep(i,s.length()){
    wordlen = pow(s[i]-'0',n);
    //cout << wordlen << endl;
    if(wordlen >= k) {
      cout << s[i];
      break;
    }else k -= wordlen;
  }
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cstdlib>

#define cmax(_a, _b) (_a < (_b) ? _a = (_b), 1 : 0)
#define cmin(_a, _b) (_a > (_b) ? _a = (_b), 1 : 0)
#define dmax(_a, _b) ((_a) > (_b) ? (_a) : (_b))
#define dmin(_a, _b) ((_a) < (_b) ? (_a) : (_b))

#define maxn 
typedef long long ll;
typedef double db;

int main()
{
	int A, B; scanf("%d%d", &A, &B);
	if (A <= 8 && B <= 8) puts("Yay!");
	else puts(":(");
	return 0;
}

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

long long cnt;
int A[1000000];
vector<int> G;
void insertionSort (int A[], int n, int g){
    for (int i = g; i < n; ++i){
        for (int j = i; j >= g; j -= g){
            // 如果有序就直接跳过，因为前面的都已经有序，不需要再做比较。
            if (A[j-g] <= A[j])
                break;
            else{
                swap(A[j-g], A[j]);
                cnt++;
            }
        }
        /*int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j = j - g;
            cnt++;
        }
        A[j+g] = v;*/
    }
}
void shellSort (int A[], int n){
    int h = 1;
    while (h <= n){
        G.push_back(h);
        h = 3 * h + 1;
    }
    for (int i = G.size()-1; i >= 0; --i){
        insertionSort(A, n, G[i]);
    }
}
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i){
        cin >> A[i];
    }
    shellSort(A, n);
    cout << G.size() << endl;
    for (int i = G.size()-1; i >= 0; --i){
        if (i == G.size()-1)
            cout << G[i];
        else
            cout << " " << G[i];
    }
    cout << endl;
    cout << cnt << endl;
    for (int i = 0; i < n; ++i){
        cout << A[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 7016
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

int N, M;
vector<int> dp;
vector<vector<int>> to;

int dfs(int v){
  if(dp[v] != -1) return dp[v];

  int ret = 0;
  for(auto u : to[v]){
    chmax(ret, dfs(u)+1);
  }
  return dp[v] = ret;
}

signed main() {
  cin >> N >> M;

  to.resize(N);
  REP(i, M){
    int u, v;
    cin >> u >> v;
    u--; v--;
    to[u].emplace_back(v);
  }

  dp.resize(N, -1);

  int ans = 0;
  REP(i, N){
    chmax(ans, dfs(i));
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 8576
#include<stdio.h>
int main()
{
	int a, b, c;
	int temp;

	scanf("%d %d %d\n", &a, &b, &c);
	if (a > b){
		temp = a;
	a = b;
	b = temp;
}
	if (b > c){
		temp = b;
	b = c;
	c = temp;
	}
	if (a > b){
		temp = a;
	a = b;
	b = temp;
}
	printf("%d %d %d\n", a, b, c);
	return 0;
}


Measured memory_bytes: 2736
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}
int n;
map<ll, int> sisu;
long long rec(map<long long, int>::iterator p, long long mul){
    if (p == sisu.end()) {
        if (mul == 1) return 1;
        else return 0;
    }
    long long res = 0;
    for (int i = 0; i < p->second + 1; ++i) {
        if(mul % (i+1) != 0) continue;
        res += rec(++p, mul / (i+1));
        --p;
    }
    return res;
}
int main(){
    cout << fixed << setprecision(10);
    cin >> n;
    for(int i = 1; i <= n; i++){
        auto ps = prime_factorize(i);
        for(auto it : ps){
            sisu[it.first] += it.second;
        }
    }
    cout << rec(sisu.begin(), 75) << endl;
    return 0;
}


Measured memory_bytes: 3580
import sys
input = sys.stdin.readline

S = input()

alphabets = set(chr(ord('a')+x) for x in range(26))

def F(S,alphabets):
    if len(S) == 0:
        return -1
    T = F(S[1:],alphabets-set([S[0]]))
    if T == -1:
        larger = [x for x in alphabets if x > S[0]]
        if not larger:
            return -1
        return min(larger)
    return S[0] + T

answer = F(S,alphabets)
print(answer)

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
    int h,w;
    scanf("%d%d",&h,&w);
    while(h!=0||w!=0){
    int i,j;
    for(i=0;i<h;i++){
        for(j=0;j<w;j++){
            if(i==0||i==h-1||j==0||j==w-1) printf("#");
            else printf(".");
        }
        printf("\n");
    }
    scanf("%d%d",&h,&w);
    printf("\n");
    }
}


Measured memory_bytes: 2060
def LCS():
 x = raw_input()
 y = raw_input()
 a, b = len(x), len(y)
 dsp1 = [0 for i in xrange(b+1)]
 for i in xrange(a):
  dsp2 = dsp1+[]
  for j in xrange(b):
   if x[i] == y[j]:
    dsp1[j+1] = dsp2[j] + 1
   elif dsp1[j+1] < dsp1[j]:
    dsp1[j+1] = dsp1[j]
 print max(dsp1)
  
n = input()
for a in xrange(n):
    LCS()

Measured memory_bytes: 6448
#include <bits/stdc++.h>
using namespace std;
int n,a,b;
long long ans;
bool check(int x)
{
	int cnt=0;
	while(x)
	{
		cnt+=x%10;
		x/=10;
	}
	if(cnt>=a&&cnt<=b)
		return 1;
	else
		return 0;
}
int main()
{
	scanf("%d%d%d",&n,&a,&b);
	for(int i=1;i<=n;i++)
	{
		if(check(i))
		ans+=i;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll zero = 0;
const ll INF = 10000000000000000; //10^16
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

struct UnionFind{
    
    vector<ll> par;
    vector<ll> trsize; //それを根とする木の大きさ
    
    UnionFind(ll N) : par(N), trsize(N){
        for(ll i = 0; i < N; i++) par.at(i) = i;
        for(ll i = 0; i < N; i++) trsize.at(i) = 1;
    }
    
    ll root(ll x){
        if(x == par.at(x)) return x;
        return par.at(x) = root(par.at(x));
    }
    
    void unite(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx == ry) return;
        par.at(rx) = ry;
        trsize.at(ry) = trsize.at(rx) + trsize.at(ry);
    }

    ll size(ll x){
        return trsize.at(root(x));
    }
    
    bool same(ll x, ll y){
        if(root(x) == root(y)) return true;
        return false;
    }
    
};

int main(void){
    ll N,M;
    cin >> N >> M;
    
    vector<pair<ll,ll>> bridge(M);
    for(ll i = 0; i<M; i++){
        cin >> bridge.at(i).first >> bridge.at(i).second;
        bridge.at(i).first--;
        bridge.at(i).second--;
    }
    
    vector<ll> ans(M, 0);
    ans.at(M-1) = N*(N-1)/2;
    
    UnionFind islands(N);
    
    ll a,b;
    for(ll i = M-1; i > 0; i--){
        a = bridge.at(i).first;
        b = bridge.at(i).second;
        if(!islands.same(a,b)){
            ans.at(i-1) = ans.at(i) - islands.size(a) * islands.size(b);
            islands.unite(a, b);
        }
        else{
            ans.at(i-1) = ans.at(i);
        }
    }
    
    for(ll i = 0; i < M; i++){
        printf("%lld\n", ans.at(i));
    }
    
}

Measured memory_bytes: 5248
# coding: utf-8
while 1:
    a,b=input().split()
    b=int(b)
    if b==0:
        break
    a='0'*(b-len(a))+a
    dic={}
    i=0
    while 1:
        if a in dic:
            print(dic[a],int(a),i-dic[a])
            break
        else:
            dic[a]=i
        a=str(int(''.join(sorted(list(a),reverse=True)))-int(''.join(sorted(list(a)))))
        a='0'*(b-len(a))+a
        i+=1
    


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

int main(){
    while(1){
        int mH,mW;
        cin>>mH>>mW;
        if((mH==0)&&(mW==0))break;
        for(int i=0;i<mH;i++){
            for(int j=0;j<mW;j++){
                if(((i>0)&&(i<mH-1))&&((j>0)&&(j<mW-1))){
                    cout<<".";
                }else{
                    cout<<"#";
                }
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 2992
#include <iostream>
#include <cstdio>
using namespace std;
int main(){

  int n;
  double x,m=0;
  cin>>n>>x;
  for(int i=0,a,b;i<n&&cin>>a>>b;i++) m=max(m,1.*b/a);
  printf("%.6f\n",x*m);
  return 0;
  
}

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

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  n /= 2;
  int count = 0;
  for (int i = 0; i < n; i++) {
      if (s[i] != s[s.size() - i - 1]) count++;
  }
  cout << count <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
int32_t main()
{
    int n;
    cin>>n;
    int m;
    cin>>m;
    if(m<2*n)
    cout<<m/2<<endl;
    else
    {
        int ans=n;
        m=m-n*2;
        //cout<<ans<<" "<<n<<" "<<m<<" "<<m/3<<endl;
        cout<<ans+(m/4)<<endl;
    }
}

Measured memory_bytes: 3564
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define sz(a) ((int) (a).size())

int main() {
	vector<int> a(4), p(4), desired = {1, 9, 7, 4};
	for (int i = 0; i < 4; ++i) {
		scanf("%d", &a[i]);
		p[i] = i;
	}
	do {
		bool ok = true;
		for (int i = 0; i < 4; ++i) {
			if (a[p[i]] != desired[i]) {
				ok = false;
				break;
			}
		}
		if (ok) {
			printf("YES\n");
			return 0;
		}
	} while (next_permutation(p.begin(), p.end()));
	printf("NO\n");
	return 0;
}

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

maxp = 100100

allPrimes = [1]
like2017 = []
primes_list = [0 for _ in range(maxp+1)]
import bisect

def isPrimeNum(num):
    if num in allPrimes:
        return True
    else:
        return False

def initPrimes(ma):
    furui = {i:0 for i in range(2,ma+1)}

    primes_list[1] = 1

    for i in range(2,ma):
        if furui[i] == 0:
            
            if i > 2 and primes_list[(i+1)//2] == 1:
                like2017.append(i)

            primes_list[i] = 1

            for h in range(1,ma):
                index = i * h
                if index>ma:
                     break
                furui[index] = 1




initPrimes(maxp)

count = 0
for _ in range(N):
    l,r = [int(x) for x in input().split()]

    f = bisect.bisect_left(like2017,l)
    t = bisect.bisect_right(like2017,r)

    print(t-f)

Measured memory_bytes: 16012
#include <bits/stdc++.h>
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;

int main() {
  ll N;
  cin >> N;
  ll M =  1;
  ll cnt = 1;
  ll sum = 0;
  while (sum + 26 * M < N) {
    sum += 26 * M;
    M *= 26;
    cnt += 1;
  }
  N -= sum;
  N -= 1;
  vector<ll> num(cnt);
  for (ll i = 0; i < cnt; ++i) {
    num.at(i) = N % 26;
    N /= 26;
  }
  reverse(num.begin(), num.end());
  for (ll i = 0; i < cnt; ++i) {
    cout << (char)(num.at(i) + 'a');
  }
  cout << "\n";
}


Measured memory_bytes: 3632
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)

using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vll = vector<ll>;
constexpr ll kMod = 1e9 + 7;

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

ll gdc(ll a, ll b) {
  ll v0 = a, v1 = b, v2 = a % b;
  while (v2 != 0) {
    v0 = v1;
    v1 = v2;
    v2 = v0 % v1;
  }
  return v1;
}

int main() {
  init();

  ll N;
  cin >> N;

  ll result = 0;
  for (ll i = 0; i < N; i++) {
    ll a;
    cin >> a;
    if (i == 0) {
      result = a;
    } else {
      result = gdc(a, result);
    }
  }

  cout << result << endl;

  return 0;
}


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

#define ll long long

int main() {
    double W, H, x, y;
    cin >> W >> H >> x >> y;
    double s = W*H/2;
    int res;
    if(abs(W/2 - x) < 0.0000000001 && abs(H/2 - y) < 0.0000000001) {
        res = 1;
    }else{
        res = 0;
    }
    printf("%lf %d\n", s, res);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
P = list(map(int,input().split()))
Q = list(map(int,input().split()))
L = [i for i in range(1,N+1)]
R = [i for i in range(1,N+1)]

A,B = 0,0
for i in range(N-1):
 
  A += L.index(P[i])
  B += R.index(Q[i])
  A *= N-i-1
  B *= N-i-1
  L[L.index(P[i])] = 10
  R[R.index(Q[i])] = 10
  L.sort()
  R.sort()
  
print(abs(A-B))



Measured memory_bytes: 3064
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.Char (digitToInt)

main :: IO ()
main = do
  mapM_ putStrLn =<< getc solve

solve :: String -> String
solve [] = []
solve [s1] = [s1]
solve [s1,s2] = [s1,s2]
solve (s1:s2:s3:ss)
  | s1 == '@' = replicate (digitToInt s2) s3 ++ solve ss
  | otherwise = s1 : solve (s2:s3:ss)

getc :: (String -> a) -> IO [a]
getc f = map f . lines <$> getContents

Measured memory_bytes: 3472
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;

int main() {
	int n;
	cin >> n;
	ll ans = 0;
	rep(i, n + 1) {
		if (i % 3 != 0 && i % 5 != 0) {
			ans += i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3580
#define rep(i,x) for (int i = 0; i < x; i++)
#define mod 1000000007
#define MOD 998244353
#define inf 1e18
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p;
typedef complex<double> com;


int main(){
	int n;
	cin >> n;
	ll ans = 0;
	rep(i, n) {
		int p;
		cin >> p;
		while (p % 2 == 0) {
			p /= 2;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
	string s, t;
	cin >> s >> t;
	bool flag = false;
	for (int i = s.size()-1; i >=0; --i) {
		if (s[i] == t[t.size()-1]||s[i]=='?') {
			if (i+1 < t.size()) {
				continue;
			}
			flag = true;
			for (int j = t.size()-1; j >=0; --j) {
				if (s[i + j-t.size()+1] != '?' && s[i + j-t.size()+1] != t[j]) {
					flag = false;
					break;
				}
			}
			if(flag)for (int j = t.size() - 1; j >= 0; --j) {
				s[i + j-t.size()+1] = t[j];
			}
			if(flag)break;
		}
	}
	if (flag) {
		for (int i = 0; i < s.size(); ++i) {
			if (s[i] == '?')s[i] = 'a';
		}
	}
	if (flag)cout << s << endl;
	else cout << "UNRESTORABLE" << endl;
	return 0;
}

Measured memory_bytes: 256
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define sc(x) scanf("%lld",&x)
    #define pf(x) printf("%lld\n",x)
    #define int long long
    #define all(x) x.begin(),x.end() 
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int MOD =  1000000007 ;
    const int MAX = 2e6 + 7;
    const int INF = 1e15;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ DEB $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    int x,ii,nn;
    set<int> st;

    void solve()
    {
        cin>>n;
        nn=sqrt(n);
        fo(i,2,nn+1)
        {
            if(n%i==0)
            {
                x=n;
                while(x>0 && x%i==0)x/=i;
                if(x%i==1)
                    st.insert(i);

                x=n;
                ii=n/i;
                while(x>0 && x%(ii)==0)x/=ii;
                if(x%ii==1)
                    st.insert(ii);
            }
        }

        n=n-1;
        nn=sqrt(n);

        fo(i,2,nn+1)
        {
            if(n%i==0)
            {
                st.insert(i);
                st.insert(n/i);
            }
        }
        if(n>1)
        st.insert(n);
        if(n+1>1)
        st.insert(n+1);

        cout<<st.size()<<endl;
        // for(auto x:st)deb(x)
        
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);

        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll n;
ll dp[100010];

int main(){
    cin >> n;
    rep(i,100010)dp[i] = INF;
    vector<ll> v;
    v.push_back(1);
    ll num = 6;
    while(num <= 100000){
        v.push_back(num);
        num *= 6;
    }
    num = 9;
    while(num <= 100000){
        v.push_back(num);
        num *= 9;
    }
    dp[0] = 0;
    rep(i,v.size()){
        rep(j,n){
            if(j + v[i] > n)continue;
            dp[j + v[i]] = min(dp[j] + 1,dp[j + v[i]]);
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N, M;
    cin >> N >> M;
    vector<int> v(M);
    rep(i, M) cin >> v[i];
    for (int i = 0; i < M; i++){
        N -= v[i];
    }

    if(N < 0){
        cout << "-1" << endl;
    } else {
        cout << N << endl;
    }
}


Measured memory_bytes: 3668
#include <iostream>
using namespace std;
int main()
{
  int n;
  cin >> n;
  long long l[100];
  l[0] = 2; l[1] = 1;
  for(int i=2; i<=n; i++){
    l[i] = l[i-1] + l[i-2];
  }
  cout << l[n] << endl;
  
  return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  
  bool path[N+1][N+1] = {false};
  
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    
    path[a][b] = true;
    path[b][a] = true;
    
  }
  
  int A[N];
  for (int i = 0; i < N; i++) {
    A[i] = i+1;
  }
  
  int ans = 0;
  do {
    bool cond = true;
    for (int i = 0; i < N-1; i++) {
      if(path[A[i]][A[i+1]]) {
        continue;
      } else {
        cond = false;
      }
    }
    if (cond) ans++;
    
  } while (next_permutation(A+1, A+N));
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int gcd(int a,int b) 
{  
  while(b!=0){
    int c = a%b;
    a=b;
    b=c;
  }
  return a;
}

int main(void) 
{
  int k,i,j,l;
  int wa = 0;
  
  scanf("%d",&k);
  
  for(i=1;i<=k;i++){
    for(j=1;j<=k;j++){
      for(l=1;l<=k;l++){
        wa+=gcd(gcd(i,j),l);
      }
    }
  }
  
  printf("%d",wa);
  return 0;
} 

Measured memory_bytes: 1728
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll dp1[1000001];
ll dp2[1000001];
vector<ll> tree[100001];
ll m;
void solve2(ll source,bool vis[],ll parent_ans)
{
	vis[source]=1;
	dp2[source]=((1+parent_ans)*dp1[source])%m;
	vector<ll> prefix;
	vector<ll> suffix;
	for(ll child:tree[source])
	{
		if(!vis[child])
		{
			prefix.push_back(1+dp1[child]);
			suffix.push_back(1+dp1[child]);
		}
	}
	for(int z=suffix.size() - 2;z>=0;z--)
	{
		suffix[z]=(suffix[z]*suffix[z+1])%m;
	}
	for(int z=1;z<prefix.size();z++)
	{
		prefix[z]=(prefix[z]*prefix[z-1])%m;
	}
	ll child_number=0;
	for(ll child:tree[source])
	{
		if(!vis[child])
		{
			ll ways=(1+parent_ans);
			ways= (child_number>0) ? (ways * (prefix[child_number-1]))%m : ways;
			ways= (child_number<(suffix.size()-1)) ? (ways*(suffix[child_number+1]))%m :ways;
			solve2(child,vis,ways);
			child_number++;
		}
	}
}
void solve1(ll source,bool vis[])
{
	vis[source]=1;
	dp1[source]=1;
	for(ll child:tree[source])
	{
		if(!vis[child])
		{
			solve1(child,vis);
			dp1[source] = (dp1[source]*(1+dp1[child]))%m;
		}
	}
}
int main()
{
	ll n;
	cin>>n>>m;
	ll edge=n-1;
	while(edge--)
	{
		ll u,v;
		cin>>u>>v;
		tree[u].push_back(v);
		tree[v].push_back(u);
	}
	bool vis[n+1];
	memset(vis,false,sizeof(vis));
	solve1(1,vis);

	memset(vis,false,sizeof(vis));
	solve2(1,vis,0);

	for(ll p=1;p<=n;p++)
		cout<<dp2[p]<<endl;
}

Measured memory_bytes: 26684
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  int h, w;
  cin >> h >> w;
  vector<string> v(h);
  rep(i,h) cin >> v[i];
  map<int, int> mph;
  map<int, int> mpw;
  string bh = "", bw = "";
  rep(i,h) bh += ".";
  rep(i,w) bw += ".";
  rep(i,h) {
    if (v[i] == bw) mph[i]++;
  }
  rep(j,w) {
    string t = "";
    rep(i,h) {
      t += v[i][j];
    }
    if (t == bh) mpw[j]++;
  }
  rep(i,h) {
    if (mph[i]) continue;
    rep(j,w) {
      if (mpw[j]) continue;
      cout << v[i][j];
    }
    cout << endl;
  }
}

int main() {
  solve();
  return 0;
}

Measured memory_bytes: 3568
def main():
    n, m = map(int, input().split())
    s = input().rstrip()
    ans = []
    x = n
    f = True
    while x > 0 and f:
        for i in reversed(range(m+1)):
            if i == 0:
                f = False
                break
            if s[max(0, x-i)] == '0':
                if x-i < 0:
                    ans.append(x)
                else:
                    ans.append(i)
                x = max(0, x-i)
                break
    if f:
        for v in reversed(ans):
            print(v, end=" ")
        print("")
    else:
        print("-1")

if __name__ == "__main__":
    main()

Measured memory_bytes: 4848
#include <iostream>
#include <climits>
using namespace std;
 
int main(void)
{
  int dp[1001][1001];  // [takara][weight]
  int wei[1001];       // [takara]
  int val[1001];       // [takara]
  int i, w;
  int n, tw;
  int datcnt;
  char c;
 
  cin >> tw;
  for(datcnt = 1; tw != 0; datcnt++){
    cin >> n;
    for(i = 1; i <= n; i++){
      cin >> val[i];
      cin >> c;
      cin >> wei[i];
    }
 
    // initArrayDP
    for(i = 0; i <= n; i++) {
      for(w = 0; w <= tw; w++) {
    dp[i][w] = 0;
      }
    }
    //cout << "--map";
    for(i = 1; i <= n; i++) {
      for(w = 1; w <= tw; w++) {
    int tem = w - wei[i];
    if(tem < 0) {
      dp[i][w] = dp[i-1][w];
    } else {
      dp[i][w] = max(dp[i-1][w], dp[i-1][tem] + val[i]);
    }
      }
    }
 
    //for(i = 1; i <= n; i++) {
    //  for(w = 1; w <= tw; w++) {
    //  printf("%5d", dp[i][w]);
    //  }
    //  printf("\n");
    //}
 
     
    // [takara]の最終列から価値最大かつ、そのなかで重さ最初を探す。
    int maxval  = INT_MIN;
    int lastwei = INT_MAX;
 
    for(w = 0; w <= tw; w++)
      maxval = max(dp[n][w], maxval);
 
    for(w = tw; w >= 0; w--)
      if(dp[n][w] == maxval) lastwei = min(lastwei, w);
 
    cout << "Case " << datcnt << ":" << endl;
    cout << maxval << endl << lastwei << endl;
     
    cin >> tw;
  }
  return 0;
}
//aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

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

int n,A[50];

int solve(int i, int m){
  if(m==0) return 1;
  if(i>=n) return 0;
  int res = (solve(i+1,m-A[i]) || solve(i+1,m));
  return res;
}

int main(){
  int q,m,i;
  
  cin >> n;
  for(i=0;i<n;i++) cin >> A[i];
  cin >> q;
  for(i=0;i<q;i++){
    cin >> m;
    if(solve(0,m)) cout << "yes" <<endl;
    else cout << "no" << endl;
  }
  return 0;
}



Measured memory_bytes: 3100
for i in range(10000):
    x, y = map(int, input().split())
    if x < y:
        print(str(x) + " " + str(y))
    elif y < x:
        print(str(y) + " " + str(x))
    elif x == 0:
        break
    else:
        print(str(y) + " " + str(x))


Measured memory_bytes: 5616
import java.io.{BufferedReader, InputStream, InputStreamReader, PrintWriter}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.reflect.ClassTag

object Main {
  val MOD = 1000000007
  val out = new PrintWriter(System.out)
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()
    val A = map(N)(_ => sc.nextInt())
    val ans = A.grpBy(identity).sumBy { case (num, as) =>
      val cnt = as.length
      if (cnt >= num) cnt - num
      else cnt
    }

    out.println(ans)
  }


  def main(args: Array[String]): Unit = {
    solve()
    out.flush()
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

  private def rep(n: Int)(f: Int => Unit): Unit = {
    var i = 0
    while(i < n) {
      f(i)
      i += 1
    }
  }

  private def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    var i = 0
    while(i < n) {
      res(i) = f(i)
      i += 1
    }
    res
  }

  private implicit class ArrayOpts[A](val as: Array[A]) extends AnyVal {
    def maxByOpt[B: Ordering](f: A => B): Option[A] = {
      if (as.nonEmpty) Some(as.maxBy(f)) else None
    }

    def grpBy[K](f: A => K): mutable.Map[K, ArrayBuffer[A]] = {
      val map = mutable.Map.empty[K, ArrayBuffer[A]]
      as.rep { a =>
        val k = f(a)
        map.getOrElseUpdate(k, ArrayBuffer()) += a
      }
      map
    }

    def rep(f: A => Unit): Unit = {
      var i = 0
      val N = as.length
      while(i < N) {
        f(as(i))
        i += 1
      }
    }

    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      var sum = num.zero
      rep { a =>
        sum = num.plus(sum, f(a))
      }
      sum
    }
  }

  private implicit class IterableOpts[A](val as: Iterable[A]) extends AnyVal {
    def sumBy[B](f: A => B)(implicit num: Numeric[B]): B = {
      as.foldLeft(num.zero)((acc, a) => num.plus(acc, f(a)))
    }
  }
}


Measured memory_bytes: 51172
#include <bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define rep(i,n) for(int i=0;i<(n);i++)
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; }
typedef long long ll;
#define PI 3.14159265358979323846264338327950L


int main() {
	ll k;
  	cin>>k;

	if(k%2==0||k%5==0){
    	cout<<-1<<endl;
    }
  
  	else{
      if(k%7==0){
      	k/=7;
      }
      
      int mod=9*k;
      int x=1%(9*k);
      for(int i=1;;i++){
      	x=(x*(10%mod))%mod;
        if(x==1){
        	cout<<i<<endl;
          return 0;
        }
      }
      
    }
  return 0;
    }



Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
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 long long INF = 1LL << 60;
// spring s; cin >> s;
// cout << res << endl;
// --------write my code!!!!!----------//

int main(){
    long long N,A,B,C,D,E; cin >> N >> A >> B >> C >> D >> E;
    long long res =max({(N-1)/A,(N-1)/B,(N-1)/C,(N-1)/D,(N-1)/E})+5;
    cout << res << endl;
}


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

const ll MOD = 998244353;

int main(){
    int n, s; cin >> n >> s;
    vector<ll> a(n); rep(i,n) cin >> a[i];

    vector<vector<ll>> dp(n+1,vector<ll>(s+1,0));
    dp[0][0] = 1;
    ll ans = 0;
    rep(i,n) {
        rep(j,s+1) {
            if (j == 0) dp[i+1][j] = dp[i][j] + 1;
            else {
                if (j < s) dp[i+1][j] += dp[i][j];
                int prev = j - a[i];
                if (prev >= 0) dp[i+1][j] += dp[i][prev];
                dp[i+1][j] %= MOD;
            }
        }
        ans += dp[i+1][s] * (n - i) % MOD;
        ans %= MOD;
    }

    cout << ans << endl;
    return 0;
}

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


#define base 1000000007LL
#define ll long long
// unsigned long long int t = 10000000000000000003ULL;
#define ulint unsigned long long int
#define ld long double
#define X first
#define Y second
#define pb push_back
#define EPS 1e-15
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())

#define ms(s, n) memset(s, n, sizeof(s))

#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define sqr(a) (a)*(a)

#define foru(i,a,b) for (ll i = (a); i <= (b); i++)
#define ford(i,a,b) for (ll i = (a); i >= (b); i--)
#define cbit(a) __builtin_popcount(a)
#define uni(a) (a).resize(unique(all(a)) - (a).begin())
#define cprint(n) printf("%.6lf + %.6lfi\n", (n).real(), (n).imag())

#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it !=(a).end(); it++)


using namespace std;
typedef pair<ll, ll> II;
typedef pair<int, int> ii;



struct Edge{
    ll u,v,w;
    Edge(ll u=0, ll v=0, ll w=0): u(u),v(v),w(w) {}
    bool operator < (Edge a){return w<a.w;}
};

const int M=1e5+7;
const int MM=4*M;
const ll MOD=base;
const int MAX=1e9;


inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll power(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = r * n % p; n = n * n % p;} return r;}
inline ll inverse(ll n, ll p=MOD){return power(n,p-2);}
ll search(ll a[], ll N, ll x){ ll l = 0, r = N - 1; while (l <= r){ ll mid = (l + r) / 2; if (x == a[mid]){ return 1; } else if (x < a[mid]){ r = mid - 1; } else if (x > a[mid]){ l = mid + 1; } } return -1; }

ll n;
ll a[M];



int main(){
    ios::sync_with_stdio(0);
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	ll res = 0;
	
	for (int i = 0; i < n; i++){
		res += a[i] - 1;
	}
	cout << res;
    return 0;
}





Measured memory_bytes: 256
N = int(input())
arr = []

for i in range(N):
  S = input()
  arr.append(S)
    
arr.sort()
cnt = 1
for i in range(N-1):
  a = arr[i]
  b = arr[i+1]
  if a != b:
    cnt += 1

print(int(cnt))

Measured memory_bytes: 24032
#include<iostream>
using namespace std;
int main(){
	long long n; cin >> n;
	long long cnt = 0;
	if (n == 2) { cout << 1 << endl; return 0; }
	for (long long i = 1; i*i <= n-1; i++) {
		if (!((n-1) % i)){
          cnt += 2;
		  if ((n-1) / i == i) cnt--;
        }
	}
	cnt--;
    cnt++;
	for (long long i = 2; i*i <= n; i++) {
		if (n % i) continue;
		long long tn = n;
		long long a = n / i;
		while (!(tn%i)) tn /= i;
		if( tn%i == 1 ) cnt++;
		if (a == i) continue;
		tn = n;
		while (!(tn%a)) tn /= a;
		if( tn%a == 1 ) cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
	int n,m;
	cin>>n>>m;
  	int sum=0;
	for(int i=0;i<2;i++){
		sum+=(n>m)?(n--):(m--);
	}
  	cout<<sum;
	return 0;
}

Measured memory_bytes: 256
S = input() #文字列の取得
s = list(S) #文字列リストに変換
ans = 1
index = 1
before = s[0] #文字列比較用変数

while index < len(s):
    if s[index] == before: #もし前の文字列と一致するなら
        if index == len(s)-1: #最終文字だけ例外処理
            break
        before = s[index]+s[index+1] #比較用の変数に次の文字列を結合した文字列を格納
        ans += 1
        index += 2 #次の文字列も結合しているため、一回飛ばす
    else:
        before = s[index]
        ans += 1
        index += 1
print(ans)

Measured memory_bytes: 4840
#include <bits/stdc++.h>
using namespace std;
//useful library
int long long gcd(int long long a, int long long b){
    return b?gcd(b,a%b):a;
} //最大公約数
int long long lcm(int long long a, int long long b){
    return a/gcd(a,b)*b;
} //最小公倍数
int long long GetDigit(int long long num){
    int long long digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
} //桁数
int long long GetDigitN(int long long num, int long long N){
    int long long digit=0;
    while(num!=0){
        num /= N;
        digit++;
    }
    return digit;
} //十進数でnumの際のN進数における桁数

int main(){
    string S;
    cin >> S;
    if((S.at(2) == S.at(3)) && (S.at(4) == S.at(5))){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
    int n, m;
    cin>>n;
    string s;
    deque<int> deq;
    for (int i=0; i<n; i++)
    {
        cin>>s;
        if (s=="insert")
        {
            cin>>m;
            deq.push_front(m);
        }
        if (s=="delete")
        {
            cin>>m;
            auto u=find(deq.begin(), deq.end(), m);
            if (u!=deq.end()) deq.erase(u);
        }
        if (s=="deleteFirst") deq.pop_front();
        if (s=="deleteLast") deq.pop_back();
    }
    for (int i=0; i<deq.size(); i++)
    {
        if (i!=deq.size()-1) cout<<deq[i]<<' ';
        else cout<<deq[i]<<'\n';
    }
    return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

const double INF=2e18;
const int MAX_V=1333;

struct edge{
	int to;
	double cost;
};

int V;
vector<edge> g[MAX_V];
// 頂点sからの最短距離
double d[MAX_V];
int n;
double x[1333], y[1333], r[1333];

void add_edge(int from, int to){
	double cost=max(0.0, sqrt((x[from]-x[to])*(x[from]-x[to])+(y[from]-y[to])*(y[from]-y[to]))-(r[from]+r[to]));
	g[from].push_back({to, cost});
	return;
}

void dijkstra(int s){
	// piiのfirstは最短距離、secondは頂点の番号
	priority_queue<pair<double, int>, vector<pair<double, int>>, greater<pair<double, int>>> que;
	fill(d, d+V, INF);
	d[s]=0;
	que.emplace(0, s);
	while(!que.empty()){
		pair<double, int> p=que.top();
		que.pop();
		int v=p.second;
		if(d[v]<p.first){
			continue;
		}
		REP(i, g[v].size()){
			edge e=g[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				que.emplace(d[e.to], e.to);
			}
		}
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout<<setprecision(20)<<fixed;
	double tx, ty;
	cin>>x[0]>>y[0]>>tx>>ty>>n;
	x[n+1]=tx;
	y[n+1]=ty;
	r[0]=r[n+1]=0;
	V=n+2;
	FOR(i, 1, n+1){
		cin>>x[i]>>y[i]>>r[i];
	}
	REP(i, V){
		REP(j, V){
			if(i!=j){
				add_edge(i, j);
			}
		}
	}
	dijkstra(0);
	// REP(i, V){
	// 	cout<<d[i]<<'\n';
	// }
	cout<<d[n+1]<<'\n';
	return 0;
}


Measured memory_bytes: 21616