akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

int main() {
	int n, m;
	while (cin >> n >> m && (n || m)) {
		VI p(n); rep(i, n)cin >> p[i];
		sort(all(p)); reverse(all(p));

		int ans = 0;
		for (int i = 0; i < n; i += m) {
			for (int j = i; j < min(i + m - 1, n); j++) {
				ans += p[j];
			}
		}
		Cout(ans);
	}
}


Measured memory_bytes: 3088
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <memory.h>
#include <set>
#include <cmath>
#define fio ios::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
ll _pow(ll a, ll b) {
	ll ans = 1;
	for (ll i = 0; b >> i; i++) {
		if ((b >> i) & 1) ans *= a;
		a *= a;
	}
	return ans;
}
int n, a, b;
char arr[100];
int main(void) {
	scanf("%d", &n);
	scanf("%s", arr);
	for (int i = 0; i < n; i++) {
		if (arr[i] == 'R') a++;
		else b++;
	}
	if (a > b) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n;
  char s[10];
  int k;
  int i;

  scanf("%d",&n);
  scanf("%s",s);
  scanf("%d",&k);

  char l;//交換しない文字;
  l=s[(k-1)];

  for(i=0;i<n;i++){

    if(s[i]!=l){
      s[i]='*';
    }

  }

  printf("%s",s);

  return 0;
}


Measured memory_bytes: 128
from bisect import bisect_left, bisect_right

n = int(input())
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
c = [int(i) for i in input().split()]

a = sorted(a)
c = sorted(c)
ans = 0
for i in range(n):
    ans += (bisect_left(a, b[i])) * (n - bisect_right(c, b[i]))
print(ans)


Measured memory_bytes: 23296
#include <bits/stdc++.h>
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  long long n;
  long long W;
  cin>>n>>W;
  vector<vector<long long>> values(4);
  long long w,v;
  long long w1;
  REP(i,n){
    cin>>w>>v;
    if(i==0){
      w1 = w;
      values[0].push_back(v);
    }else{
      values[w-w1].push_back(v);
    }
  }
  long long len[4];
  REP(i,4){
    sort(values[i].begin(),values[i].end(),greater<long long>());
    len[i] = values[i].size();
    REP(j,len[i]){
      if(j==0){
        continue;
      }else{
        values[i][j] += values[i][j-1];
      }
    }
  }
  long long ans=0;
  long long temp=0;
  long long l;
  REP(i,len[0]+1){
    REP(j,len[1]+1){
      REP(k,len[2]+1){
        if(i+j+k>n){
          break;
        }
        if(w1*i + (w1+1)*j + (w1+2)*k > W){
          break;
        }else{
          l = (W - (w1*i + (w1+1)*j + (w1+2)*k))/(w1+3);
          l = min(l,len[3]);
        }
        if(i!=0){
          temp += values[0][i-1];
        }
        if(j!=0){
          temp += values[1][j-1];
        }
        if(k!=0){
          temp += values[2][k-1];
        }
        if(l!=0){
          temp += values[3][l-1];
        }
        ans = max(ans,temp);
        temp = 0;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
arr = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
puts arr[gets.chomp.to_i-1]

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


def main():
    n, w = map(int, input().split())
    wv = [tuple(map(int, input().split())) for _ in range(n)]

    dp = [0] * (w+1)
    for i in range(n):
        for j in range(w, wv[i][0] - 1, -1):
            dp[j] = max(dp[j], dp[j-wv[i][0]] + wv[i][1])
    print(max(dp))


if __name__ == "__main__":
    main()


Measured memory_bytes: 39920
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	for (int i = n - 1; i >= 0; i -= 2) {
		cout << a[i] << " ";
	}
	if (n % 2 == 0) {
		for (int i = 0; i < n; i += 2) {
			cout << a[i] << " ";
		}
	}
	else {
		for (int i = 1; i < n; i += 2) {
			cout << a[i] << " ";
		}
	}
	return 0;
}


Measured memory_bytes: 3712
def count_balls(n, b, a):
	if b == 0:
		return 0
	
	num = n // (a + b)
	mod = n % (a + b)
	if mod != 0:
		if mod < b:
			return num * b + mod
		else:
			return num * b + b
	else:
		return num * b

n, b, a = map(int, input().split())
print(count_balls(n, b, a))

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){	
	ll n, m, ans = 0, i, j;
	cin >> n >> m;
	vector<pii>v(n);
	rep(i,0,n){
		cin >> v[i].ff >> v[i].ss;
	}
	sort(all(v));
	priority_queue<ll>pq;
	j = 0;
	for(i = 1; i <= m; i++){
		while(j < n and v[j].ff <= i){
			pq.push(v[j].ss);
			j++;
		}
		if(!pq.empty()){
			ans += pq.top();
			pq.pop();
		}
	}
	cout << ans << nl;
}

int main() {
#ifndef ONLINE_JUDGE
//    freopen("input1.txt","r",stdin);
//    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
	// cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


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

int main() {
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    for (int i = 1; i <= (int)S.length(); ++i) {
        if (i == K) {
            S[i - 1] = S[i - 1] - 'A' + 'a';
            break;
        }
    }
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
def BFS(K, edges, N):
    roots = [[] for i in range(N)]
    for a, b, c in edges:
        roots[a - 1] += [(b - 1, c)]
        roots[b - 1] += [(a - 1, c)]
    dist = [-1] * N
    stack = []
    stack.append(K)
    dist[K] = 0
    while stack:
        label = stack.pop(-1)
        for i, c in roots[label]:
            if dist[i] == -1:
                dist[i] = dist[label] + c
                stack += [i]
    return dist


N = int(input())
edges = []
for i in range(N - 1):
    edges += [list(map(int, input().split()))]
Q, K = map(int, input().split())
xy = [list(map(int, input().split())) for i in range(Q)]
distance = BFS(K-1, edges, N)
for i in range(Q):
    print(distance[xy[i][0] - 1] + distance[xy[i][1] - 1])

Measured memory_bytes: 86008
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

ll dp[10010];

int main(){
  ll h,n;
  cin>>h>>n;
  vector<ll> va,vb;
  rep(i,0,n){
    ll a,b;
    cin>>a>>b;
    va.pb(a);
    vb.pb(b);
  }
  rep(i,0,10010)dp[i] = 1000000000000000000LL;
  dp[h] = 0;
  per(i,0,h+1){
    rep(j,0,va.sz){
      dp[max(0LL,i-va[j])] = min(dp[max(0LL,i-va[j])],dp[i]+vb[j]);
    }
  }
  cout << dp[0] << endl;
  return 0;
}

Measured memory_bytes: 384
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = [0]+list(map(int, input().split()))

# 区間[i, j)の質量の合計はAcum[j-1] - Acum[i]
Acum = A[::]
for i in range(N):
    Acum[i + 1] += Acum[i]


cost = [[-1] * (N + 1) for _ in range(N + 1)]
for i in range(N):
    cost[i][i + 1] = 0


def slime(i, j):
    if cost[i][j] != -1:
        return cost[i][j]

    res = 10 ** 18
    mass = Acum[j] - Acum[i]
    for x in range(i + 1, j):
        res = min(res, mass + slime(i, x) + slime(x, j))
    cost[i][j] = res
    return res


ans = slime(0, N)
print(ans)


Measured memory_bytes: 44396
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, K, H[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> K;
	rep(i, 0, N) cin >> H[i];

	sort(H, H + N);
	ll ans = 0;
	rep(i, 0, N - K) ans += H[i];
	cout << ans << endl;
}







Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
#include <cmath>
#include <map>
#include <queue>
using namespace std;

const int N = 4;
const int N2 = 16;

static const int dx[4] = { 0, -1, 0, 1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'r', 'u', 'l', 'd' };
int MDT[N2][N2];

struct Puzzle {
	int f[N2], space, MD;
	int cost;

	bool operator < (const Puzzle &p) const {
		for (int i = 0; i < N2; ++i) {
			if (f[i] == p.f[i])
				continue;
			return f[i] < p.f[i];
		}

		return false;
	}

};

struct State {
	Puzzle puzzle;
	int estimated;
	bool operator < (const State &s) const {
		return estimated > s.estimated;
	}

};

int getAllMD(Puzzle pz) {
	int sum = 0;
	for (int i = 0; i < N2; ++i) {
		if (pz.f[i] == N2)
			continue;
		sum += MDT[i][pz.f[i] - 1];
	}

	return sum;

}

int aster(Puzzle s) {
	priority_queue<State> PQ;
	s.MD = getAllMD(s);
	s.cost = 0;
	map<Puzzle, bool> V;
	Puzzle u, v;
	State initial;
	initial.puzzle = s;
	initial.estimated = getAllMD(s);
	PQ.push(initial);

	while (!PQ.empty()) {

		State st = PQ.top();
		PQ.pop();

		u = st.puzzle;

		if (u.MD == 0)
			return u.cost;
		V[u] = true;

		int sx = u.space / N;
		int sy = u.space % N;

		for (int r = 0; r < 4; ++r) {
			int tx = sx + dx[r];
			int ty = sy + dy[r];

			if (tx < 0 || ty < 0 || tx >= N || ty >= N)
				continue;

			v = u;
			v.MD -= MDT[tx * N + ty][v.f[tx * N + ty] - 1];

			v.MD += MDT[sx * N + sy][v.f[tx * N + ty] - 1];

			swap(v.f[sx * N + sy], v.f[tx * N + ty]);
			v.space = tx * N + ty;
			if (!V[v]) {
				v.cost++;
				State news;
				news.puzzle = v;
				news.estimated = v.cost + v.MD;
				PQ.push(news);
			}
		}
	}

	return -1;

}

int main() {

	for (int i = 0; i < N2; ++i)
		for (int j = 0; j < N2; ++j)
			MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);

	Puzzle in;

	for (int i = 0; i < N2; ++i) {
		cin >> in.f[i];
		if (in.f[i] == 0) {
			in.f[i] = N2;
			in.space = i;
		}
	}

	cout << aster(in) << endl;

	return 0;
}


Measured memory_bytes: 257696
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	int n,m;
	int K;
	cin>>n>>m>>K;
	bool ok = false;
	// if(K==0) ok = true;
	rep(i,n+1){
		rep(j,m+1){
			if(n-2*i<0) continue;
			int tmp = i*m + j*(n-2*i);
			// cout<<i<<" "<<j<<" "<<tmp<<endl;
			if(tmp == K) ok = true;
		}
	}
	cout<<(ok?"Yes":"No")<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

		// 整数の入力
		int count = sc.nextInt();

		// 文字列の入力
        String str = sc.next();
        String str2 = sc.next();
        for (int i = 0; i < count; i++) {
            System.out.print(str.charAt(i));
            System.out.print(str2.charAt(i));
        }
	}
}

Measured memory_bytes: 22612
N, K = map(int, input().split())
mod = 998244353
move = []

for _ in range(K):
  L, R = map(int, input().split())
  move.append((L, R))

dp = [0]*(2*N+1)
dp[0] = 1

for i in range(N):
  for l, r in move:
    dp[i+l] += dp[i]
    dp[i+l] %= mod
    dp[i+r+1] -= dp[i]
    dp[i+r+1] %= mod
  if i:
    dp[i+1] += dp[i]
  dp[i] %= mod

print(dp[N-1])

Measured memory_bytes: 24488
N = input()
S_2, S_4 = int(N[:2]), int(N[2:])
if 1 <= S_2 <= 12 and 1 <= S_4 <= 12:
    print("AMBIGUOUS")
elif 1 <= S_2 <= 12 and (S_4 < 1 or S_4 > 12):
    print("MMYY")
elif (S_2 < 1 or S_2 > 12) and 1 <= S_4 <= 12:
    print("YYMM")
else:
    print("NA")

Measured memory_bytes: 3064
void main() {
	auto ip = readAs!(int[]), H1 = ip[0], M1 = ip[1], H2 = ip[2], M2 = ip[3], K = ip[4];
	auto t1 = H1*60 + M1, t2 = H2*60 + M2;
	writeln(t2 - t1 - K);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

long rl() {
	return readAs!long;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

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

#define INF INT_MAX/2
#define MOD 1000000007

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

   int N,M;
   cin>>N>>M;
   vector<pair<int,int> >d(M);
   for(int i=0;i<M;i++)cin>>d[i].second>>d[i].first;
   sort(d.begin(),d.end());

   int a=-1;
   int ans = 0;
   for(int i=0;i<M;i++){
      if(d[i].second < a)continue;
      else {
         a = d[i].first;
         ans++;
      }
   }
   cout<<ans<<endl;
   return 0; 
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>
using namespace std;
char a[105],b[105],c[105];
int main()
{
    int n;
    scanf("%d%s%s",&n,a,b);
    int ans=-1;
    for(int k=n;k>=0;k--)
    {
        int j=0,f=0;
        for(int i=n-k;i<=n-1;i++)
        {
            if(a[i]==b[j]) j++;
            else
            {
                f=1;
                break;
            }
        }
        if(!f) {ans=2*n-k;break;}
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 384
import Data.List      -- sort
import Control.Monad  -- replicateM

isRightTriangle sides = a * a + b * b == c * c
        where [a,b,c] = sort sides

main  = do { n <- readLn ; replicateM n main' }
main' = do s <- getLine
           printYN . isRightTriangle . map read . words $ s

printYN y = putStrLn $ if y then "YES" else "NO"

Measured memory_bytes: 4172
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

#include <bits/stdc++.h>
using namespace std; 

int main() {

  int n;
  cin>>n;
  
  map<string,int> m;
  rep(i,n){
    string s,t;
    cin>>s>>t;
    if(s[0]=='i') m[t]=1;
    else{
      if(m[t]==1) cout<<"yes"<<endl;
      else cout<<"no"<<endl;
    }
  }
  
  return 0;
}


Measured memory_bytes: 52508
# D

n = int(input())

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

import collections

c = collections.Counter(prime_factorize(n))

ans = 0

for i in c.items():
  num = i[1]
  temp = 1
  while True:
    num -= temp
    if num < 0:
      break
    ans += 1
    temp += 1

print(ans)  


Measured memory_bytes: 9464
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ll long long 
#define int long long
#define ull unsigned long long 
#define mod 1000000
#define vi vector<ll>
#define pb push_back
#define mp make_pair
#define str string
#define sp(x,y) fixed<<setprecision(y)<<x
#define mk(arr,n,type) type *arr=new type[n];
#define w(x) ll x; cin>>x; while(x--)
#define endl '\n'
void kehsihba() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
#define all(v) v.begin(), v.end()
int32_t main(){
	//kehsihba();
	ll n;
	cin>>n;
	ll arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	ll dp[n]={0};
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
	}
	cout<<dp[n-1];
}

Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    int n; cin >> n;

    ll a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }

    int ans = 0;
    for(int i=0; i<n; i++){
        while(a[i] % 2 == 0){
            a[i] /= 2;
            ans++;
        }
    }

    cout << ans;


    return 0;
}

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

int main() {
	// your code goes here
	int a,b,c,d;
	cin >>a>>b>>c>>d;
	if(a>b){
		d=a;
		a=b;
		b=d;
	} if (b>c){
		d=b;
		b=c;
		c=d;
	} if (a>b){
		d=a;
		a=b;
		b=d;
	}
	cout<<a<<" "<<b<<" "<<c<<endl;
	
		
	return 0;
}

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

// 最大公約数を求める関数
int gcd(int x, int y)
{
    int r;

    if(x == 0 || y == 0)  // 引数チェック
    {
        //fprintf(stderr, "引数エラーです。\n");
        return 0;
    }

    // ユーグリッドの互除法
    while((r = x % y) != 0)  // yで割り切れるまでループ
    {
        x = y;
        y = r;
    }
    return y;
}

int main() {
  int N;
  cin>>N;
  
  int X;
  cin>>X;
  
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  
  if(N==1){
    cout<<abs(vec.at(0)-X)<<endl;
    return 0;
  }
  
  /*vector<int> vec1(N);
  for(int i=0;i<N;i++){
    if(vec.at(i)-X<0){
      vec1.at(i)=X-vec.at(i);
    }
    else{
      vec1.at(i)=vec.at(i)-X;
    }
  }*/
  
  //int x=gcd(2,4);
  //cout<<x<<endl;
  //cout<<vec1.at(1)<<endl;
  
  
  
  int x=gcd(abs(vec.at(0)-X),abs(vec.at(1)-X));
  if(N==2){
    cout<<x<<endl;
    return 0;
  }
  int y;
  int z=x;
  
  for(int i=1;i<N-1;i++){
    y=gcd(z,abs(vec.at(i+1)-X));
    // y=min(x,gcd(abs(vec.at(i)-X),abs(vec.at(i+1)-X)));
    z=y;
  }
     cout<<z<<endl;
}






Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;

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

int main(){
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        mp[s]++;
    }

    ll ans = 0;
    for(auto& p : mp){
        int s = p.second;
        ans += (ll)s * (s-1) / 2;
    }   
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11136
#include <cstdio>
#include <cstring>

int n;
char s[10004];

int main(){
    scanf("%d\n%s", &n, s);
    int len = strlen(s);
    for(int i = 0; i < len; i++) s[i] = ((s[i] - 'A') + n) % 26 + 'A';
    printf("%s", s);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(auto i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = ~(1<<31);
#define fs first
#define sc second
#define pb push_back

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T> T smod(T a, T b) {
    return (a % b + b) % b;
}


vi T[3];
int memo[100'050][4];

int n;
int dp(int at, int last1) {
    if(at >= n) return 0;
    if(memo[at][last1] != -1) return memo[at][last1];
    int ans = 0;
    rep(i,0,3) {
        if(i == last1) continue;
        ans = max(ans, dp(at+1,i)+T[i][at]);
    }
    return memo[at][last1] = ans;

}


int main() {
    cin.sync_with_stdio(false);
    memset(memo,-1,sizeof(memo));
    cin >> n;
    rep(i,0,n) {
        rep(j,0,3) {
            int x;
            cin >> x;
            T[j].pb(x);
        }
    }
    cout << dp(0,3) << endl;

    return 0;
}


Measured memory_bytes: 11116
package main
import "fmt"
func main() {
	var n int
	var s string
  var m,tmp_min,leftwest,righteast int
  fmt.Scan(&n)
  fmt.Scan(&s)
  leftwest,righteast = 0,0
  for i:=0;i<n;i++ {
		// リーダーより右でEのひとは向きを変えないといけない
		// 計算量を節約するため、一度ここでEのひとを数えておく
    if s[i:i+1] == "E" { righteast++ }
  }
  m = n+1
  for i:=0;i<n;i++ {
		// s[i:i+1] はリーダー自身だから、righteastをマイナスしておく
		if s[i:i+1] == "E" { righteast-- }
    tmp_min = leftwest+righteast
		if m > tmp_min { m = tmp_min } // 最小値が更新されたらmを入れ替える
		// リーダーの位置がWだったら次は入れ替わるはず このようにすることで計算量を減らせる
    if s[i:i+1] == "W" { leftwest++ }
  }
  fmt.Println(m)
}

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

using namespace std;

int main() {

	long long h, w;
	cin >> h >> w;

	long long ans = 1000000000000;
	long long h1, h2, h3;
	long long w1, w2, w3;
	long long s1, s2, s3;

	if (h == 2 && w == 2) {
		cout << 1 << endl;
		return 0;
	}

	//pattern1
	if (h != 2) {
		h1 = h / 3;
		h2 = (h - h1) / 2;
		h3 = h - h1 - h2;

		s1 = w * h1;
		s2 = w * h2;
		s3 = w * h3;

		ans = min(ans, max(s1, max(s2, s3)) - min(s1, min(s2, s3)));

		//pattern2

		for (long long i = 1; i <= h - 1; i++) {
			h1 = i;
			h2 = i;
			h3 = h - i;
			w1 = w / 2;
			w2 = w - w1;
			w3 = w;
			s1 = h1 * w1;
			s2 = h2 * w2;
			s3 = h3 * w3;
			ans = min(ans, max(s1, max(s2, s3)) - min(s1, min(s2, s3)));
		}
	}

	if (w != 2) {
		long tmp;
		tmp = h;
		h = w;
		w = tmp;

		//pattern1
		h1 = h / 3;
		h2 = (h - h1) / 2;
		h3 = h - h1 - h2;

		s1 = w * h1;
		s2 = w * h2;
		s3 = w * h3;

		ans = min(ans, max(s1, max(s2, s3)) - min(s1, min(s2, s3)));

		//pattern2

		for (long i = 1; i <= h - 1; i++) {
			h1 = i;
			h2 = i;
			h3 = h - i;
			w1 = w / 2;
			w2 = w - w1;
			w3 = w;
			s1 = h1 * w1;
			s2 = h2 * w2;
			s3 = h3 * w3;
			ans = min(ans, max(s1, max(s2, s3)) - min(s1, min(s2, s3)));
		}
	}




	cout << ans << endl;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var p = new Program();
        var N = int.Parse(Console.ReadLine());
        var input = p.ConvertIntArray(p.ReadInput());
        double result = 0.0;
        for(var i = 0; i < N; i++)
        {
            result += 1.0 / input[i];
        }
        Console.WriteLine(1 / result);
    }


    public string[] ReadInput()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] ConvertIntArray(string[] x)
    {
        var convertedArray = new int[x.Length];
        for (var i = 0; i < x.Length; i++)
        {
            convertedArray[i] = int.Parse(x[i]);
        }

        return convertedArray;
    }

}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=620;
const int mod=1e9+7;

int n,k;
int to[maxn];
int g[maxn];
int s[maxn];

inline void init()
{
	n=read();k=read();
	REP(i,1,k)
	{
		int a=read(),b=read();
		to[a]=b; to[b]=a;
	}
	REP(i,1,2*n)s[i]=s[i-1]+(!to[i]);
	g[0]=1; REP(i,2,2*n)g[i]=(ll)g[i-2]*(i-1)%mod;
}

int f[maxn][maxn];
int ans;

inline void doing()
{
	REP(i,1,2*n-1)
	{
		int l=i,r=i+1;
		if((!to[i] && !to[i+1]) || (to[i]==i+1))f[i][i+1]=1;
		ans=(ans+(ll)f[l][r]*g[s[2*n]-(s[r]-s[l-1])])%mod;
	}
	REP(len,3,2*n)
	{
		REP(l,1,2*n-len+1)
		{
			int r=l+len-1;
			if(s[r]-s[l-1]&1)continue;
			int flg=0;
			REP(j,l,r)if(to[j] && (to[j]<l || to[j]>r)){flg=1; break;}
			if(flg)continue;
			
			int num=g[(s[r]-s[l-1])];
			REP(k,l+1,r-1)num=(num-(ll)f[l][k]*g[s[r]-s[k]])%mod;
			f[l][r]=(num+mod)%mod;
			ans=(ans+(ll)f[l][r]*g[s[2*n]-(s[r]-s[l-1])])%mod;
		}
	}
	printf("%d\n",ans);
}

int main()
{
	init();
	doing();
	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define lf double
#define gc getchar()
#define mp make_pair
#define ri register int
#define rc register char
#define rb register bool
#define lowbit(x) (x&(-x))
#define rp(i,x,y) for(ri i=x;i<=y;++i)
#define my(i,x,y) for(ri i=x;i>=y;--i)

const int N=1e5+10;
int n;
pair<int,int>P[N];

il int read()
{
    rc ch=gc;ri x=0;rb y=1;
    while(ch!='-' && (ch>'9' || ch<'0'))ch=gc;
    if(ch=='-')ch=gc,y=0;
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc;
    return y?x:-x;
}

int main()
{
	//freopen("C.in","r",stdin);freopen("C.out","w",stdout);
	n=read();rp(i,1,n)P[i]=mp(read(),i);sort(P+1,P+1+n);rp(i,1,n)printf("%d ",P[i].second);
    return 0;
}


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

void solve(long long N, vector<long long> A){
	sort(A.begin(), A.end());
  // for (long long i = 0; i < A.size(); i++ ) { cout << A[i] << " "; } cout << endl;
  long long ans = A.size();
  long long lp = A.size() - 1;
  for (long long i = 0; i < lp; i++) {
    if (A[i] == A[i+1]) {
      // cout << A[i] << " equal and ";
      ans -= 2;
      for (long long j = lp; lp >= i + 1; j--) {
        if (A[j] == A[j-1]) {
          // cout << A[j] << " equal" << endl;
          lp = j - 1;
          break;
        }
      }
    }
  }
  cout << ans << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, A);
	return 0;
}



Measured memory_bytes: 1920
import jdk.nashorn.internal.ir.LabelNode;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int f = sc.nextInt();

		double rate = 0.0;
		int[] ws = new int[]{1, 0};

		for (int i = 0; i <= 3000; i++) {
			for (int j = 0; j <= 3000; j++) {
				int water = ((a * i) + (b * j)) * 100;
				if (water == 0 || water > f) break;
				int cap = ((a * i) + (b * j)) * e;
				for (int k = 0; k <= 3000; k++) {
					for (int l = 0; l <= 3000; l++) {
						int sugar = k * c + l * d;
						if (sugar > cap || water + sugar > f) break;
						if (rate <= 100.0 * sugar / (water + sugar)) {
							rate = 100.0 * sugar / (water + sugar);
							ws[0] = water;
							ws[1] = sugar;
						}
					}
				}
			}
		}

		System.out.println(ws[0] + ws[1] + " " + ws[1]);
	}
}


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

int main(void){
	map<string,int> m;
	int q;
	int x,y;
	string s;
	cin>>q;
	while(q--){
		cin>>x>>s;
		if(x==0){
			cin>>x;
			m[s]=x;
		}else if(x==1){
			cout<<(m.find(s)!=m.end()?m[s]:0)<<endl;
		}else if(x==2){
			m.erase(s);
		}
	}
}



Measured memory_bytes: 27728
#include<stdio.h>
#include<algorithm>
using namespace std;
int n;
int p[505];
bool cmp(int x,int y)
{
    return x<y;
}
main()
{
    int i,ans;
    scanf("%d",&n);
    for(i=0;i<2*n;i++) scanf("%d",&p[i]);
    sort(&p[0],&p[2*n],cmp);
    ans = 0;
    for(i=0;i<2*n;i+=2) ans += p[i];
    printf("%d",ans);
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
n = gets.chomp.to_i

a = Array.new(n)

str = gets.chomp
a = str.split.map(&:to_i)

flag = 1
count = 0

while flag == 1 do
  flag = 0
  (n-1).downto(1) do |i|
    if a[i] < a[i-1] then
      change = a[i]
      a[i] = a[i-1]
      a[i-1] = change
      flag = 1
      count += 1
    end
  end
end
for i in 0..n-1 do
  print a[i]
  print " " if i != n-1
end

print "\n", count, "\n"

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

int main(){

  long long int a[1000000] = {0};

  a[0] = 1;
  a[1] = 1;
  for(int i=2;i*i<=1000000;i++){
    if(a[i] == 0){
      for(int j=i+i;j<=1000000;j+=i) a[j] = 1;
    }
  }

  int n;

  while(cin >> n, n){
    int ans = 0,t = 0,s = 0;

    while(t < n){
      if(a[s] == 0){
	ans += s;
	t++;
      }
      s++;
    }
    cout << ans << endl;
  }
}

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

int main(){
    uint_fast32_t N, K;
    scanf("%lu%lu", &N, &K);
    
    vector<uint_fast32_t> ans(K + 1), a(N);
    for(auto& i : a)scanf("%lu", &i);
    
    for(auto i = 0; i <= K; ++i)
        for(auto j = 0; j < N && a[j] <= i; ++j)
            if(ans[i - a[j]] == 0)ans[i] = 1;
    
    puts(ans[K] ? "First" : "Second");
    
    return 0;
}

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

using namespace std;

int n, a[(int)2e5];

int ls[(int)2e5], rs[(int)2e5];

int main(){
	cin >> n;
	for(int i = 0; i < n; ++i) cin >> a[i];
	int l_max = 0, r_max = 0;
	for(int i = 0; i < n; ++i){
		int l = i, r = n-i-1;
		l_max = max(l_max, a[l]), r_max = max(r_max, a[r]);
		ls[l] = l_max, rs[r] = r_max;
	}
	
	for(int i = 0; i < n; ++i){
		if(i == 0){
			cout << rs[i+1] << endl;
		}else if(i == n - 1){
			cout << ls[i-1] << endl;
		}else{
			cout << max(ls[i-1], rs[i+1]) << endl;
		}
	}
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

  int main(){
     lint n,a,b,c,d,e;
     cin>>n>>a>>b>>c>>d>>e;
     lint x=min({a,b,c,d,e});
     lint ans=(n+x-1)/x;
     ans+=4;
     cout<<ans<<endl;

  }
      

Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n,a[100001]={0},b,ans=0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> b;
    if(b>100000) {
      ans++;
    }
    else {
      a[b]++;
    }
  }
  for(int i=1; i<=100000; i++) {
    if(a[i]>i) {
      ans+=a[i]-i;
    }
    if(a[i]<i) {
      ans+=a[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> vp;
    ll cnt = 0, res = 0;
    REP(i, n){
        ll a, b;
        cin >> a >>b;
        vp.pb({a, b});
    }
    sort(ALL(vp));
    ll i = 0;
    while(cnt < m){
        res += vp[i].fi;
        vp[i].se--;
        if(vp[i].se == 0) i++;
        cnt++;
    }
    cout << res << endl;
}

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

Measured memory_bytes: 2420
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main() {
	int cnt,n, p, a[50] = {};
	while (cin >> n >> p&&n&&p) {
		fill(a, a + 50, 0);
		cnt = p;
		for (int i = 0;; i++) {
			if (a[i%n] == p) {
				cout << i%n << endl;
				break;
			}
			if (cnt == 0) {
				swap(cnt, a[i%n]);
				continue;
			}
			a[i%n]++;
			cnt--;
		}
	}
	return 0;
}

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

int main(){
  int n; cin>>n;
  vector<ll> mp(10000010,0);
  for(int i=1; i<=10000000; i++){
    for(int j=1; j*i<=10000000; j++){
      mp[i*j]++;
    }
  }
  ll ans=0;
  for(int i=1; i<=n; i++){
    ans+=i*mp[i];
  }
  cout<<ans<<endl;
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

const ll dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const ll dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

inline bool inside(ll y, ll x, ll H, ll W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

ll dp[2][105];
ll G[2][105];


signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  rep(i,2) rep(j,n) cin>>G[i][j];
  
  queue<pll> q;
  q.emplace(0,0);
  dp[0][0]=G[0][0];
  while(!q.empty()){
    ll y=q.front().first;
    ll x=q.front().second;
    q.pop();
    rep(i,2){
      ll ny=dy[i]+y, nx=dx[i]+x;
      if(inside(ny,nx,2,n)){
        chmax(dp[ny][nx], dp[y][x]+G[ny][nx]);
        q.emplace(ny,nx);
      }
    }
  }
  cout<<dp[1][n-1]<<endl;
}

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

int main(){
    std::vector<int> color;
    int buf;
    for(int i = 0; i < 3; ++i){
        std::cin >> buf;
        color.push_back(buf);
    }

    std::sort(color.begin(), color.end());
    color.erase(std::unique(color.begin(), color.end()), color.end());

    std::cout << color.size() << std::endl;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> sn(n, 1);
    for(int i = 0; i < k; i++){
        int d;
        cin >> d;
        for(int j = 0; j < d; j++){
            int a;
            cin >> a, a--;
            sn[a] = 0;
        }
    }
    cout << accumulate(begin(sn), end(sn), 0) << endl;
    return 0;
}


Measured memory_bytes: 3644
import sys
N = int(input())
A = [int(x) for x in input().split()]

def solve(N, A):
    S = 0
    C = [A[0]]
    for i in range(1,N):
        if A[i] == C[-1]:
            continue
        C.append(A[i])
    A = C
    if len(C) == 1:
        print(1000)
        return
    C = [(A[0], '-' if A[0] <A[1] else '+')]

    for i in range(1,len(A)-1):
        if C[-1] ==  A[i]:
            continue
        if A[i-1] > A[i] <= A[i+1]:
            C.append((A[i], "-"))
        elif A[i-1] < A[i] >= A[i+1]:
            C.append((A[i], "+"))
    if C[-1][0] != A[-1]:
        C.append((A[-1], '+' if A[-1] > C[-1][0] else '-'))

    S = 0
    m = 1000
    if C and C[0][1] == '+':
        C = C[1:]
    if C and C[-1][1] == '-':
        C = C[:-1]
    #print(C,file=sys.stderr) 

    for p, s in C:
        m_ = m
        S_ = S
        if s == '+':
            m += p * S 
            S = 0
        else:
            # buy stock
            m -= (m_ // p) * p
            S = (m_ // p)
        #print(s, p, "money(%d -> %d)"%(m_, m), "stock(%d -> %d)"% (S_, S))
    print(m)

solve(N, A)




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

#define NMAX 15

using namespace std;

int N, M, X;
int c[NMAX];
int a[NMAX][NMAX];

bool used[NMAX];
int sol[NMAX];
int cost_min = 999999999;

void backt(int n)
{   
	int  count = pow(2,n);
	for (int i = 0; i < count; i++) {
        vector <int> sol;
        int crt_cost = 0;
        int skill[NMAX] = { 0 };
		for (int j = 0; j < n; j++) {
			if ((i & (1 << j)) > 0)
                sol.push_back(j);
		}
        for (int j = 0; j < sol.size(); ++j) {
            // cout << sol[j] << " ";
            crt_cost += c[sol[j]];
            for (int k = 0; k < M; ++k) {
                skill[k] += a[sol[j]][k];
            }
        }
        bool ok = true;
        for (int k = 0; k < M; ++k) {
            if (skill[k] < X) {
                ok = false;
                break;
            }
        }

        if (ok && crt_cost < cost_min) {
            cost_min = crt_cost;
        }
	}
}

int main() {
    cin >> N >> M >> X;
    for (int i = 0; i < N; ++i) {
        cin >> c[i];
        for (int j = 0; j < M; ++j) {
            cin >> a[i][j];
        }
    }

    backt(N);

    if (cost_min != 999999999) {
        cout << cost_min << '\n';
    } else {
        cout << "-1\n";
    }

    return 0;
}

Measured memory_bytes: 4104
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <complex>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, a, b;
	cin >> N >> a >> b;
	if((b-a-1)%2){
		cout << "Alice" << endl;
	}else{
		cout << "Borys" << endl;
	}
}


Measured memory_bytes: 892
import std.stdio, std.conv, std.string, std.algorithm, std.math, std.array, std.container;

int a, b;

int solve() {
  int amin=-1, amax, bmin=-1, bmax;
  for(int i=1; i<=1500; i++) {
    int a_ = floor(i*0.08).to!int;
    int b_ = floor(i*0.1).to!int;
    if(a_ == a) {
      if(amin == -1) amin = i;
      amax = i;
    }
    if(b_ == b) {
      if(bmin == -1) bmin = i;
      bmax = i;
    }
  }
  if(amin == -1 || bmin == -1) return -1;
  if(amax < bmin || amin > bmax) return -1;
  return max(amin, bmin);
}

void main() {
  readf("%d %d", &a, &b);
  writeln(solve());
}



Measured memory_bytes: 256