akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
using VVVLL = vector<VVLL>;
const ll MOD = 1000000007;

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

    int N; cin >> N;
    vector<VVVLL> dp(N+1, VVVLL(5, VVLL(5, VLL(5))));
    dp[0][0][0][0] = 1;
    for (int n = 0; n < N; n++) {
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 5; j++) {
                for (int k = 0; k < 5; k++) {
                    for (int l = 1; l < 5; l++) {
                        if (l == 2)
                            if (j == 1 && k == 3) continue;
                        if (l == 3) {
                            if (i == 1 && j == 2) continue;
                            if (i == 1 && k == 2) continue;
                            if (j == 1 && k == 2) continue;
                            if (j == 2 && k == 1) continue;
                        }
                        dp[n+1][j][k][l] += dp[n][i][j][k];
                        if (dp[n+1][j][k][l] >= MOD)
                            dp[n+1][j][k][l] -= MOD;
                    }
                }
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i < 5; i++) {
        for (int j = 0; j < 5; j++) {
            for (int k = 0; k < 5; k++) {
                ans += dp[N][i][j][k];
                if (ans >= MOD)
                    ans -= MOD;
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int a[100005];
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int x=0;
	for(int i=0;i<n;i++){
		if(i%2==0){
			x+=a[i];
		}
		else{
			x-=a[i];
		}
	}
	cout<<x<<" ";
	for(int i=0;i<n-1;i++){
		cout<<2*(a[i]-x/2)<<" ";
		x=2*(a[i]-x/2);
	}
}

Measured memory_bytes: 1664
N = int(input())
ans = 1
*a, = map(int, input().split())
mod = 10**9+7

l = [[0,0,0] for _ in range(N+1)]
r, g, b = 0, 0, 0

for i, j in enumerate(a):
    if i:
        if j==0:
            if g==0:
                g += 1
            else:
                b += 1
        else:
            if r==j:
                r += 1
            elif g==j:
                g += 1
            elif b==j:
                b += 1
    else:
        r += 1
     
    l[i+1][0] = r
    l[i+1][1] = g
    l[i+1][2] = b

ans = 1
for i,j in zip(a, l):
    ans *= j.count(i)
    ans %= mod

print(ans)

Measured memory_bytes: 20772
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;

int main(){
    int n, m; scanf("%d %d", &n, &m);
    vector<int> cost(m);
    vector<vector<int> > key(m);
    for(int i = 0; i < m; i++){
        int num; scanf("%d %d", &cost[i], &num);
        for(int j = 0; j < num; j++){
            int x; scanf("%d", &x);
            key[i].push_back(x - 1);
        }
    }
    vector<int> dp(1 << n, INF);
    dp[0] = 0;
    for(int bit = 0; bit < (1 << n); bit++){
        for(int i = 0; i < m; i++){
            int num = bit;
            for(int j = 0; j < key[i].size(); j++) num = num | (1 << key[i][j]);
            dp[num] = min(dp[num], dp[bit] + cost[i]);
        }
    }
    int ans = dp[(1 << n) - 1];
    if(ans == INF) ans = -1;
    printf("%d\n", ans);
}

Measured memory_bytes: 3904
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int a, b;
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		if (a < b)
			System.out.println("a < b");
		else if (a == b)
			System.out.println("a == b");
		else
			System.out.println("a > b");
	}
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> A(0);
  for(int i = 0; i < N; i++){
    int K;
    cin >> K;
    vector<int> AK(K);
    for(int j = 0; j < K; j++){
      cin >> AK.at(j);
    }
    A.push_back(AK);
  }
  int cnt = 0, frag, dekafrag, K;
  for(int i = 1; i <= M; i++){
    int dekafrag = 0;
    for(int j = 0; j < N; j++){
      int frag = 0;
      K = A.at(j).size();
      for(int t = 0; t < K; t++){
        if(A.at(j).at(t) == i) frag = 1;
      }
      if(frag == 0) dekafrag = 1;
    }
    if(dekafrag == 0){
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 2010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
string S, T;
int A[MAX_N], B[MAX_N];
int C[MAX_N], M[MAX_N];

void solve() {
	cin >> S >> T;
	N = sz(S);
	fill(A, A + N, inf);
	rep(i, 0, N) {
		rep(j, 0, N) {
			if(T[(i + j) % N] == '1') {
				A[i] = min(A[i], j);
				B[i] = max(B[i], j);
			}
		}
	}
	//debug(vi(A, A + N), vi(B, B + N));
	if(A[0] == inf) {
		bool ok = true;
		rep(i, 0, N) if(S[i] == '1') ok = false;
		if(ok) cout << 0 << "\n";
		else cout << -1 << "\n";
		return;
	}
	int res = inf;
	rep(i, 0, N) {
		int tmp = 0;
		fill(C, C + N, inf);
		rep(j, 0, N) {
			if(T[(i + j) % N] != S[j]) {
				tmp++;
				if(S[j] == '1') MIN(C[A[j]], B[j]);
			}
		}
		fill(M, M + N + 1, inf);
		int mi = -1, mx;
		rer(j, N, 0) {
			M[j] = min(M[j + 1], C[j]);
			if(C[j] != inf) MAX(mi, j);
		}
		mx = M[0];
		if(mx == inf) MIN(res, tmp + min(i, N - i));
		else {
			MIN(res, tmp + mi + min(abs(mi - i), N - abs(mi - i))); 
			MIN(res, tmp + N - mx + min(abs(mx - i), N - abs(mx - i))); 
		}
		rep(j, 0, N) {
			if(C[j] != inf) {
				mi = j; mx = M[j + 1];
				if(mx == inf) continue;
				MIN(res, tmp + mi + N - (mx - mi) + min(abs(mx - i), N - abs(mx - i)));
				MIN(res, tmp + N - mx + N - (mx - mi) + min(abs(mi - i), N - abs(mi - i)));
			}
		}
	}
	cout << res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int main(){
  ll n,k;
  cin>>n>>k;
  ll ans=1;
  for(int i=0;i<n;i++)
    ans=(ans*k)%mod;
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3112
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef pair< int, int > Pi;
const int INF = 1 << 30;
struct edge: vector< Pi > {
  void add_edge(int to, int cost){
    push_back(Pi(to,cost));
  }
} info[100000];
int hoge[100000];
 
void bfs(const int& st, const int& V){
  fill_n( hoge, V, INF);
  queue< int > que;
  que.push(st);
  hoge[st] = 0;
  while(!que.empty()){
    int p = que.front();
    que.pop();
    for(int i = 0 ; i < info[p].size() ; i++){
      int cost = info[p][i].second;
      int to = info[p][i].first;
      if( cost + hoge[p] < hoge[to]){
        que.push(to);
        hoge[to] = cost + hoge[p];
      }
    }
  }
}
 
int main(){
  int N;
  scanf("%d", &N);
  for(int i = 0; i < N; i++){
    int u, k;
    scanf("%d %d", &u, &k);
    u--;
    while(k--){
      int v;
      scanf("%d", &v);
      info[u].add_edge( v - 1, 1);
    }
  }
  bfs(0, N);
  for(int i = 0 ; i < N ; i++ ){
    printf("%d %d\n", i + 1, hoge[i]==INF?-1:hoge[i]);
  }
}

Measured memory_bytes: 3384
#include <iostream>
using namespace std;
 
int main()
{
    int x,y,s,temp;
    while(cin >> x >> y >> s,x || y || s){
        temp = 0;
        for(int i = 1;i <= s;i++){
            for(int j = 1;j < i;j++){
                if(j*(100+x)/100+(i-j)*(100+x)/100 == s){
                    if(j*(100+y)/100+(i-j)*(100+y)/100 > temp)
                    temp = j*(100+y)/100+(i-j)*(100+y)/100;
                }
            }
        }
        cout << temp << endl;
    }
    return 0;
}

Measured memory_bytes: 3096
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys;input = sys.stdin.readline
inp,ip = lambda :int(input()),lambda :[int(w) for w in input().split()]

n,d = ip()
ct = 0
for i in range(n):
    a,b = ip()
    if a*a + b*b <= d*d:
        ct += 1
print(ct)
    


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

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " : " << p.second << "}";
	return os;
}

template<typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/

int main()
{
	int N;
	cin >> N;
	vi a(N, 0);
	cin >> a;
	sortall(a);
	cout << a[N - 1] - a[0] << endl;
	
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 200005;
int l[N], r[N], d[N], x[N];
vector<int> g[N];
bool vis[N];

bool dfs(int v, ll val){
	if(vis[v]){
		if(x[v] != val)return false;
		return true;
	}
	vis[v] = true;
	x[v] = val;
	for(auto ind : g[v]){
		int u = l[ind]^r[ind]^v;
		if(u == r[ind] && !dfs(u, val + d[ind]))return false;
		if(u == l[ind] && !dfs(u, val - d[ind]))return false;
	}
	return true;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n, m;
	cin>>n>>m;
	for(int i = 0; i < m; i++){
		cin>>l[i]>>r[i]>>d[i];
		g[l[i]].push_back(i);
		g[r[i]].push_back(i);
	}
	memset(vis, false, sizeof(vis));
	for(int i = 1; i <= n; i++){
		if(!vis[i] && !dfs(i, 0)){
			cout<<"No\n";
			exit(0);
		}
	}
	cout<<"Yes\n";


	return 0;
}

Measured memory_bytes: 16256
import java.util.*;

class Main{
    public Main(){
        Scanner SC = new Scanner(System.in);
        long X = Long.parseLong(SC.next());

        ArrayList<Long> factor = new ArrayList<Long>();

        for(long i=1;i*i<=X;i++){
            if(X % i == 0){
                factor.add(i);
                factor.add(X/i);
            }
        }

        long A, B = 0;
        while(true){
            for(long f : factor){
                A = f + B;
                if(A*A*A*A*A-B*B*B*B*B == X){
                    System.out.println(A + " " + B);
                    return;
                }
                A = f - B;
                if(A*A*A*A*A+B*B*B*B*B == X){
                    System.out.println(A + " " + -1*B);
                    return;
                }
            }
            B++;
        }
    }

    public static void main(String args[]){
        Main main = new Main();
    }
}


Measured memory_bytes: 38844
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))
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;}

// debug
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif

int main() {
  int in(N); int in(K);

  vi m(N, 0);
  rep(i, K) {
    int in(d);
    rep(j, d) {
      int in(A); --A;
      ++m[A];
    }
  }
  int ans = 0;
  rep(i, N)
    if (m[i] == 0)
      ++ans;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
 
using namespace std;
 
const int N = 1000 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n;
int p[N];
vector<int> vec[N];

bool read() {
    if (!(cin >> n))
        return false;

    for (int i = 0; i < n; ++i) {
        vec[i].resize(n - 1);

        for (auto& j : vec[i])
            cin >> j, --j;
    }

    return true;
}

void solve() {
    set< pair<int, int> > st;
    auto ans = 0;

    for (int i = 0; i < n; ++i) {
        auto j = vec[i][p[i]];

        if (p[j] < n - 1 && vec[j][p[j]] == i)
            st.insert(make_pair(min(i, j), max(i, j)));
    }

    for (; !st.empty(); ) {
        ++ans;
        set<int> kekos;

        for (; !st.empty(); ) {
            ++p[st.begin()->first];
            ++p[st.begin()->second];
            kekos.insert(st.begin()->first);
            kekos.insert(st.begin()->second);
            st.erase(st.begin());
        }

        for (const auto& i : kekos) {
            if (p[i] >= n - 1)
                continue;

            auto j = vec[i][p[i]];

            if (p[j] < n - 1 && vec[j][p[j]] == i)
                st.insert(make_pair(min(i, j), max(i, j)));
        }
    }

    if (*min_element(p, p + n) < n - 1)
        cout << -1 << endl;
    else
        cout << ans << endl;
}
 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();
 
    return 0;
}



Measured memory_bytes: 28800
#include<bits/stdc++.h>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<iostream>
#define N 100000

using namespace std;

int main()
{

        string str;cin>>str;
        int i,j,n,l=0,r=0,q=0;
        for(i=0;i<str.size();i++)
        {
            if(str[i]==43) l++;
            else if(str[i]==45) r++;

        }
        cout<<l-r<<endl;


    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<algorithm>
#include<deque>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 80100;
char cn[cm], * ci = cn, ct;
inline int getint() {
	int A = 0;
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}
inline int getint2() {
	int pn = 1;
	if ((ct = *ci++) == '-') { pn = -1; ct = *ci++; }
	int A = ct - '0';
	while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return pn * A;
}

ll dat[10200];
bool yatta[5000];
int P[5000], C[5000];

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


	fread(cn, 1, cm, stdin);

	int N = getint(), K = getint();
	rep(i, N) P[i] = getint() - 1;
	rep(i, N) C[i] = getint2();

	ll kotae = -2e18;
	rep(i, N) if (!yatta[i]) {
		int L = 0;
		auto kari = dat;
		kari[0] = 0;
		int j = i;
		while (!yatta[j]) {
			yatta[j] = 1;
			kari[L + 1] = kari[L] + C[j];
			L++;
			j = P[j];
		}
		ll hue = kari[L];
		for (int j = L + 1; j <= L + L; j++) {
			kari[j] = kari[j - L] + hue;
		}
		ll amari = K % L;
		ll wari = K / L;
		if (hue > 0) {
			if (amari > 0) {
				deque<int> dq;
				rep1(i, L + amari - 1) {
					while (dq.size() && kari[dq.back()] <= kari[i]) dq.pop_back();
					dq.push_back(i);
					if (i < amari) continue;
					while (dq.size() && dq.front() <= i - amari) dq.pop_front();
					chmax(kotae, hue * wari + kari[dq.front()] - kari[i - amari]);
				}
			}			
			if (wari > 0) {
				deque<int> dq;
				rep1(i, L + L - amari - 1) {
					while (dq.size() && kari[dq.back()] <= kari[i + amari]) dq.pop_back();
					dq.push_back(i + amari);
					if (i < L - amari) continue;
					while (dq.size() && dq.front() <= i + amari - L) dq.pop_front();
					chmax(kotae, hue * (wari - 1) + kari[dq.front()] - kari[i + amari - L]);
				}
			}
		}
		else {
			deque<int> dq;
			int are = min(K, L);
			rep1(i, L + are - 1) {
				while (dq.size() && kari[dq.back()] <= kari[i]) dq.pop_back();
				dq.push_back(i);
				if (i < are) continue;
				while (dq.size() && dq.front() <= i - are) dq.pop_front();
				chmax(kotae, kari[dq.front()] - kari[i - are]);
			}
		}
	}

	printf("%lld\n", kotae);


	Would you please return 0;
}

Measured memory_bytes: 3300
import math
k=int(input())
if(k%2)==0:
    print("-1")
else:
    flag=0
    for x in range(1,1000001):
        if (7%(9*k)*(pow(10,x,k*9)-1)%(9*k))==0:
            print(x)
            flag=1
            break
    if flag==0:
        print(-1)


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


int main(int argc, const char * argv[]) {
    
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin >> N;
    int i, temp;
    vector<int> mochi;
    for(i=0;i<N;i++){
        cin >> temp;
        mochi.push_back(temp);
    }
    
    sort(mochi.begin(),mochi.end());
    
    int min = 0;
    int counter=0;
    for(i=0;i<N;i++){
        if(mochi[i]>min){
            min = mochi[i];
            counter++;
        }
    }

    cout << counter << endl;
    
    return 0;
}


Measured memory_bytes: 892
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*(pow(x,(m-1)//2)**2)%p)%p
p = 10**9+7
N = int(input())
A = list(map(int,input().split()))
a = sum(A)
b = 0
for i in range(N):
    b = (b+A[i]**2)%p
ans = (a*a)%p-b
ans = (pow(2,p-2)*ans)%p
print(ans)

Measured memory_bytes: 105384
import java.util.*

fun main(args: Array<String>) {
    Scanner(System.`in`).use {
        val m = mutableMapOf(7 to 1, 5 to 2)
        var r = "YES"
        for (i in 1..3) {
            val x = it.nextInt()
            val c = m[x]
            if (c != null && c > 0) {
                m[x] = c - 1
            } else {
                r = "NO"
                break
            }
        }
        println(r)
    }
}


Measured memory_bytes: 31388
# import numpy as np
# S,T = input().split()
N,K = list(map(int,input().split()))
# N = int(input())
ps = list(map(int,input().split()))
Es = []
for p in ps:
    Es.append((1+p)/2)
beg = 0
end = K
ans = sum(Es[beg:end])
prev = ans

while end < N:
    prev = prev - Es[beg] + Es[end]

    if prev > ans:
        ans = prev
    beg += 1
    end += 1

print(ans)


Measured memory_bytes: 24804
from math import factorial
# 組み合わせ
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

def main():
    num, k = map(int, input().split())

    if num == 2:
        max_num = 10
    else:
        max_num = combinations_count(num - 1, 2)
    # max_num = combinations_count(num - 1, 2)

    if k > max_num or num == 2:
        if num == 2 and k == 0:
            print(1)
            print(1, 2)
        else:
            print('-1')
    else:
        edge = num - 1
        now_count = max_num
        data = [[num, i] for i in range(1, num)]
        for i in range(1, num):
            for j in range(i + 1, num):
                if now_count > k:
                    edge += 1
                    now_count -= 1
                    data.append([i, j])
                else:
                    pass

        print(edge)
        for i, j in data:
            print(i, j)

if __name__ == '__main__':
    main()



Measured memory_bytes: 43504
#include <cstdio>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
    int n, l, i;
    long double t = 0, v = 0;
    deque <pair<long double, long double> > d;
    
    scanf("%d %d", &n, &l);
    
    for (i = 0; i < n; i++) {
        double tx, vx;
        
        scanf("%lf %lf", &tx, &vx);
        
        if (l == vx) {
            d.clear();
            t = 0;
            v = 0;
        }
        
        while (v + vx > l && d.size() > 0) {
            long double t1 = d.front().first;
            long double v1 = d.front().second;
            long double v2 = min(v1, v + vx - l);
            
            t = (t * v - t1 * v2) / (v - v2);
            v = v - v2;
            
            if (v1 == v2) {
                d.pop_front();
            } else {
                d.front().second -= v2;
                break;
            }
        }
        
        t = (t * v + tx * vx) / (v + vx);
        v = v + vx;
        
        printf("%.12lf\n", (double)t);
        
        while (d.size() > 0) {
            long double t1 = d.back().first;
            long double v1 = d.back().second;
            
            if (t1 < tx) break;
            
            tx = (tx * vx + t1 * v1) / (vx + v1);
            vx = vx + v1;
            
            d.pop_back();
        }
        
        d.push_back(make_pair(tx, vx));
    }
    
    return 0;
}


Measured memory_bytes: 27828
#include <stdio.h>
int main()
{
    int a, b, c, ab, ac, bc;
    scanf("%d %d %d", &a, &b, &c);
    ab = a+b;
    ac = a+c;
    bc = b+c;
    if(ab<ac && ab<bc)
    {
       printf("%d", ab);
    }
    else if(ac<ab && ac<bc)
    {
        printf("%d", ac);
    }
    else
    {
      printf("%d", bc);
    }
    return 0;
}

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

typedef pair<int, int> P;

int main() {

    int n,m;
    cin >> n >> m;
    vector<P> p(m);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        p[i] = P(a,b);
    }

    vector<int> v(n);
    rep(i,n){
        v[i] = i;
    }

    int ans = 0;
    do{
        bool ok = true;
        rep(i,n-1){
            P tmp1 = P(v[i],v[i+1]);
            P tmp2 = P(v[i+1],v[i]);
            if(find(p.begin(), p.end(), tmp1)==p.end() && find(p.begin(), p.end(), tmp2) ==p.end()){
                ok = false;
                break;
            }
        }
        if(ok){
            ans++;
        }
    }while(next_permutation(v.begin()+1,v.end()));

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
import math
def solve():
    n=int(input())
    x=list(map(int,input().split()))
    
    ave=0
    sum=0
    for i in range(len(x)):
        sum+=x[i]
    ave=sum/len(x)
    if ave>math.floor(ave)+0.5:
        pre=math.ceil(ave)
    else:
        pre=math.floor(ave)
    ans=0
    for i in range(len(x)):
        ans+=(x[i]-pre)**2
    print(ans)
    
solve()

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a,b) printf(a,b);
#define c(s) cout<< (s) << endl;
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define YES cout<<"YES"<<endl;
#define NO cout<<"NO"<<endl;
#define cyn(c) cout<<(c?"Yes":"No")<<endl;
#define cYN(c) cout<<(c?"YES":"NO")<<endl;
#define pyn(o,c) printf(o,c?"Yes":"No");
#define pYN(o,c) printf(o,c?"YES":"NO");
typedef long long LL;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
   int a,b; cin>>a>>b;
   p("%s",a+b==15?"+":a*b==15?"*":"x");
}


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

int main() {
    int n, d;
    set<int> st;

    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> d;
        st.insert(d);
    }

    cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n, k, q;
int a;
int cnt[100000];

signed main() {
	int i;
	
	cin >> n >> k >> q;
	rep(i, q) {
		cin >> a;
		a--;
		cnt[a]++;
	}
	
	rep(i, n) {
		if (k - q + cnt[i] > 0) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1408
import java.util.*;
public class Main {
   public static void main(String args[]){
      //declaration and initialization
      Scanner sc = new Scanner(System.in);
      int n = Integer.parseInt(sc.nextLine());
      int x;
      
      for(int i = 1; i <= n; i++){
         x = i;
         if(x % 3 == 0){
            System.out.print(" " + i);
            continue;
         }
         
         while(x > 0){
            if(x % 10 == 3){
               System.out.print(" " + i);
               break;
            }else{
               x /= 10;
            }
         }
      }
      
      System.out.println();
      
         
   }//main
      
}//class


Measured memory_bytes: 28700
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ

int main(){
	int a;scanf("%d",&a);
	long long N=0;
	long long M=0;
	for(int i=0;i<a;i++){
		long long x,y;scanf("%lld%lld",&x,&y);
		N+=y;
		M+=x*y;
	}
	long long ret=N-1;
	ret+=(M-1)/9;
	printf("%lld\n",ret);
}


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


void input(); template<typename First,typename... Rest> void input(First&,Rest&...);
void inputVector(); template<typename First,typename... Rest>  void inputVector(std::vector<First>&,Rest&...);
#define loop(n) for(int i = 0;i < (int)(n);++i)
#define rep(i,n) for(int i = 0;i < (int)(n);++i)


void calculate(){

}

int main(int,char**){
    std::string str;
    input(str);
    str[3] = '8';
    std::cout << str << '\n';
}



void input(){return;}
template<typename First,typename... Rest>
void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}

void inputVector(){return;}
template<typename First,typename... Rest> 
void inputVector(std::vector<First> &first,Rest&... rest){
    int N = first.size();
    for(int i = 0;i < N;i++){
        std::cin >> first[i];
    }
    inputVector(rest...);
}

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

namespace _061_RankChecker
{
	class Program
	{
		static void Main ( string[] args )
		{
			//??´???????????¨?????°??????????????????
			List<Pair> pointList = new List<Pair> (100);

			string inputStr;

			while ((inputStr = Console.ReadLine ()) != "0,0")
			{
				int[] split = inputStr.Split (',').Select (int.Parse).ToArray ();
				Pair p = new Pair (split[0], split[1]);
				pointList.Add (p);
			}

			//????????????????????????
			pointList.Sort (( item, item2 ) => item2.Point - item.Point);

			//???????????????????????????????????????????????\??????
			//index = number, value = rank
			int[] rankArray = new int[pointList.Count + 1];	//???????????¨??´????????????????????????

			int rank = 1;
			int previousPoint = pointList[0].Point;

			rankArray[pointList[0].Number] = rank;

			for (int lp = 1; lp < pointList.Count; lp++)
			{
				int currentPoint = pointList[lp].Point;

				if (currentPoint != previousPoint)
				{
					rank++;
				}
				previousPoint = currentPoint;

				rankArray[pointList[lp].Number] = rank;
			}

			//???????????\??§????????????
			string inputStr2;

			while ((inputStr2 = Console.ReadLine ()) != null)
			{
				int number = int.Parse (inputStr2);
				int result = rankArray[number];
				Console.WriteLine (result);
			}
		}
	}

	//?????°
	class Pair
	{
		public Pair ( int number, int point )
		{
			this.Number = number;
			this.Point = point;
		}

		public int Number { private set; get; }
		public int Point { private set; get; }
	}
}

Measured memory_bytes: 9524
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  //文字列切り出し + 数値変換
  int intA, intB;
  intA = atoi(S.substr(0, 2).c_str());
  intB = atoi(S.substr(2, 2).c_str());
  
  //条件により判定
  string result = "";
  
  if(intA > 12){
    if(intB > 12){
      result = "NA";
    }
    else{
      result = "YYMM";
    }
  }
  else{
    if(intB > 12){
      result = "MMYY";
    }
    else{
      result = "AMBIGUOUS";
    }
  }
  
  //0処理
  if(intA == 0){
    if(intB != 0 && intB < 13){
      result = "YYMM";
    }
    else{
      result = "NA";
    }
  }
  if(intB == 0){
    if(intA != 0 && intA < 13){
      result = "MMYY";
    }
    else{
      result = "NA";
    }
  }
  
  cout << result << endl;
}

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

using namespace std;
using ll = long long;

#pragma region Macros
#define FOR(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define rep(i, n) FOR(i, 0, n)

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

template <class T> string join(const T &v, const string delim = ",")
{
    if (v.empty())
        return "";

    ostringstream res;
    res << v[0];
    for (int i = 1; i < v.size(); i++)
    {
        res << delim << v[i];
    }
    return res.str();
}

#pragma endregion Macros

int main()
{
    int A , B;
    cin >> A >> B;
    string ans = "No";
    for (int c = 1; c <= 3; c++) {
        if((A*B*c)%2==1){
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;
}


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


int main() {
  int n; cin >> n;
  string s; cin >> s;
  long long max; max=0;
  long long sum; sum=0;
  
  for(int i=0; i < n; i++){
    if(s.at(i) == 'I'){
      sum++;
    }
    else{
      sum--;
    }
    
    if(sum > max){
      max = sum;
    }
  }
  
  cout << max << endl;
}

Measured memory_bytes: 256
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.Arrays;
import java.util.Comparator;

public class Main {
    public static void main(String[] args) throws IOException {
        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            String s = reader.readLine();
            String t = reader.readLine();

            Character[] sc = toCharacterArray(s);

            Character[] tc = toCharacterArray(t);

            // s 昇順
            Arrays.sort(sc);

            // t 降順
            Arrays.sort(tc, Comparator.reverseOrder());

            s = "";
            for (Character c : sc) s += c.toString();

            t = "";
            for (Character c : tc) t += c.toString();

            System.out.println(s.compareTo(t) < 0 ? "Yes" : "No");
        }
    }

    static Character[] toCharacterArray( String s ) {
        if ( s == null ) {
            return null;
        }

        int len = s.length();
        Character[] array = new Character[len];
        for (int i = 0; i < len ; i++) {
            array[i] = new Character(s.charAt(i));
        }

        return array;
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef vector<int> vi;
const int inf = 1e9+7;
const int INF = 1e18+7;
//26

int a[10000], dp[4][10000];
signed main(){
	int n, ans = inf;
	scanf("%lld", &n);
	rep(i,4)rep(j,10000)dp[i][j] = inf;
	rep(i,n)scanf("%lld", &a[i]);
	rep(i,4){
		if(i > a[0])break;
		dp[i][0] = a[0]-i;
	}
	repi(i,1,n){
		rep(j,4){
			if(j > a[i])break;
			rep(k,4){
				int mx = max(k, a[i]-j);
				chmin(dp[j][i], dp[k][i-1]+2*mx);
			}
		}
	}
	
	/*rep(i,4){
		rep(j,n)printf("%lld ", dp[i][j] == inf ? -1 : dp[i][j]);
		printf("\n");
	}*/
	rep(i,4)chmin(ans, dp[i][n-1]+i);
	printf("%lld\n", ans);
	return 0;
}





Measured memory_bytes: 3572
def solve(n, k, A):
    d = {}
    for a in A:
        d[a] = d.get(a, 0) + 1
    return sum(sorted(d.values())[:len(d) - k])

_n, _k = map(int, input().split())
_A = map(int, input().split())
print(solve(_n, _k, _A))

Measured memory_bytes: 41376
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper

a, b, c = inl()
print('YES' if b-a == c-b else 'NO')


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

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

    ll N, M;
    cin >> N >> M;
    // greatest divisor of M smaller than or equal to M/N
    ll ans = 0;
    for (ll i = 1; i * i <= M; i++) {
        if (M % i == 0) {
            if (i * N <= M) ans = max(ans, i);
            if ((M / i) * N <= M) ans = max(ans, M / i);
        }
    }
    cout << ans << endl;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)turn idx;
#define deg_to_rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad_to_deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)

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

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

int main() {
  int X;
  cin >> X;
  int items = X / 100;
  int remainder = X % 100;
  if ((items * 5) >= remainder) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
};


Measured memory_bytes: 256
import heapq
n,m = map(int,input().split())
al = [[] for i in range(10**5)]
ans = 0
h = []
for i in range(n):
    a,b = map(int,input().split())
    al[a-1] += [-b]
for i in range(m):
    for j in al[i]:
        heapq.heappush(h,j)
    if h:
        ans -= heapq.heappop(h)
print(ans)

Measured memory_bytes: 22080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    int k,s,count=0;
    cin >> k >> s;
    for (int i = 0; i <= k; i++)
    {
        for (int j = 0; j <= k; j++)
        {
            int z = s - i - j;
            if (0 <= z && z <= k)
            {
                count++;
            }
        }
    }
    cout <<count<<endl;
}


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

struct process {
	string name;
	int time;
};

int main() {
	int n,time,limit,stamp=0;
	process temp;
	string proc;
	queue<process> todo,finish;
	cin >> n >> limit;
	for(int i=0; i<n; ++i) {
		cin >> proc >> time;
		temp.name = proc;
		temp.time = time;
		todo.push(temp);
	}
	while(!(todo.empty())) {
		temp=todo.front();
		todo.pop();
		if(temp.time>limit) {
			stamp+=limit;
			temp.time-=limit;
			todo.push(temp);
		} else {
			stamp+=temp.time;
			temp.time=stamp;
			finish.push(temp);
		}
	}
	for(int i=0; i<n; ++i) {
		temp=finish.front();
		finish.pop();
		cout << temp.name << " " << temp.time << endl;
	}
	return 0;
}

Measured memory_bytes: 6340
#include <stdio.h>

int main()
{
	int monsterHP, attackPower, attacksAmount;
	scanf("%d %d", &monsterHP, &attackPower);

	// Counts how many attacks will take whole HP of the monster
	attacksAmount = monsterHP / attackPower;

	// Checks if attacks where enough to kill monster, if not then adds one more attack
	if (monsterHP % attackPower != 0)
	{
		attacksAmount++;
	}

	printf("%d\n", attacksAmount);

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll k; string s; cin >> k >> s;
    ll n = s.size();
    if(n <= k)cout << s << endl;
    else{
        rep(i,k)cout << s[i];
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3616
#!/usr/bin/env python3
import sys
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(N: int, M: int, A: "List[str]", B: "List[str]"):

    for i in range(N-M+1):
        for j in range(N-M+1):
            flag = True
            for k in range(M):
                for l in range(M):
                    if A[i+k][j+l] != B[k][l]:
                        flag = False
                        break
                if flag == False:
                    break
            if flag == True:
                yes()
                return

    no()
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [next(tokens) for _ in range(N)]  # type: "List[str]"
    B = [next(tokens) for _ in range(M)]  # type: "List[str]"
    solve(N, M, A, B)


if __name__ == '__main__':
    main()


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

using namespace std;
using ll  = long long;
using ii  = pair < int , int >;
using i3  = pair < int , ii >;
using vi  = vector < int >;
using vii = vector < ii >;
using vi3 = vector < i3 >;

const int N = 1010 , mod = 1e9 + 7;
const ll INF = 1e12;
const double eps = 1e-9 , PI = acos(-1);

int n , m;
char G[N][N];
int dp[N][N];

void solve(){
    scanf("%d %d" , &n , &m);
    for(int i = 0 ; i < n ; i ++){
        scanf("%s" , G[i]);
    }

    dp[0][0] = 1;
    for(int i = 0 ; i < n ; i ++){
        for(int j = 0 ; j < m ; j ++){
            if(G[i][j] == '#')continue;
            if(i - 1 >= 0){
                if(G[i-1][j] != '#'){
                    dp[i][j] += dp[i-1][j];
                    dp[i][j] %= mod;
                }
            }
            if(j - 1 >= 0){
                if(G[i][j-1] != '#'){
                    dp[i][j] += dp[i][j-1];
                    dp[i][j] %= mod;
                }
            }
        }
    }

    printf("%d\n" , dp[n-1][m-1]);
}

main(){
    int t = 1;
    //scanf("%d" , &t);

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

    return 0;
}






Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)(j);i <= (int)(k);i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define fix cout<<fixed<<setprecision(20);
const int maxn=(int)1e6+5;
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    long long n;cin>>n;
    if(n%2)cout<<0<<endl;
    else{
        n/=2;
        long long ans=0;
        while(n){
            ans+=n/5;n/=5;
        }
        cout<<ans<<endl;
    }
}
/* 
5   5*3*1
6   6*4*2*1
25 /5=5  5/5=1
 */

Measured memory_bytes: 256
N = int(input())
c = 0
P = [N]

alph = {}
p = 1
for i in range(97, 97+26):
    alph[str(p%26)] = chr(i)
    p += 1

ans = []
k = 0
T = N
while(N > 0):
    if k == 0:
        ans.append(alph[str((N // (26**k))%26)])
    else:
        ans.append(alph[str(((N-1)//(26**k)+1)%26)])
    k += 1
    N -= 26**k
print("".join(ans[::-1]))

Measured memory_bytes: 61972
#include <iostream>
using namespace std;
int main(){
    string a,b,c;
    int x,y;
    cin>>a>>b>>c;
    x=a.size();
    y=b.size();
    if(a[x-1]==b[0]&&b[y-1]==c[0])
    cout<<"YES"<<endl;
    else{
    cout<<"NO"<<endl;

    }
    
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int i,a[7],b[7],c[7];
  for(i=0;i<7;i++){
    cin>>a[i]>>b[i];
    c[i]=a[i]-b[i];
  }
  for(i=0;i<7;i++)
    cout<<c[i]<<endl;
  return 0;
}

Measured memory_bytes: 1160
import copy
s = int(input())
mod = 10**9+7

def com(n,r,m):
    #a = math.factorial(n)%m
    a = 1
    for i in range(1,n+1):
        a *= i
        a %= m
    A = pow(a,m-2,m)
    
    
    b= copy.deepcopy(A)   
    for i in range(n,r,-1):
        b = (b*i)%m
    
    c = copy.deepcopy(A)
    for i in range(n,n-r,-1):
        c = (c*i)%m
       
    return (a*b*c)%m

ans = 0
for i in range(1,s//3+1):
    a = s - 3*i
    ans += com(a+i-1,i-1,mod)
    ans %= mod
print(ans)

Measured memory_bytes: 9348
import sys
from collections import defaultdict, deque
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

n, q = map(int, readline().split())
G = defaultdict(list)
for _ in range(n-1):
    a, b = map(int, readline().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
count = [0] * n
for _ in range(q):
    p, x = map(int, readline().split())
    count[p-1] += x


def dfs(root, x):
    ans[root] = count[root] + x
    for i in G[root]:
        if ans[i] == -1:
            dfs(i, ans[root])


ans = [-1] * n
ans[0] = count[0]
q = deque([0])
while q:
    root = q.pop()
    for i in G[root]:
        if ans[i] == -1:
            q.append(i)
            ans[i] = ans[root] + count[i]

# dfs(0, 0)
print(*ans)


Measured memory_bytes: 79072
#include <iostream>
#include <cstring>

using namespace std;

int n, m;
int G[500][500];

int dp[500];

void solve() {
	memset(dp, 0, sizeof(dp));
	
	dp[0] = 0;
	for (int i = 0; i < m; i++) {
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < n; k++) {
				if (G[j][k] >= 0) {
					dp[k] = max(dp[k], dp[j] + G[j][k]);
				}
			}
		}
	}
	cout << dp[n-1] << endl;
}

int main() {
	cin >> n >> m;
	
	memset(G, -1, sizeof(G));
	for (int i=0; i<m; i++) {
		int a, b, c; cin >> a >> b >> c;
		G[a][b] = c;
	}
	
	solve();
	
	return 0;
}

Measured memory_bytes: 2148