akhauriyash/Code-Regression huggingface dataset:
def show(array):
    for i in range(len(array)):
        if i != len(array) - 1:
            print(array[i], end=' ')
        else:
            print(array[i])


def bubbleSort(array):
    flag = True
    count = 0
    while flag:
        flag = False
        for j in sorted(range(1, len(array)), reverse=True):
            if array[j] < array[j - 1]:
                array[j], array[j - 1] = [array[j - 1], array[j]]
                flag = True
                count += 1
    show(array)
    return count


input()
array = [int(x) for x in input().split()]

print(bubbleSort(array))



Measured memory_bytes: 5616
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <deque>
using namespace std;

#define next '\n'
#define sp " "
#define print(x) cout << (x)
#define println(x) cout << (x) << next
#define stop return(0)
#define rep(i, n) for(int (i) = (0); (i) < (n); (++i))
#define FOR(i, start, end) for(int (i) = (start); (i) < (end); (++i))
#define foreach(e, elem) for(auto& (e) : (elem))
#define FAST ios::sync_with_stdio(false); cin.tie(nullptr)
#define size(s) (s).size()
#define all(vec) (vec).begin(), (vec).end()
#define pb(e) push_back(e);
#define INF 1e+12
#define PI acos(-1)
using ll = long long;
using ull = unsigned long long;

vector<int> v;
vector<int> c;

int main(){
    int n, m;
    cin >> n >> m;
    int day = n;
    rep(i, m){
        int an;
        cin >> an;
        day -= an;
    }

    if(day < 0){
        println(-1);
    }else{
        println(day);
    }
}

Measured memory_bytes: 3640
N = int(input())
l = [0] * N

for i in range(1, N):
  a = i**2
  if 6*a > N:
    break
  for j in range(i, N):
    b = j**2
    d = i*j
    if a+2*b+2*i+j**2 > N:
      break
    for k in range(j, N):
      c = k**2
      e = i*k
      f = j*k
      s = a+b+c+d+e+f
      if s <= N:
        if (a==b) and (b==c):
          l[s-1] += 1
        elif (a==b) or (b==c):
          l[s-1] += 3
        else:
          l[s-1] += 6
      else:
        break
        
for num in l:
  print(num)

Measured memory_bytes: 9136
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define x first
#define y second
#define iter iterator
#define riter reversed_iterator
#define y1 Lorem_ipsum_
#define tm dolor_sit_amet_
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int mxN = 5e3;
llong f[2503][7503][2];
int n,m; llong P;

void updsum(llong &x,llong y) {x+=y-P,x+=(x>>31)&P;}

int main()
{
	n = read(); P = read(); m = n-1>>1;
	if(n==2ll) {puts("3"); return 0;}
	f[1][2][0] = f[1][2][1] = 1ll;
	for(int i=1; i<=m; i++)
	{
		if(i==1)
		{
			for(int j=2; j<n+m+1; j+=2)
			{
				if(i*2+j<=n+m+1)
				{
					updsum(f[i][i*2+j][0],f[i][j][0]);
					updsum(f[i][i*2+j][1],(f[i][j][0]+f[i][j][1])%P);
				}
				updsum(f[i+1][j+1][0],f[i][j][1]);
				updsum(f[i+1][j+1][1],f[i][j][1]);
			}
		}
		else
		{
			for(int j=1; j<n+m+1; j++)
			{
				if(i+1+j<=n+m+1)
				{
					updsum(f[i][i+1+j][0],f[i][j][0]);
					updsum(f[i][i+1+j][1],(f[i][j][0]+f[i][j][1])%P);
				}
				updsum(f[i+1][j+1][0],f[i][j][1]);
				updsum(f[i+1][j+1][1],f[i][j][1]);
			}
		}
//		for(int j=1; j<=n+m+1; j++) printf("f[%d][%d]: %lld %lld\n",i,j,f[i][j][0],f[i][j][1]);
	}
	if(!(n&1))
	{
		for(int j=1; j<=n+m+1; j++) {f[m][j][0] = f[m][j][1];}
	}
	llong ans = 0ll;
	for(int j=0; j<=n; j++)
	{
//		printf("f[%d][%d][0]=%lld\n",m,j+m+1,f[m][j+m+1][0]);
		llong tmp = ((n-j+1ll)*(n-j)/2ll)%P*f[m][j+m+1][0]%P;
		updsum(ans,tmp);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 293376
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, K: int, Q: int, A: "List[int]"):
    from collections import Counter
    c = Counter(A)

    ans = 0
    for v in c.values():
        if(K-Q+v <= 0):
            ans += 1
    
    for i in range(1,N+1):
        if(not c[i]):
            if(K-Q > 0):
                print(YES)
            else:
                print(NO)
        else:
            if(K-Q+c[i] > 0):
                print(YES)
            else:
                print(NO)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(Q)]  # type: "List[int]"
    solve(N, K, Q, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 11932
#include <bits/stdc++.h>
#define long long long int
using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n, m;
    cin >> n >> m;
    vector<int> sub(n);
    vector<bool> solved(n);

    int res_solve = 0;
    int res_pen = 0;
    for (int i = 0; i < m; i++) {
        int p; cin >> p; p--;
        string s; cin >> s;
        if (solved[p]) continue;
        if (s == "WA") {
            sub[p]++;
        } else {
            res_solve++;
            res_pen += sub[p];
            solved[p] = true;
        }
    }
    cout << res_solve << " " << res_pen << "\n";

    return 0;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	static int[] prices = { 0, 6000, 4000, 3000, 2000 };

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			StringTokenizer st = new StringTokenizer(line);
			int t = Integer.parseInt(st.nextToken());
			int n = Integer.parseInt(st.nextToken());
			System.out.println(prices[t] * n);
		}
	}
}

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

int main() {
	int a = 0, b = 0, c;
	for (int i = 0; i < 4; i++)
	{
		cin >> c;
		a += c;
	}
	for (int i = 0; i < 4; i++)
	{
		cin >> c;
		b += c;
	}
	cout << max(a, b) << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  VL a(n);
  REP(i, 0, n) cin >> a[i];
  VL acc(n + 1);
  REP(i, 0, n) acc[i + 1] = acc[i] + a[i];
  map<ll, int> tbl;
  REP(i, 0, n + 1) tbl[acc[i]]++;
  ll tot = 0;
  for (auto &e: tbl) {
    ll x = e.second;
    tot += x * (x - 1) / 2;
  }
  cout << tot << endl;
}


Measured memory_bytes: 15872
#include <iostream>

using namespace std;

int main() {
    int P, P5 = 0, P7 = 0;
    for (int i = 0; i < 3; ++i) {
        cin >> P;
        if (P == 5)P5++;
        if (P == 7)P7++;
    }
    if (P5 == 2 && P7 == 1) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.nio.charset.StandardCharsets;
import java.util.*;

public class Main {

    //グローバル変数を定義
    List<char[]> list = new ArrayList<>();

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        char[] array = sc.next().toCharArray();
        int[] intArray = new int[array.length];
        for(int i=0; i<array.length; i++){
            intArray[i] = Character.getNumericValue(array[i]);
        }

        long sum = 0;
        // nは個数で、Math.pow(2,n)は、32個の
        // 組み合わせができることを指している。
        for(int bit=0; bit<Math.pow(2, array.length-1); bit++){
//            StringBuilder str = new StringBuilder();
            String str = "";
            for(int i=0; i<array.length; i++){
                //bitにi番目のフラグが立っているかどうか
                if((1&bit>>i) == 1){
                    str += intArray[i] + "+";
//                    str.append(intArray[i] + "+");
                } else {
                    str += intArray[i];
//                    str.append(intArray[i]);
                }
            }
//            System.out.println(str);
            String[] res = str.split("[+]");
            for(String s: res){
//                System.out.println(s);
                long val = Long.parseLong(s);
                sum+=val;
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 23888
from collections import defaultdict
n,x = open(0).read().split()
n = int(n)
cnt = x.count('1') 
digits = list(map(int, list(x)))
x = int(x, 2)

d = defaultdict(int)
d[0] = 0
def calc(m):
    if m not in d:
        nxt = m % bin(m).count('1')
        d[m] = calc(nxt) + 1
    return d[m]

mmod = cnt - 1
pmod = cnt + 1

if mmod:
    mx = x % mmod
px = x % pmod

mbase = 1
pbase = 1

ans = []
while digits:
    digit = digits.pop()
    
    if digit and not mmod:
        ans.append(0)
    else:
        if digit:
            nx = (mx - mbase)%mmod
        else:
            nx = (px + pbase)%pmod
        ans.append(calc(nx) + 1)

    if mmod > 0:
        mbase = (mbase * 2) % mmod
    pbase = (pbase * 2) % pmod

while ans:
    print(ans.pop())

Measured memory_bytes: 101252
x, k, d = map(int, input().split())
p = (x + d * k) // (2 * d)

def f(a):
  return abs(x + d * (k - 2 * a))

if p > k or p < 0:
  print(min(f(0), f(k)))
else:
  print(min(f(p), f(p + 1)))

Measured memory_bytes: 9084
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int h1=read(),m1=read(),h2=read(),m2=read(),k=read();
	cout<<(h2-h1)*60+m2-m1-k<<endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const int INF=1e9;
const int MAX=100005;
const int MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define ALL(v) v.begin(), v.end()
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbgmap(mp) for (auto i = mp.begin(); i != mp.end(); ++i) { cout << i->first <<":"<<i->second << endl;}
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    string t;
    cin>>s>>t;
    ll ans=0;
    rep(i,s.length()){
        if(s[i]==t[i]){
            ans++;
        }
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k = sc.nextInt();
      Set<Integer> sets = new HashSet<>();
      while(k-- > 0) {
        int d = sc.nextInt();
        for(int i = 0; i < d; i++)
          sets.add(sc.nextInt());
      }

      System.out.println(n - sets.size());
  }
}

Measured memory_bytes: 37676
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		if(N == 1){
			Console.WriteLine(1);
			return;
		}
		
		int min = N;
		for(int i=0;i<N;i++){
			for(int j=i+1;j<N;j++){
				long p = X[i] - X[j];
				long q = Y[i] - Y[j];
				var UF = new UnionFind(N);
				for(int ii=0;ii<N;ii++){
					for(int jj=ii+1;jj<N;jj++){
						if(X[ii] - X[jj] == p && Y[ii] - Y[jj] == q) UF.Unite(ii,jj);
						if(X[ii] - X[jj] == -p && Y[ii] - Y[jj] == -q) UF.Unite(ii,jj);
					}
				}
				min = Math.Min(UF.Compo, min);
			}
		}
		Console.WriteLine(min);
		
		
		
		
		
		
	}
	int N;
	long[] X,Y;
	public Sol(){
		N = ri();
		X = new long[N];
		Y = new long[N];
		for(int i=0;i<N;i++){
			var d = ria();
			X[i] = d[0]; Y[i] = d[1];
		}
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}

class UnionFind{
	
	int[] parent;
	int[] mem;
	int compo;
	int N;
	public UnionFind(int n_){
		Initialize(n_);
	}
	
	public void Initialize(int n_){
		N=n_;
		parent=new int[N];
		mem=new int[N];
		for(int i=0;i<N;i++){
			parent[i]=i;
			mem[i]=1;
		}
		compo=N;
	}
	
	public int Parent(int a){
		if(parent[a]==a) return a;
		return parent[a] = Parent(parent[a]);
	}
	
	public bool IsUnited(int a,int b){
		return Parent(a) == Parent(b);
	}
	
	public void Unite(int a,int b){
		a = Parent(a); b = Parent(b);//Parent()を呼ぶことでa以上のノードは全てparentがrootになる
		if(a == b) return;
		parent[a] = b;
		mem[b] += mem[a];
		compo -= 1;
	}
	
	public bool IsRoot(int x){
		return x == parent[x];
	}
	public int MemCnt(int x){
		return mem[Parent(x)];
	}
	
	public void Dump(){
		for(int i=0;i<parent.Length;i++){
			Console.Write(i==0?"{0}":" {0}",parent[i]);
		}
		Console.WriteLine("");
	}
	
	public int Compo{
		get{
			return compo;
		}
	}
	
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N, M;
    cin >> N >> M;
    priority_queue<ll> que;
    for (int i = 0; i < N; i++) {
        ll a;
        cin >> a;
        que.push(a);
    }
    while (M > 0 && que.top() > 0) {
        ll price = que.top();
        que.pop();
        que.push(price / 2LL);
        M--;
    }
    ll ans = 0;
    while (!que.empty()) {
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
}

Measured memory_bytes: 1400
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

vector<ll> dp;
vector<vector<ll> > dp2(2);

ll rec(int d, int roc, int s) {
	if(dp2[d][roc] != -1) return dp2[d][roc];
	if(roc < s) {
		if(d == 0) return dp2[0][roc] = 0;
		else return dp2[1][roc] = dp[roc];
	} else {
		if(d == 0) return dp2[0][roc] = rec(1, roc - s, s);
		else return dp2[1][roc] = dp[roc] - rec(1, roc - s, s);
	}
}

int main(void) {
	int n, m;
	cin>>n>>m;
	vector<vector<pair<i_i, int> > > l(n);
	vector<bool> used(m, false);
	REP(i, m) {
		int a, b, c;
		cin>>a>>b>>c;
		--a;
		--b;
		l[a].pb(pair<i_i, int>(i_i(b, c), i));
		l[b].pb(pair<i_i, int>(i_i(a, c), i));
	}
	REP(i, n) {
		vector<int> d(n, INF);
		priority_queue<pair<i_i, int>, vector<pair<i_i, int> >, greater<pair<i_i, int> > > q;
		vector<bool> usedp(n, false);
		q.push(pair<i_i, int>(i_i(0, i), -1));
		d[i] = 0;
		usedp[i] = true;
		while(!q.empty()) {
			pair<i_i, int> np = q.top();
			q.pop();
				usedp[np.first.second] = true;
			if(d[np.first.second] != np.first.first) continue;
			if(np.second != -1) used[np.second] = true;
			REP(j, l[np.first.second].size()) {
				if(d[l[np.first.second][j].first.first] > d[np.first.second] + l[np.first.second][j].first.second) {
					d[l[np.first.second][j].first.first] = d[np.first.second] + l[np.first.second][j].first.second;
					q.push(pair<i_i, int>(i_i(d[l[np.first.second][j].first.first], l[np.first.second][j].first.first), l[np.first.second][j].second));
				} else if(d[l[np.first.second][j].first.first] == d[np.first.second] + l[np.first.second][j].first.second && !usedp[l[np.first.second][j].first.first]) {
					q.push(pair<i_i, int>(i_i(d[l[np.first.second][j].first.first], l[np.first.second][j].first.first), l[np.first.second][j].second));
				}
			}
		}
	}
	int cnt = 0;
	REP(i, m) if(!used[i]) {
		++cnt;
	}
	cout<<cnt<<endl;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> d(K);
  set<int> s;
  for (int i=0; i<K; i++) {
    cin >> d.at(i); // d_iの値
    vector<int> A(d.at(i));
    for (int j=0; j<d.at(i); j++) {
      cin >> A.at(j);
      s.insert(A.at(j));
    }
  }
  cout << N - s.size() << endl;
}

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

#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mod 1000000007

int main(){
	fast;
	string s;
	cin>>s;
	if(s[0]=='R' and s[1]=='R' and s[2]=='R')
		cout<<3;
	else if(s[0]=='R' and s[1]!='R' )
		cout<<1;
	else if(s[0]!='R' and s[1]=='R' and s[2]!='R')
		cout<<1;
	else if(s[2]=='R' and s[1]!='R' and s[0]!='R')
		cout<<1;
	else if(s[0]!='R' and s[1]==s[0] and s[2]==s[0])
		cout<<0;
	else 
		cout<<2;
	return 0;
}



Measured memory_bytes: 3652
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		
		int d = a + b;
		
		if (d >= c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23764
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
l = [a, b, c, d, e]
ans = 5
min_take = min(l)

if min(l) >= n:
    ans = 5
else:
    if n % min_take != 0:
        group = n // min_take
    else:
        group = n // min_take - 1
    ans += group

print(ans)

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

using namespace std;
typedef long long ll;
const int N = 2010;
const ll INFLL = 1e18;
int _w;

int n, x, a[N];

int nxt( int i ) {
	return i == n ? 1 : i+1;
}
int pre( int i ) {
	return i == 1 ? n : i-1;
}

int minv[N][N];
void prelude() {
	for( int i = 1; i <= n; ++i ) {
		minv[i][i] = a[i];
		for( int j = nxt(i); j != i; j = nxt(j) )
			minv[i][j] = min( minv[i][pre(j)], a[j] );
	}
}

void solve() {
	ll ans = INFLL;
	for( int i = 0; i < n; ++i ) {
		ll now = 1LL * i * x;
		for( int j = 1; j <= n; ++j ) {
			int p = j-i;
			p += p <= 0 ? n : 0;
			now += minv[p][j];
		}
		ans = min(ans, now);
	}
	cout << ans << endl;
}

int main() {
	cin >> n >> x;
	for( int i = 1; i <= n; ++i )
		cin >> a[i];
	prelude(), solve();
	return 0;
}


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

static const int MAX = 100000;
static const int INF = (1<<29);
int N,M;
vector< int > G[MAX];
bool V[MAX];
int indeg[MAX];
list< int > out;
bool flag = false;

void bfs(int num){
  queue<int> que;
  que.push(num);
  while(!que.empty()){
    if(que.size() >= 2) flag = true;
    int now = que.front(); que.pop();
    out.push_back(now);
    for(int i=0;i<G[now].size();i++){
      int v = G[now][i];
      indeg[v]--;
      if(indeg[v] == 0 && !V[v]){
	V[v] = true;
	que.push(v);
      }
    }
  }
}

void tsort(){
  for(int i=0;i<N;i++){
    indeg[i] = 0;
    V[i] = false;
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<G[i].size();j++) indeg[G[i][j]]++;
  }
  for(int i=0;i<N;i++){
    if(indeg[i] == 0 && !V[i]) bfs(i);
  }
  for(list<int>::iterator it = out.begin();it != out.end();it++){
    cout << (*it)+1 << endl;
  }
  if(flag) cout << "1" << endl;
  else cout << "0" << endl;
}

int main(){
  cin >> N >> M;
  for(int i=0;i<M;i++){
    int s,t; cin >> s >> t;
    s--; t--;
    G[s].push_back(t);
  }
  tsort();
}

Measured memory_bytes: 4348
n, m = map(int, input().split())
data1 = [list(map(int, input().split())) for i in range(n)]
data2 = [list(map(int, input().split())) for i in range(m)]
def d(i,j):
  return abs(data1[i][0] - data2[j][0]) + abs(data1[i][1] - data2[j][1])
for i in range(n):
  rv = d(i,0)
  rj = 0
  for j in range(1,m):
    v = d(i,j)  
    if v < rv:
      rv = v
      rj = j
  print(rj+1) 

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
void calc_comb(vector<vector<long long>> &v){
    rep(i,v.size()){
        v[i][0]=1;
        v[i][i]=1;
    }
    for(int i=1; i<v.size(); i++){
        for(int j=1; j<i; j++){
            v[i][j]=(v[i-1][j-1]+v[i-1][j]);
        }
    }
}
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    ll ans=a[0];
    ll nearans=a[0];
    ll c=a[n-1]/2;
    if(a[n-1]%2) c++;
    for(int i=0; i<n-1; i++){
        if(a[i]<=c) ans=a[i];
        else{
            nearans=a[i];
            break;
        }
    }
    cout<<a[n-1]<<" ";
    if(abs(c-nearans) > abs(c-ans) ) cout<<ans<<endl;
    else cout<<nearans<<endl;
}

Measured memory_bytes: 640
a,b,c,d = map(int,input().split())
a -=1

from fractions import gcd

def solve(n1,n2):
    k = gcd(n1,n2)
    return int((n1*n2)/k)

l = solve(c,d)


        
ans1 = b - int(b//c) - int(b//d) + int(b//l)
ans2 = a - int(a//c) - int(a//d) + int(a//l)

print(int(ans1-ans2))


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

#define int         long long
#define mp          make_pair
#define pb          push_back
#define vi          vector<int>
#define vii         vector<pair<int,int>>
#define mi          map<int,int>
#define mii         map<pair<int,int>,int>
#define all(a)      (a).begin(),(a).end()
#define f           first
#define s          second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define hellhsh     444440583533
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rep0(a,n)  for(int i=0;i<n;i++)cin>>a[i];
#define si(x)       cin>>x;
#define sii(x,y)    cin>>x>>y;
#define ahell   998244353
#define p(x)   printf("%I64d",x)
#define aut(x,u) for(auto x:u)
#define pri     queue<pii>
#define forn(k) for(int i=0;i<k;i++)
#define N 200007
#define fl 1.0000000000
#define ms(a,n) memset(a,n,sizeof(a))
#define INF 10000000000007
using namespace std;
int x,y,m,k;
int n;
vii list[1006];
void solve()
{
int q=0,i,j;
int x,y=0,ct=0;
cin>>k>>n;
int a[200007];
rep0(a,n);
y=0;
y=max(k-a[n-1]+a[0],y);
for(i=1;i<n;i++)
  y=max(y,a[i]-a[i-1]);
cout<<k-y;

}
main()
{
ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    int i,j,k,test=1;
    
  //cin>>test;
  while(test--)
  {
      solve();
      //cout<<"\n";
 }

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
int main(){
  string S;cin>>S;
  LL ans=0,p=0;
  for(int i=0;i<S.size();i++){
    if(S[i]=='W'){
      ans+=i-p;
      p++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cstdlib>
#include <cstdio>
using namespace std;

const double EPS = 1e-9;

double tr(double xn, double q){
	double xn2 = xn*xn;
	double xn3 = xn2*xn;
	if(abs(xn3 - q) < 0.00001*q){
		return xn;
	}
	return tr(xn-(xn3-q)/(3.0*xn2), q);
}

int main(){
	int q;
	while(cin >> q, q != -1){
		printf("%lf\n", tr(q/2.0, q));
	}

	return 0;
}

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

#define INIT_CAP 10
#define INF 1000000000

inline int nextInt(void) {
	int ch;
	int sign, x;

	do {
		ch = getchar();
	} while (ch < '-');

	if (ch == '-') {
		sign = -1;
		ch = getchar();
	} else
		sign = 1;

	x = 0;
	while (ch >= '0' && ch <= '9') {
		x = x * 10 + ch - '0';
		ch = getchar();
	}

	return sign * x;
}

typedef struct {
	int to, w;
} Edge;

typedef struct {
	Edge *elem;
	int cap, size;
} VecEdge;

typedef struct {
	int num, d;
} PNumDis;

VecEdge adj[10000];
PNumDis heap[500000];
int hsize;
int d[10000];

void init(int n) {
	while (n--)
		adj[n] = (VecEdge){malloc(sizeof(Edge) * INIT_CAP), INIT_CAP, 0};
}

inline void add(int from, int to, int w) {
	if (adj[from].size == adj[from].cap) {
		adj[from].cap <<= 1;
		adj[from].elem = realloc(adj[from].elem, sizeof(Edge) * adj[from].cap);
	}
	adj[from].elem[adj[from].size++] = (Edge){to, w};
}

inline void insert(int num, int d) {
	int i;
	for (i = hsize++; i > 0 && d < heap[i - 1 >> 1].d; i = i - 1 >> 1)
		heap[i] = heap[i - 1 >> 1];
	heap[i] = (PNumDis){num, d};
}

inline int calcNextIdx(int i) {
	return i * 2 + 1 + (i * 2 + 2 < hsize && heap[i * 2 + 1].d > heap[i * 2 + 2].d);
}

inline PNumDis delete(void) {
	int i;
	int nextIdx;
	const PNumDis root = heap[0], last = heap[--hsize];

	for (i = 0; i * 2 + 1 < hsize && last.d > heap[nextIdx = calcNextIdx(i)].d; i = nextIdx)
		heap[i] = heap[nextIdx];
	heap[i] = last;

	return root;
}

void dijkstra(int n, int s) {
	int i;

	for (i = 0; i < n; i++)
		d[i] = INF;

	d[s] = 0;
	insert(s, 0);
	while (hsize > 0) {
		const PNumDis fromP = delete();

		if (fromP.d > d[fromP.num])
			continue;

		for (i = 0; i < adj[fromP.num].size; i++) {
			const Edge e = adj[fromP.num].elem[i];
			if (fromP.d + e.w < d[e.to]) {
				d[e.to] = fromP.d + e.w;
				insert(e.to, d[e.to]);
			}
		}
	}
}

int main(void) {
	int i;
	int n;

	scanf("%d", &n);

	init(n);
	for (i = 0; i < n; i++) {
		int u, k;
		scanf("%d %d", &u, &k);
		while (k--) {
			int v = nextInt(), c = nextInt();
			add(u, v, c);
		}
	}

	dijkstra(n, 0);

	for (i = 0; i < n; i++)
		printf("%d %d\n", i, d[i]);

	return 0;
}

Measured memory_bytes: 5688
from itertools import chain
explosion = [i for i in range(-3, 4) if i] + [0] * 6

def bomb(x, y):
	field[y][x] = 0
	for dx, dy in zip(explosion, reversed(explosion)):
		nextX = x + dx
		nextY = y + dy
		if nextX in range(0, 8) and nextY in range(0, 8):
			if field[nextY][nextX] == 1:
				bomb(nextX, nextY)
			field[nextY][nextX] = 0

for i in xrange(input()):
	raw_input()
	field = [[int(c) for c in raw_input()] for j in range(8)]
	x = input() - 1
	y = input() - 1
	bomb(x, y)
	print "Data %d:" % (i + 1)
	for f in field:
		print "".join(str(i) for i in f)

Measured memory_bytes: 4432
import java.util.Scanner;

public class Main {

	static int n;
	static int[][] a;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		a = new int[2][n];
		for(int i = 0 ; i < 2 ; i++) {
			for(int j = 0 ; j < n ; j++) {
				a[i][j] = sc.nextInt();
			}
		}
		int ans = dfs(0, 0, a[0][0]);
		System.out.println(ans);
	}

	public static int dfs(int x, int y, int sum) {
		int ret = 0;
		if(x == 1 && y == n - 1) {
			return sum;
		}
		if(0 <= x + 1 && x + 1 < 2 && 0 <= y && y < n && 0 <= x && x < 2 && 0 <= y + 1 && y + 1 < n) {
			ret = Math.max(dfs(x + 1, y, sum + a[x + 1][y]), dfs(x, y + 1, sum + a[x][y + 1]));
		} else if(0 <= x + 1 && x + 1 < 2 && 0 <= y && y < n) {
			ret = dfs(x + 1, y, sum + a[x + 1][y]);
		} else if(0 <= x && x < 2 && 0 <= y + 1 && y + 1 < n) {
			ret = dfs(x, y + 1, sum + a[x][y + 1]);
		} else {
			ret = 0;
		}
		return ret;
	}

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
#define Endl '\n'
typedef long long int lli;
/*
created on: 19/4/2020
*/
void solve();
lli ans;
int main(int argc, char const *argv[]){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
}
void solve(){
  long double R;
  cin>>R;
  cout<<2*3.14159*R<<Endl;
}


Measured memory_bytes: 3776
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
 
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;
 
 
signed main()
{
	bool is_flip = false;

	int H, W, h, w;
	cin >> H >> W >> h >> w;

	int K = h;
	int S = (w * h) - K;
	int allK = (int)(W / w) * H;
	int allS = (W * H) - allK;

	if (allS * K == S * allK)
	{
		int temp = H;
		H = W;
		W = temp;
		temp = h;
		h = w;
		w = temp;
		is_flip = true;
		K = h;
		S = (w * h) - K;
		allK = (int)(W / w) * H;
		allS = (W * H) - allK;
		if (allS * K == S * allK)
		{
			cout << "No" << endl;
			return 0;
		}
	}

	int C = allK * S;
	int D = allK * K;
	int E = K * allS;

	int a = (int)ceil(2 * D / (double)(E - C));
	int b = (int)((C / (double)D) * a) + 1;

	cout << "Yes" << endl;


	if (!is_flip)
	{
		for (int y = 0; y < H; y++)
		{
			for (int x = 0; x < W; x++)
			{
				cout << (((x + 1) % w == 0) ? -b : a) << " ";
			}
			cout << endl;
		}
	}
	else
	{
		for (int y = 0; y < W; y++)
		{
			for (int x = 0; x < H; x++)
			{
				cout << (((y + 1) % w == 0) ? -b : a) << " ";
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 1280
n,m,c = map(int,input().split())
b_list = list(map(int,input().split()))
ans = 0
for i in range(n):
    a = list(map(int,input().split()))
    dum = 0
    for j in range(m):
        dum += a[j] * b_list[j]
    if dum+c > 0:
        ans += 1
print(ans)

Measured memory_bytes: 38256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = int(1e09) + 7
INF = int(1e15)


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


def main():
    # sys.stdin = open("sample.txt")
    N = Scanner.int()
    A, B = [0] * N, [0]*N
    for i in range(N):
        A[i], B[i] = Scanner.map_int()
    ans = 0
    for i in reversed(range(N)):
        A[i] += ans
        if A[i] % B[i] != 0:
            ans += B[i] - A[i] % B[i]
    print(ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 43480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll n; cin >> n;
    ll ans = 1001001001001;
    for(ll i=1;i*i<=n;i++){
        if (n%i != 0) continue;
        ll j = n/i;
        ans = min(ans, i+j-2);
    }
    cout << ans << endl;
    return 0;
}

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

void trace(int A[], int N) {
    cout << A[0];
    for (int i=1; i < N; i++) {
        cout << " ";
        cout << A[i];
    }
    cout << endl;
}

void bubbleSort(int A[], int N) {
    int v;
    int flag = 1;
    int cnt = 0;
    
    while (flag > 0) {
        flag = 0;
        for (int j=N-1; j > 0; j--) {
            v = A[j];
            if (A[j - 1] > v) {
                A[j] = A[j - 1];
                A[j - 1] = v;
                v = A[j];
                flag = 1;
                cnt++;
            }
    }
}
    trace(A, N);
    cout << cnt << endl;
    return;
}


int main(){
    int n;
    int A[110];

    cin >> n;
    for (int i=0; i < n; i++) {
        cin >> A[i];
    }
    bubbleSort(A, n);
} 


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N, R;
    cin >> N >> R;
    if (N >= 10) {
        cout << R << '\n';
    }else{
        cout << 100 * (10 - N) + R << '\n';
    }

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define clr(x, y) memset(x,y,sizeof(x));
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i, m, n) for(int i=m ; i<n ; i++)
#define forr(i, m, n) for(int i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N = 1e5 + 5;
const ll OO = (ll) 1e9 + 7;
using namespace std;

int main() {
    IO;
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll mx = 0;
    ll tar7 = min(a, k);
    mx += tar7, k -= tar7;
    tar7 = min(b, k);
    k -= tar7;
    tar7 = min(c, k);
    mx -= tar7, k -= tar7;
    cout<<mx;


}

Measured memory_bytes: 3648
k, n = map(int, input().split())
if k % 2 == 0:
    print(k // 2, end=" ")
    for i in range(n - 1):
        print(k, end=" ")
else:
    l = [(k + 1) // 2 for i in range(n)]
    for i in range(n // 2):
        if l[-1] == 1:
            l.pop()
        else:
            l[-1] -= 1
            for j in range(n - len(l)):
                l.append(k)
    print(*l, sep=" ")

Measured memory_bytes: 25500
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[1000010];
ll kai[1000010];
ll beki(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k%2==1){
            ret*=now;
            ret%=mod;
        }
        now*=now;
        now%=mod;
        k/=2;
    }
    return ret;
}
ll gyaku(ll n){
    return beki(n,mod-2);
}
void nckinit(ll n){
    kai[0]=1;
    kai[1]=1;
    for(int i=2;i<=n;i++){
        kai[i]=kai[i-1]*i;
        kai[i]%=mod;
    }
    gya[n]=gyaku(kai[n]);
    for(int i=n-1;i>=1;i--){
        gya[i]=gya[i+1]*(i+1);
        gya[i]%=mod;
    }
    gya[0]=1;
}
ll nck(ll n,ll k){
    if(k<0)return 0;
    if(k==0||n==k)return 1;
    ll ret=kai[n];
    ret*=gya[n-k];
    ret%=mod;
    ret*=gya[k];
    ret%=mod;
    return ret;
}
ll npk(ll n,ll k){
    if(k<0)return 0;
    if(k==0)return 1;
    ll ret=kai[n];
    ret*=gya[n-k];
    ret%=mod;
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    if(n%2==1){
        cout<<n/2<<endl;
    }
    else{
        cout<<n/2-1<<endl;
    }
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const double PI = 3.1415926535897932;
const int MOD = 1e9 + 7;
vector<pair<ll, ll>> prime_factorize(ll n) {
  vector<pair<ll, ll>> res;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i != 0) continue;
    ll ex = 0;
    while (n % i == 0) {
      ++ex;
      n /= i;
    }
    res.push_back({i, ex});
  }
  if (n != 1) res.push_back({n, 1});
  return res;
}

//cin.tie(0);ios::sync_with_stdio(false);
int main() {
  ll n, p;
  cin >> n >> p;
  ll ans = 1;
  for (auto v : prime_factorize(p)) {
    ans *= pow(v.first, v.second/n);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {

    int N;
    std::cin >> N;
    std::vector<std::pair<int, int>> pos(N);
    for (auto& v : pos)std::cin >> v.first >> v.second;
    std::map<std::pair<int, int>, int> memo;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i == j)continue;
            int p = pos[i].first - pos[j].first;
            int q = pos[i].second - pos[j].second;
            ++memo[std::make_pair(p, q)];
        }
    }
    auto pq = *std::max_element(memo.begin(), memo.end(), [](auto a, auto b) { return a.second < b.second; });

    std::cout << (N == 1 ? 1 : N - pq.second) << std::endl;

}

Measured memory_bytes: 384
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

ll a, b;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b;
    for (ll i = 1; i < 101010; i++) {
        ll e = i * 8 / 100, t = i * 10 / 100;
        if (e == a && t == b) {
            cout << i << '\n';
            return 0;
        }
    }
    cout << -1 << '\n';
    return 0;
}


Measured memory_bytes: 256
n = input()

money = 0
if int(n)%1000 == 0:
    print(0)
elif 1000 > int(n):
    ans = 1000 - int(n)
    print(ans)
else:
    money = (int(n[:-3]) + 1)*1000
    ans = money - int(n)
    print(ans)


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

using namespace std;

int main(void) {
    int N, K;
    cin >> N >> K;
    vector<int64_t> mod(K);
    for(int a=1; a<=N; a++) {
        mod.at(a%K) ++;
    }
    int64_t ans = 0;
    for(int a=1; a<=N; a++) {
        int inv = (K - a%K) % K;
        if((2*inv) % K == 0) {
            ans += mod.at(inv) * mod.at(inv);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <queue>
using namespace std;
int N,M;

typedef pair<int,int> P;
priority_queue<P> jobs;
priority_queue<int> values;

int main(){
  cin >> N >> M;
  for(int i=0;i<N;i++){
  int A,B;cin >> A >> B;
    jobs.push(make_pair(-A,B));
  }
  
  int sum=0;P task;
  for(int t=M;t>=0;t--){
    while(-jobs.top().first <= M-t && !jobs.empty()){
      task = jobs.top();jobs.pop();
      values.push(task.second);
    }
    
    if(!values.empty()){
      sum += values.top();values.pop();
    }
  }
  
  cout << sum << endl;
 
  return 0;
}

Measured memory_bytes: 1908
#include<stdio.h>
int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	if (n == 2)
	{
		if (k == 0)
		{
			printf("1\n");
			printf("1 2\n");
			return 0;
		}
		else
		{
			printf("-1\n");
			return 0;
		}
	}
	if (n == 3)
	{
		if (k == 0)
		{
			printf("3\n");
			printf("1 2\n2 3\n1 3\n");
			return 0;
		}
		if (k == 1)
		{
			printf("2\n");
			printf("1 2\n2 3\n");
			return 0;
		}
		printf("-1\n");
		return 0;
	}
	int max = (n - 1) * (n - 2) / 2;
	if (k > max)
	{
		printf("-1\n");
		return 0;
	}
	int m = 0;
	int ans1[10004], ans2[10004];
	int i, j;
	for (i = 1; i < n; i++)
	{
		ans1[m] = 1;
		ans2[m] = i + 1;
		m++;
	}
	i = 2;
	j = 3;
	while (max > k)
	{
		max--;
		ans1[m] = i;
		ans2[m] = j;
		m++;
		j++;
		if (j > n)
		{
			i++;
			j = i + 1;
		}
	}
	printf("%d\n", m);
	for (i = 0; i < m; i++)
		printf("%d %d\n", ans1[i], ans2[i]);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

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

#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

string s;
vector<int> p[26];

int main() {
    cin >> s;
    REP(i, s.size()) {
        p[s[i] - 'a'].push_back(i);
    }
    REP(i, 26) {
        if (p[i].size() < 2) continue;
        for (int j = 0; j < p[i].size() - 1; j++) {
            if (p[i][j + 1] - p[i][j] < 3) {
                cout << p[i][j] + 1 << " " << p[i][j + 1] + 1 << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1" << endl;
    return 0;
}

Measured memory_bytes: 1148
#include <stdio.h>

int main(){
	int N, A, B;
	scanf("%d %d %d", &N ,&A ,&B);
	int x1 = A * N;
	if (x1 <= B){
		printf("%d",x1);
	}else{
		printf("%d",B);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;


int main() {

    ll N, K;
    vector<ll> tree;

    cin >> N >> K;
    tree.resize(N, 0);

    for (ll i = 0; i < N; ++i)
        cin >> tree[i];

    sort(tree.begin(), tree.end());

    ll res = 10000000000;
    for(ll i=0; i+K-1<N; i+=1)
        res=min(res, tree[i+K-1]-tree[i]);

    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 1024
def gcd(m, n):
    x, y = max(m, n), min(m, n)
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x % y
            x, y = y, z
        else:
            return z


def lcm(m, n):
    return int(m * n / gcd(m, n))


n = int(input())
print(lcm(2, n))


Measured memory_bytes: 2940