akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <iostream>
#include <stack>

using namespace std;

int main(){
    int n;
    cin >> n;
    printf("%d\n", 180 * (n - 2));
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include <math.h>
using namespace std;


	int main() {
		int n;
		cin >> n;
		int a = 0, b = 0;
		int A[10000],k[100000];

		for (int i = 0; i < n; i++) {
			cin >> A[i];
			if (A[i] == 2) {
				b++;
			}
		}
		
		for (int i = 0; i < n; i++) {
			a = 0;
			int R = sqrt(A[i]);
			if (A[i] != 0) {
				for (int j = 2; j <= R; j++) {
					k[j] = A[i] % j;
					if (k[j] != 0) {
						a++;
					}
				}
				if (a == R - 1 && A[i] != 2) {
					b++;
				}
			}
		}
		cout << b << endl;
		
		return 0;
	}


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

int main(){
  string s;
  cin >> s;
  vector<int> v(26, 0);
  rep(i, s.size()){
    int x = static_cast<int>(s[i]) - 97;
    ++v[x];
  }
  string ans = "None";
  ostringstream sout;
  rep(i, 26){
    if (v[i] == 0){
      sout << static_cast<char>(i + 97);
      ans = sout.str();
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int sed(int N) {
    int a = N;
    int c = 0;
    bool b = true;
    while(b){
        if (a == 0) {
            b = false;
        }
        c += a % 10;
        a /= 10;
    }
    return c;
}
int main() {
    int N; cin >> N;
    if (N % sed(N) == 0) printf("%s\n", "Yes");
    else printf("%s\n", "No");
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
using namespace std;
int main() {
    int n;
    cin >> n;
    int a, b;
    int cou = 0;
    rep(i, n) {
        cin >> a >> b;
        if(a == b)
            cou++;
        else
            cou = 0;
        if(cou == 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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


int main() {
    const int valueOfCoin = 500;
    int payment = 0;
    int numOf1yen = 0;
    std::cin >> payment >> numOf1yen;
    
    int fraction = payment % valueOfCoin;
    if(fraction <= numOf1yen) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }    
}

Measured memory_bytes: 3632
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	var (
		x, ans float64
		u      string
	)
	for i := 0; i < n; i++ {
		fmt.Scan(&x, &u)
		if u == "BTC" {
			x = 380000 * x
		}
		ans += x
	}

	fmt.Println(ans)
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<lli> x(N), y(N), z(N);
    REP(i, 0, N) {
        cin >> x[i] >> y[i] >> z[i];
    }
    lli ans = -(1LL << 60);
    REP(t, 0, 8) {
        int tx = 2 * ((t >> 2) & 1) - 1, ty = 2 * ((t >> 1) & 1) - 1, tz = 2 * (t & 1) - 1;
        vector<lli> sum(N);
        REP(i, 0, N) {
            sum[i] += tx * x[i] + ty * y[i] + tz * z[i];
        }
        sort(begin(sum), end(sum), greater<lli>());
        lli res = 0;
        REP(i, 0, M) {
            res += sum[i];
        }
        ans = max(res, ans);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
    li l,r,d;

    cin>>l>>r>>d;

    li ans=r/d-(l+d-1)/d+1;

    cout<<ans;
}

int main()
{    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
using namespace std;
int main(void){
    int n, k;
    string s;
    cin >> n >> s >> k;
    
    char sk = s[k-1];
    
    int i;
    for(i = 0; i<s.size(); i++){
     if(s[i] != sk) s[i] = '*';
    }
    
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            long N = long.Parse(Console.ReadLine());
            int[] A = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            int cnt = A.Where((v, i) => i % 2 == 0).Count((v)  => v % 2 != 0);
            Console.WriteLine(cnt);
        }
    }
}

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

#define vi vector<int>
#define vii vector<vi>
#define pi pair<int,int>
#define vpi vector<pi>
#define S second
#define F first
#define pb push_back
#define inf 1000000
#define Test int t,i=0;cin>>t;while(i<t)
#define MAXN 100005
#define M 100005

signed main()
{
    int a[M],b[M],c[M];
    Test{
        cin>>a[i]>>b[i]>>c[i];
        i+=1;
    }
    for(i=1;i<t;i++)
    {
        a[i] = max(a[i]+b[i-1],a[i]+c[i-1]);
        b[i] = max(a[i-1]+b[i],c[i-1]+b[i]);
        c[i] = max(a[i-1]+c[i],b[i-1]+c[i]);
    }
    cout<<max({a[t-1],b[t-1],c[t-1]})<<"\n";
}

Measured memory_bytes: 1408
#include <iostream>
#include <stdlib.h>
#include <stdio.h>      /* printf */
#include <math.h>       /* pow */
#include <vector>
#include <algorithm>

void print_array(std::vector<int> list)
{
  for(int i = 0; i < list.size(); ++i){
    if(i>0) std::cout << " ";
    std::cout << list[i];
  }
  std::cout << std::endl;
}

int main(void){

    int num;
    std::cin >> num;
    if (num>100) {
        std::cout << "list too big" << std::endl;
        return 1;
    }
    std::vector<int> list;
    for(int i = 0; i < num; i++){
    int value;
    std::cin >> value;
    list.push_back(value);
    }

    int swapNumber=0;
    for (int j=0; j < list.size(); j++) {
        for (int k=list.size()-1; k>j; k--) {
            if(list[k]<list[k-1]) {
                std::swap(list[k],list[k-1]);
                swapNumber++;
            }
        }
            
    }

    print_array(list);
    std::cout << swapNumber << std::endl;

    return 0;
}

Measured memory_bytes: 1220
N,M=map(int,input().split())
edge=[set([]) for i in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    edge[a-1].add(b-1)
    edge[b-1].add(a-1)

cedge=[[] for i in range(N)]
for i in range(N):
    for j in range(N):
        if j not in edge[i] and j!=i:
            cedge[i].append(j)

ans=[]
def is_bipartgraph():
    color=[0]*N
    used=[False]*N
    for i in range(N):
        if not used[i]:
            stack=[(i,1)]
            black=0
            white=0
            while stack:
                v,c=stack.pop()
                if not used[v]:
                    color[v]=c
                    black+=(c==1)
                    white+=(c==-1)
                    used[v]=True
                    for nv in cedge[v]:
                        if color[nv]==color[v]:
                            return False
                        elif color[nv]==0:
                            stack.append((nv,-c))
            ans.append([black,white])
    return True

if is_bipartgraph():
    dp=[[False for i in range(0,N+1)] for j in range(len(ans))]
    a,b=ans[0]
    dp[0][a],dp[0][b]=True,True
    for i in range(1,len(ans)):
        a,b=ans[i]
        for j in range(0,N+1):
            test=False
            if j>=a:
                test=test|dp[i-1][j-a]
            if j>=b:
                test=test|dp[i-1][j-b]
            dp[i][j]=test
    ans=0
    for i in range(0,N+1):
        if dp[-1][i] and abs(ans-N/2)>abs(i-N/2):
            ans=i
    ans2=N-ans
    print(ans*(ans-1)//2+ans2*(ans2-1)//2)
else:
    print(-1)

Measured memory_bytes: 82008
def main
  n = gets.chomp.to_i
  n.times do
    mcxi1,mcxi2 = gets.chomp.split(' ').map{ |x| to_integer(x)}
    puts to_mcxi(mcxi1 + mcxi2)
  end
end

def to_integer mcxi
  integer = 0
  num = 1
  mcxi.each_char do |c|
    if c =~ /[2-9]/
      num = c.to_i
      next
    end

    integer += num * get_divisor(c)
    num = 1
  end
  integer
end

def to_mcxi integer
  mcxi = ''
  mcxi << get_mcxi(integer, 1000)
  mcxi << get_mcxi(integer % 1000, 100)
  mcxi << get_mcxi(integer % 100, 10)
  mcxi << get_mcxi(integer % 10, 1)
  mcxi
end

def get_mcxi integer, divisor
  mcxi = ''
  i = integer / divisor
  unless i == 0
    mcxi << i.to_s unless i == 1
    mcxi << get_unit(divisor)
  end
  mcxi
end

def get_unit integer
  case integer
  when 1000; 'm'
  when 100; 'c'
  when 10; 'x'
  when 1; 'i'
  end
end

def get_divisor unit
  case unit
  when 'm'; 1000
  when 'c'; 100
  when 'x'; 10
  when 'i'; 1
  end
end

main

Measured memory_bytes: 6152
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll inf=1000000000000000000,mod=1000000007,BS,k;

int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
        ll a=0,t=0,w=0,r=0;
        ll n;cin>>n;string s;
        for(ll i=0;i<n;i++){
            cin>>s;
            if(s[0]=='A')
            a++;
            if(s[0]=='T')
            t++;
            if(s[0]=='W')
            w++;
            if(s[0]=='R')
            r++;
        }
        cout<<"AC x "<<a<<endl;
        cout<<"WA x "<<w<<endl;
        cout<<"TLE x "<<t<<endl;
        cout<<"RE x "<<r<<endl;


}


Measured memory_bytes: 3644
#include<stdio.h>

int main(){
	int a, b;
	int num;
	int tmp[350] = {-1};
	int ans = 0;
	scanf("%d %d", &a, &b);
	num = b;

	if(b < 10){
		num += a * 10;
	}else if(b < 100){
		num += a * 100;
	}else{
		num += a * 1000;
	}
	for(int i = 1; i < 100000; i++){
		if(i * i > 100000){
			break;
		}
		tmp[i] = i * i;
	}
	for(int i = 0; i < 350; i++){
		if(num == tmp[i]){
			ans = 1;
		}
	}
	printf("%s\n", ans ? "Yes" : "No");
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	ll n;
	cin>>n;
	ll  res = 0;
	for(ll i=1;i*i<=n;i++){
		if( (n-i)%i==0 ) {
			ll tmp = (n-i)/i;
			if(tmp==0)break;
			if(n/tmp == n%tmp)res += tmp;
			//cout<<i<<' '<<(n-i)/i<<endl;
		}
	}
	cout<<res<<endl;
	return 0;
}


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  ll N;
  int M = 5;
  vector<ll> A(M);
  cin >> N;
  REP(i,M) cin >> A[i];

  ll minA = *min_element(ALL(A));
  ll ret = M + (N - 1) / minA;
  cout << ret << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <queue>
#include <memory>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>

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

using namespace std;
using ll = long long;
const int mod = 1e9+7;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> x(m);
    rep(i,m) cin >> x[i];
    sort(x.begin(),x.end(),less<int>() );
    vector<int> dist(m-1);
    
    rep(i,m-1){
        dist[i] = x[i+1] - x[i];
    }
    sort(dist.begin(),dist.end(),less<int>() );
    ll ans = 0;

    rep(i,m-n){
        ans += dist[i];
    }
    cout << ans << endl;

    return 0;
}

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


using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x*x; }

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int n; cin >> n;
	
	map<int, int> m;

	for (int i = 0; i < n; i++) {
		int buf; cin >> buf;

		m[buf]++;
	}

	int ans = 0;
	for (auto &i : m) {
		if (i.second > i.first) {
			ans += i.second - i.first;
		}
		else if(i.second < i.first) {
			ans += i.second;
		}
	}

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

Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define show(x) cout << #x " = " << x << endl;
#define show2(x, y) cout << #x " = " << x << " " << #y << " = " << y << endl;
#define all(x) x.begin(), x.end()
#define INF 0x3f3f3f3f
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> iipair;
typedef pair<unsigned, unsigned> uupair;
typedef vector<int> vec;
typedef vector<unsigned> uvec;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    unsigned n, m;
    cin >> n >> m;
    vec a(n, -1);
    int s, c;
    bool flag = 0;
    for (unsigned i = 0; i < m; ++i)
    {
        cin >> s >> c;
        if (flag)
            continue;
        --s;
        if (a[s] == -1)
        {
            a[s] = c;
        }
        else
        {
            if (a[s] != c)
            {
                flag = 1;
            }
        }
    }
    if (n > 1 && a[0] == 0)
        flag = 1;
    if (flag)
        cout << "-1";
    else
    {
        for (auto &x : a)
        {
            if (x == -1)
                x = 0;
        }
        if (n > 1)
        {
            for (auto &x : a)
            {
                if (x == 0)
                    x = 1;
                break;
            }
        }
        for (auto x : a)
            cout << x;
    }
}

Measured memory_bytes: 256
class UnionFind:
    from typing import List, Set

    def __init__(self, n):
        self.n = n
        self.parent = [-1] * n

    def union(self, x, y) -> int:
        x = self.leader(x)
        y = self.leader(y)

        if x == y:
            return 0

        if self.parent[x] > self.parent[y]:
            x, y = y, x

        self.parent[x] += self.parent[y]
        self.parent[y] = x

        return self.parent[x]

    def same(self, x, y) -> bool:
        return self.leader(x) == self.leader(y)

    def leader(self, x) -> int:
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.leader(self.parent[x])
            return self.parent[x]

    def size(self, x) -> int:
        return -self.parent[self.leader(x)]

    def groups(self) -> List[Set[int]]:
        groups = dict()

        for i in range(self.n):
            p = self.leader(i)
            if not groups.get(p):
                groups[p] = set()
            groups[p].add(i)

        return list(groups.values())

n, m = map(int, input().split())
uf = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())  
    uf.union(a-1, b-1)
print(len(uf.groups()) - 1)

Measured memory_bytes: 35528
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < int(n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i,m,n) for (int i = (n)-1; (i) >= int(m); --(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;
template <typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

struct edge_t { int to, cap, rev; };
int maximum_flow_destructive(int s, int t, vector<vector<edge_t> > & g) { // ford fulkerson, O(EF)
    int n = g.size();
    vector<bool> used(n);
    function<int (int, int)> dfs = [&](int i, int f) {
        if (i == t) return f;
        used[i] = true;
        for (edge_t & e : g[i]) {
            if (used[e.to] or e.cap <= 0) continue;
            int nf = dfs(e.to, min(f, e.cap));
            if (nf > 0) {
                e.cap -= nf;
                g[e.to][e.rev].cap += nf;
                return nf;
            }
        }
        return 0;
    };
    int result = 0;
    while (true) {
        used.clear(); used.resize(n);
        int f = dfs(s, numeric_limits<int>::max());
        if (f == 0) break;
        result += f;
    }
    return result;
}
void add_edge(vector<vector<edge_t> > & g, int from, int to, int cap) {
    g[from].push_back((edge_t) {   to, cap, int(g[  to].size()    ) });
    g[  to].push_back((edge_t) { from,   0, int(g[from].size() - 1) });
}

int main() {
    // input
    int h, w; scanf("%d%d", &h, &w);
    int inf = h*w;
    vector<vector<char> > f = vectors(h, w, char());
    repeat (y,h) repeat (x,w) scanf(" %c", &f[y][x]);
    // maximum flow
    const int src = 0;
    const int dst = 1;
    auto node_y = [&](int y) { return 2 + y; };
    auto node_x = [&](int x) { return 2 + h + x; };
    vector<vector<edge_t> > g(2 + h + w);
    repeat (y,h) repeat (x,w) {
        if (f[y][x] == 'S') {
            add_edge(g, src, node_y(y), inf);
            add_edge(g, src, node_x(x), inf);
        } else if (f[y][x] == 'T') {
            add_edge(g, node_y(y), dst, inf);
            add_edge(g, node_x(x), dst, inf);
        }
        if (f[y][x] != '.') {
            add_edge(g, node_y(y), node_x(x), 1);
            add_edge(g, node_x(x), node_y(y), 1);
        }
    }
    int flow = maximum_flow_destructive(src, dst, g);
    // output
    if (flow >= inf) flow = -1;
    printf("%d\n", flow);
    return 0;
}


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


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

    if(n%2 == 1 ){
        cout << "No" <<endl;
        return 0;
    }else{
        rep(i,n/2){
            if(s[i] != s[i+n/2]){
                cout << "No" <<endl;
                return 0;
            }
        }
    }
    cout << "Yes" <<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

typedef struct{
  char suit;
  int num;
}Card;

void swap(Card *x, Card *y)
{
  Card tmp;
  tmp = *x;
  *x = *y;
  *y = tmp;
}

int bubbleSort(Card *A, int N) // N 個の要素を含む 0-オリジンの配列 A
{
  int count = 0;

  int flag = 1; // 逆の隣接要素が存在する
  while(flag){
    flag = 0;
    int j = N-1;
    while(j >= 1){
      if (A[j].num < A[j-1].num) {
        swap(&A[j], &A[j-1]);
        flag = 1;
        count++;
      }
      j--;
    }
  }
  return count;
}

int selectionSort(Card *A, int N) // N個の要素を含む0-オリジンの配列A
{
  int minj, tmp;
  int count = 0;
  
  for(int i=0; i<N; i++){
    minj = i;
    for(int j=i; j<N; j++){
      if (A[j].num < A[minj].num)
        minj = j;
    }
    if (i != minj) {
      swap(&A[i], &A[minj]);
      count++;
    }
  }

  return count;
}

int main(void)
{
  Card A[36], B[36];
  int N, i;
  
  int count;
  
  scanf("%d",&N);
  for(i=0;i<N;i++) {
    scanf(" %c%d", &A[i].suit, &A[i].num);//配列読み込み
    B[i] = A[i];
  }    

  count = bubbleSort(A, N);

  for (int i = 0; i< N-1; i++)
    printf("%c%d ", A[i].suit, A[i].num);
  printf("%c%d\n", A[N-1].suit, A[N-1].num);
  printf("Stable\n");

  count = selectionSort(B, N);

  for (int i = 0; i< N-1; i++)
    printf("%c%d ", B[i].suit, B[i].num);
  printf("%c%d\n", B[N-1].suit, B[N-1].num);

  int flag = 0;
  for(i=0; i<N; i++){
    if (A[i].suit != B[i].suit) {
      flag = 1;
      break;
    }
  }
  if (flag == 0) {
    printf("Stable\n");
  }else {
    printf("Not stable\n");
  }
  
  return 0;
}

  



Measured memory_bytes: 2040
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <functional>

using namespace std;

typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;
    if (a == 1)
        a += 13;
    if (b == 1)
        b += 13;
    if (a > b)
        cout << "Alice" << endl;
    else if (a < b)
        cout << "Bob" << endl;
    else
        cout << "Draw" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(ll, n, m, k);
    Cins(ll, n, a);
    Cins(ll, m, b);
    
    Cusum(ll, a, as);
    Cusum(ll, b, bs);
    
    int ans = 0;
    For(i, n+1){
        if(as[i] > k) break;
        auto itr = upper_bound(Range(bs), k-as[i]);
        Maxi(ans, i + (int)distance(bs.begin(), itr) - 1);
    }
    Cout(ans);
}


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

int main()
{
	int n, k, q;
	cin >> n >> k >> q;
	vector<int> seikai(n);
	for (int i = 0; i < q; i++) {
		int a_in;
		cin >> a_in;
		seikai.at(a_in - 1) += 1;
	}

	vector<int> point(n);
	for (int i = 0; i < n; i++) {
		point.at(i) = k - q + seikai.at(i);
		if (point.at(i) <= 0) {
			cout << "No" << endl;
		} else {
			cout << "Yes" << endl;
		}
	}
}


Measured memory_bytes: 1408
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>


     
#define INF 1e9
#define LINF 1e19
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define pb push_back
#define sz size()
     
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

     
const ll MOD = 1e9 + 7;
const ll ZER = 0;

//最大公約数
ll gcd(ll a, ll b){
    if(a % b == 0)return b;
    else return gcd(b, a % b);
}

int main(){
    ll w, h, n;
    cin >> w >> h >> n;
    ll mah = h, mih = 0, maw = w, miw = 0;
    rep(i, n){
        ll x, y, a;
        cin >> x >> y >> a;
        if(a == 1)chmax(miw, x);
        if(a == 2)chmin(maw, x);
        if(a == 3)chmax(mih, y);
        if(a == 4)chmin(mah, y);
    }
    if(maw - miw < 0 || mah - mih < 0){
        cout << 0 << endl;
        return 0;
    }
    cout << max(ZER, (maw - miw) * (mah - mih)) << endl;
}





Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <map>

using namespace std;

bool ok(int N, string S, string T)
{
	map<char, char> m1, m2;
	for (int i = 0; i < N; ++i) {
		if (m1.count(S[i]) == 0 && m2.count(T[i]) == 0) {
			m1[S[i]] = T[i];
			m2[T[i]] = S[i];
		}
		else if (m1.count(S[i]) != 0 && m2.count(T[i]) != 0) {
			if (m1[S[i]] != T[i] || m2[T[i]] != S[i]) {
				return false;
			}
		}
		else {
			return false;
		}
	}
	return true;
}

int main()
{
	string S, T;
	cin >> S >> T;
	const int N = S.size();
	if (ok(N, S, T)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


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

int main(void){
    int n,m,x;
    cin >> n >> m >> x;
    int c[n],a[n][m];
    for(int i = 0;i < n;i++){
        cin >> c[i];
        for(int j = 0;j < m;j++){
            cin >> a[i][j];

        }
    }
    
    long long sum = 1e9;
    for(int i = 0;i < (1<<n);i++){
        long long num[20] = {},kane = 0;
        for(int j = 0;j < n;j++){
            if(i & (1 << j)){
                for(int k = 0;k < m;k++)num[k] += a[j][k];
                kane += c[j];
            }
        }
        bool check = true;
        for(int j = 0;j < m;j++){
            if(num[j] < x)check = false;
        }
        if(check == true)sum = min(sum,kane);
    }
    
    if(sum == 1e9)cout << -1 << endl;
    else cout << sum << endl;
}

Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

static class Program
{
    class Solver
    {
        long A;
        long B;
        long C;
        long D;
        Dictionary<long, BigInteger> memo = new Dictionary<long, BigInteger>();
        public Solver(long A, long B, long C, long D)
        {
            this.A = A;
            this.B = B;
            this.C = C;
            this.D = D;
        }
        public BigInteger Solve(long N)
        {
            if (N == 0) { return 0; }
            if (N == 1) { return D; }
            if (!memo.ContainsKey(N))
            {
                var ans = new List<BigInteger> { BigInteger.Multiply(N, D) };
                long i = N % 2;
                long j = N % 3;
                long k = N % 5;
                memo[N] = ans[0];
                if (i == 0)
                {
                    ans.Add(Solve(N / 2) + A);
                }
                else
                {
                    ans.Add(Solve((N - i) / 2) + A + D * i);
                    ans.Add(Solve((N + (2 - i)) / 2) + A + D * (2 - i));
                }
                if (j == 0)
                {
                    ans.Add(Solve(N / 3) + B);
                }
                else
                {
                    ans.Add(Solve((N - j) / 3) + B + D * j);
                    ans.Add(Solve((N + (3 - j)) / 3) + B + D * (3 - j));
                }
                if (k == 0)
                {
                    ans.Add(Solve(N / 5) + C);
                }
                else
                {
                    ans.Add(Solve((N - k) / 5) + C + D * k);
                    ans.Add(Solve((N + (5 - k)) / 5) + C + D * (5 - k));
                }
                memo[N] = ans.Min();
            }
            return memo[N];
        }
    }

    static void Main(string[] args)
    {
        int T = int.Parse(Console.ReadLine());
        for (int i = 0; i < T; ++i)
        {
            var V = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
            Console.WriteLine(new Solver(V[1], V[2], V[3], V[4]).Solve(V[0]));
        }
    }
}


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

typedef pair <int, int> pii;
typedef pair <int, pii> pip;

struct HASH {
	size_t operator() (const pair<int,int> &x) const {
		return hash <long long> () (((long long)x.first) ^ (((long long)x.second) << 32));
	}
};

const int MAX_N = 1e5 + 5;
int n;
vector <pip> G[MAX_N];
unordered_map <pii, int, HASH> Map;

void calc(int v, int u, int type) {
	if (type == 1) {
		G[v][Map[{u, v}]].second.first = 1;
		
		for (int i = 0; i < G[v].size(); i++)
			if (G[v][i].first != u) {
				int k = G[v][i].first;
				int ind = Map[{v, k}];
				if (!G[k][ind].second.second)
					calc(k, v, 2);
				
				if (G[k][ind].second.second == 2) {
					G[v][Map[{u, v}]].second.first = 2;
					break;
				}
			}
		
		return ;
	}
	G[v][Map[{u, v}]].second.second = 2;
	for (int i = 0; i < G[v].size(); i++)
		if (G[v][i].first != u) {
			int k = G[v][i].first;
			int ind = Map[{v, k}];
			if (!G[k][ind].second.first)
				calc(k, v, 1);
			
			if (G[k][ind].second.first == 1) {
				G[v][Map[{u, v}]].second.second = 1;
				break;
			}
		}
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i < n; i++) {
		int v, u;
		cin >> v >> u;
		v--; u--;
		Map[{v, u}] = G[u].size();
		Map[{u, v}] = G[v].size();
		G[v].push_back({u, {0, 0}});
		G[u].push_back({v, {0, 0}});
	}
	
	for (int i = 0; i < n; i++)
		for (int j = 0; j < G[i].size(); j++) {
			if (!G[i][j].second.first)
				calc(i, G[i][j].first, 1);
			
			if (!G[i][j].second.second)
				calc(i, G[i][j].first, 2);
		}
	
	for (int i = 0; i < n; i++) {
		bool can = true;
		for (int j = 0; j < G[i].size(); j++) {
			int v = G[i][j].first;
			int ind = Map[{i, v}];
			
			if (G[v][ind].second.first == 1) {
				can = false;
				break;
			}
		}
		
		if (can) {
			cout << "First\n";
			return 0;
		}
	}
	
	cout << "Second\n";
	return 0;
}

Measured memory_bytes: 18248
import sys
import collections
import bisect


def main():
    n = int(input())
    A, B = [0] * n, [0] * n
    cnt = 0
    for i in range(n):
        [A[i], B[i]] = list(map(int, input().split()))
    for i in range(n):
        k = B[n - i - 1] - (((A[n - i - 1] + cnt) % B[n - i - 1]))
        cnt += 0 if k == B[n - i - 1] else k
    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 17140
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)

	ans := "No"
	if abs(c-a) <= d || (abs(b-a) <= d && abs(c-b) <= d) {
		ans = "Yes"
	}
	fmt.Println(ans)
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
const int INF = 1e18, MOD = 1e9 + 7;
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
signed main() {
    INCANT;
    int a, b, c, res = 0;
    cin>>a>>b>>c;
    rep(i, b, c + 1){
        if(a%i==0) res++;
    }
    cout<<res<<endl;
}



Measured memory_bytes: 3144
n=int(input())
A=[]
B=[]
c=0
for i in range(n):
  S=input()
  a=0
  b=0
  for j in range(len(S)):
    if S[j]=="(":
      a=a+1
    else:
      a=a-1
      if a<b:
        b=a
  b=b*-1
  if b==0:
    c=c+a
  elif a>=0:
    B.append([b,-1*a])
  else:
    A.append([b+a,a])
A.sort()
B.sort()
f=0
for i in range(len(B)):
  if c-B[i][0]<0:
    f=1
  c=c-B[i][1]
d=0
for i in range(len(A)):
  if d-A[i][0]<0:
    f=1
  d=d-A[i][1]
if c!=d:
  f=1
if f==0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 148604
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
  string S;
  cin >> S;

  if (S.at(0)!=S.at(1) && S.at(1)!=S.at(2) && S.at(2)!=S.at(0)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

using ll = long long;
#define rep(n, i) for(ll i = 0; i < n; ++i)

void solve(void){
  string s; cin >> s;
  string str1 = "";
  string str2 = "";

  rep((ll)s.size(), i) {
    if (i % 2 == 0) {
      str1 += '0'; str2 += '1';
    } else {
      str1 += '1'; str2 += '0';
    }
  }

  ll res1 = 0, res2 = 0;
  rep((ll)s.size(), i) {
    if (s[i] != str1[i]) ++res1;
    if (s[i] != str2[i]) ++res2;
  }
  cout << min(res1, res2) << endl;
}

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

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int a[2][10];
    rep(i,2)rep(k,20) cin>>a[i][k];
    sort(a[0],a[0]+10); sort(a[1],a[1]+10);
    cout<<a[0][9]+a[0][8]+a[0][7]<<" "
        <<a[1][9]+a[1][8]+a[1][7]<<endl;
}

Measured memory_bytes: 1176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int[][] board = new int[3][3];

//		String[] line1 = sc.nextLine().split(" ");
//		String[] line2 = sc.nextLine().split(" ");
//		String[] line3 = sc.nextLine().split(" ");
//
		for (int i = 0; i < 3; i++) {
			board[i][0] = sc.nextInt();
			board[i][1] = sc.nextInt();
			board[i][2] = sc.nextInt();
		}

		int N = sc.nextInt();
		for (int i = 0; i < N; i++) {

			int b = sc.nextInt();

			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 3; k++) {
					if(b==board[j][k]) {
						board[j][k] = 0;
					}
				}
			}
		}

		if(board[0][0]==0 &&board[0][1]== 0 && board[0][2]==0) {
			System.out.println("Yes");
			return;
		}
		if(board[1][0]==0 &&board[1][1]== 0 && board[1][2]==0) {
			System.out.println("Yes");
			return;
		}
		if(board[2][0]==0 &&board[2][1]== 0 && board[2][2]==0) {
			System.out.println("Yes");
			return;
		}
		if(board[0][0]==0 &&board[1][0]== 0 && board[2][0]==0) {
			System.out.println("Yes");
			return;
		}
		if(board[0][1]==0 &&board[1][1]== 0 && board[2][1]==0) {
			System.out.println("Yes");
			return;
		}
		if(board[0][2]==0 &&board[1][2]== 0 && board[2][2]==0) {
			System.out.println("Yes");
			return;
		}
		if(board[0][0]==0 &&board[1][1]== 0 && board[2][2]==0) {
			System.out.println("Yes");
			return;
		}
		if(board[0][2]==0 &&board[1][1]== 0 && board[2][0]==0) {
			System.out.println("Yes");
			return;
		}

		System.out.println("No");
	}
}

Measured memory_bytes: 23124
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<string> S(N); vector<int> P(N);
	for(int i = 0; i < N; ++i) {
		cin >> S[i] >> P[i];
	}
	vector<int> perm(N);
	for(int i = 0; i < N; ++i) {
		perm[i] = i;
	}
	sort(perm.begin(), perm.end(), [&](int i, int j) { return S[i] != S[j] ? S[i] < S[j] : P[i] > P[j]; });
	for(int i = 0; i < N; ++i) {
		cout << perm[i] + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <list>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;


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

	int a,b,c;
	cin >> a>>b>>c;
	if (c >= a && c <= b) {
		cout << "Yes" <<endl;
	} else {
		cout << "No" <<endl;
	}

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>

using namespace std;


int main()
{

  int N;
  cin >> N;

  vector<int> B(N);

  for(int i = 0; i < N-1; i++){
    cin >> B[i];
  }

  int sum = B[N-2];
  for(int i = N-3; i >= 0; i--){
    sum += min(B[i], B[i+1]);
  }

  sum += B[0];

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
    int a, b, c, d;
    cin>> a>>b>>c>>d;
    printf("%d\n",max(a*b, c*d));
    return 0;
}

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

#define int long long
#define fi first
#define se second
#define otp(n) cout << n;
#define ct(n) cout << n << endl;
#define cts(n) cout << n << " ";
#define cte cout << endl;
#define ctv(v) rep(i,(v).size()) ct(v[i])
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repo(i,o,n) for(int i=o;i<n;i++)
#define repm(i,n) for(int i=n-1;i>=0;i--)
#define repv(i,v) for(int i=0;i<(v).size();i++)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);


int  n,k,t,d,ans,memo[100001],tmptcnt;
vector<pair<int,int>> v,maxv,firstv;

main() {
    cin >> n >> k;
    rep(i,n) cin >> t >> d,v.pb(make_pair(d,t));
    sort(rall(v));
    rep(i,n) {
        int f=0;
        if (!memo[v[i].se]) f++,memo[v[i].se]++;
        if (i<k) {
            ans+=v[i].fi;
            if(f) tmptcnt++;
            else firstv.pb(make_pair(v[i].fi,v[i].se))
        } else if (f) maxv.pb(make_pair(v[i].fi,v[i].se))
    }
    ans+=tmptcnt*tmptcnt;
    sort(rall(firstv));
    sort(all(maxv));
    int border=(int)min(firstv.size(),maxv.size()),tmpans=ans;
    rep(i,border) {
        tmpans = tmpans-firstv.back().fi+maxv.back().fi-tmptcnt*tmptcnt+(tmptcnt+1)*(tmptcnt+1);
        tmptcnt++;
        firstv.pop_back();
        maxv.pop_back();
        ans = max(ans,tmpans);
    }
    ct(ans)
}

Measured memory_bytes: 4464
N = int(input())
c = [int(input()) for _ in range(5)]

key = min(c)

ans = 0
"""
if N % key == 0:
    ans = N / key
else:
    ans = N // key + 1

print(ans + 4)
"""
anss = 4 + int((N+key-1)/key)
print(anss)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define M 50010

ll n,ans[210];
vll g[M];
bool ok=1;
void dfs(ll u,ll pa=-1){
	for(auto v:g[u]){
		if(ans[v]!=-1){
			if(!(ans[u]^ans[v]))ok=0;
			continue;
		}
		ans[v]=ans[u]^1;
		dfs(v,u);
	}
}
int main(){
	IOS;
	tihs;


	cin>>n;
	rep(i,0,n){
		string s;cin>>s;
		rep(j,0,n)if(s[j]=='1')g[i].pb(j),g[j].pb(i);
		ans[i]=-1;
	}
	ans[0]=0;
	dfs(0);
	if(!ok){
		cout<<"-1";
		return 0;
	}
	ll mx=0;
	queue<ll>q;
	ll d[n];
	rep(i,0,n){
		rep(j,0,n)d[j]=-1;
		q.push(i);d[i]=0;
		while(!q.empty()){
			ll u=q.front();q.pop();
			for(auto v:g[u])if(d[v]==-1)d[v]=d[u]+1,q.push(v);
		}
		rep(j,0,n)mx=max(mx,d[j]);
	}++mx;
	cout<<mx;


	return 0;
}

Measured memory_bytes: 2304
// atcoder/m-solutions2020/E/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);


  int n;
  while (cin >> n) {
    lli x[n], y[n], u[n];
    for (int i = 0; i < n; ++i) {
      cin >> x[i] >> y[i] >> u[i];
    }

    const int N = 16;
    const int BIT = 1 << N;
    const lli inf = 1LL << 60;

    static lli mnx[BIT][N];
    static lli mny[BIT][N];

    for (int bit = 0; bit < (1 << n); ++bit) {
      for (int i = 0; i < n; ++i) {
        if (bit & (1 << i)) mnx[bit][i] = mny[bit][i] = 0;
        else {
          mnx[bit][i] = abs(x[i]);
          mny[bit][i] = abs(y[i]);
        }
      }

      for (int i = 0; i < n; ++i) {
        if (bit & (1 << i)) {
          for (int j = 0; j < n; ++j) {
            unless (bit & (1 << j)) {
              setmin(mnx[bit][j], abs(x[i] - x[j]));
              setmin(mny[bit][j], abs(y[i] - y[j]));
            }
          }
        }
      }
    }

    lli mn[N];
    fill(mn, mn + N, inf);

    for (int bit = 0; bit < (1 << n); ++bit) {
      const int pc = __builtin_popcount(bit);
      for (int a = bit; 0 <= a; --a) {
        a = bit & a;
        int b = bit - a;

        lli sum = 0;
        for (int i = 0; i < n; ++i) {
          sum += min(mnx[a][i], mny[b][i]) * u[i];
        }

        setmin(mn[pc], sum);
      }
    }

    for (int i = 0; i <= n; ++i) {
      cout << mn[i] << endl;
    }
  }

  return 0;
}


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

using namespace std;

int main() {
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    vector<int> xi(n, 0);
    vector<int> yi(m, 0);
    for (int i = 0; i < n; ++i) {
        cin >> xi[i];
    }
    for (int i = 0; i < m; ++i) {
        cin >> yi[i];
    }
    for (int z = x + 1; z <= y; ++z) {
        bool flag = true;
        for(auto e : xi)
        {
            if(e >= z)
            {
                flag = false;
            }
        }
        for(auto e : yi)
        {
            if(e < z)
            {
                flag = false;
            }
        }
        if(flag){
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
    return 0;
}


Measured memory_bytes: 256