akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t d,n;
    cin >> d >> n;
    if(d==0){
        if(n!=100){
            cout << n << endl;
        }else{
            cout << n+1 << endl;
        }
    }else if(d==1){
        if(n!=100){
            cout << 100*n << endl;
        }else{
            cout << 100*(n+1) << endl;
        }
    }else{
        if(n!=100){
            cout << 10000*n << endl;
        }else{
            cout << 10000*(n+1) << endl;
        }
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  long long int n, k; cin >> n >> k;
  map<long long int, long long int> mp;
  for(int i = 0; i < n; i++){
    int a, b; cin >> a >> b;
    mp[a] += b;
  }
  long long int cnt = 0;
  for(auto itr = mp.begin(); itr != mp.end(); itr++){
    cnt += itr->second;
    if(cnt >= k){
      cout << itr->first << endl;
      return;
    }
  }
  return;
}

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


Measured memory_bytes: 4224
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class C { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		long N = GetLong();
		long M = GetLong();
		long K = GetLong();
		var A = GetLongs(N);
		var B = GetLongs(M);

		var X = new long[N + 1];
		for(long i = 0; i < N; i++)
			X[i + 1] = X[i] + A[i];

		var C = new long[M + 1];
		for(long i = 0; i < M; i++)
			C[i + 1] = C[i] + B[i];

		long ans = 0;
		for(long i = 0; i <= N; i++)
		{
			if(X[i] > K)
				break;

			long rest = K - X[i];
			long ng = M + 1;
			long ok = 0;
			while(Abs(ng - ok) > 1)
			{
				long mid = (ng + ok) / 2;
				if(C[mid] <= rest)
					ok = mid;
				else
					ng = mid;
			}
			chmax(ref ans, i + ok);
		}
		WriteLine(ans);
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 73180
// Copyright 2020 yaito3014
#include <bits/stdc++.h>

int main() {
  using namespace std;
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> A(N);
  for (auto& e : A) cin >> e;
  int s = accumulate(cbegin(A), cend(A), 0, [](int a, int b) { return a ^ b; });
  for (const auto& e : A) cout << (s ^ e) << ' ';
  cout << '\n';
}


Measured memory_bytes: 3984
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).ok();
    let mut it = buf.split_whitespace();
    let a = it.next().unwrap().parse::<i64>().unwrap();
    let b = it.next().unwrap().parse::<i64>().unwrap();
    let x = it.next().unwrap().parse::<i64>().unwrap();
    let f = |s : i64, t : i64| { if s >= 0 { s / t + 1 } else { 0 } };
    println!("{}", f(b, x) - f(a-1, x));
}


Measured memory_bytes: 4352
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
int main(){
    char data;
    string word[10000];
    int n=0,i=0;
    int flg=0;
    while(scanf("%c",&data)!=EOF){
        if(data==10)break;
        if(isalpha(data))word[i]+=data;
        if(data==39)word[i]+=data;
        if(data==' '){
            i++;
        }
    }
    flg=0;
    for(int j=0;j<=i;j++){
        if(word[j].length()>=3&&word[j].length()<=6){
                if(flg==1)cout<<" ";
                cout<<word[j];
                flg=1;
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1276
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int 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(int n, int k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);

  int n,k,x,y; cin >> n >> k >> x >> y;
  if (n<=k){cout << x*n;}
  else {cout << x*k+y*(n-k);}

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (void)
{
	while(true)
	{
		int n, m, p;
		p = 0;
		cin >> n;
		if(n == 0) 
		{
			break;
		}
		cin >> m;
		while(m > 0)
		{
			int s, q;
			cin >> s >>q;
			p += q-s;
			m--;
		}
		if(p >= n)
		{
			cout<<"OK"<<endl;
		}
		else
		{
			cout <<n - p<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
//
// Created by watemus on 05.06.2020.
//

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

using namespace std;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second

using ll = long long;
using ld = long double;

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

template<typename T>
using uset = unordered_set<T>;

template<typename T1, typename T2>
using umap = unordered_map<T1, T2>;

#define int ll

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;
constexpr ld PI = acos(-1);

vector<pair<int, int>> DD = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

#ifdef LOCAL
#else
#endif

void run() {
    int n;
    cin >> n;
    vec<pair<int, int>> a(n);
    for (auto &[x, y] : a) cin >> x >> y;
    sort(all(a));
    if (n % 2) {
        int mx1 = a[n/2].first;
        sort(all(a), [](auto a, auto b){
            return a.second < b.second;
        });
        int mx2 = a[n/2].second;
        cout << mx2 - mx1 + 1 << '\n';
    } else {
        int mx11 = a[n/2-1].first;
        int mx12 = a[n/2].first;
        sort(all(a), [](auto a, auto b){
            return a.second < b.second;
        });
        int mx21 = a[n/2-1].second;
        int mx22 = a[n/2].second;
        cout << mx22 + mx21 - mx11 - mx12 + 1 << '\n';
    }
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

signed main() {
#ifdef LOCAL
    std::freopen("input.txt", "r", stdin);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    cout << fixed << setprecision(20);
    int t = 1;
//    cin >> t;
    while (t--) {
        run();
    }
    return 0;
}



Measured memory_bytes: 6360
n = gets.to_i
s = gets.chomp

n_hash_left = 0
n_dot_right = s.count('.')
min_change = n_hash_left + n_dot_right
0.upto(n-1) do |b|
  if s[b] == '.'
    n_dot_right -= 1
  else
    n_hash_left += 1
  end
  min_change = [min_change, n_hash_left + n_dot_right].min
end

puts min_change


Measured memory_bytes: 2172
/*#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>
#define ll long long
#define inf 1000000005
#define put putchar('\n')
#define F(i,a,b) for (int i=(a);i<=(b);i++)
#define D(i,a,b) for (int i=(a);i>=(b);i--)
#define go(i,t) for (int i=head[t];i;i=Next[i])
#define sqr(x) ((x)*(x))
#define re register
#define mp make_pair
#define fi first
#define se second
#define pa pair<int,int>
#define pb push_back
#define be begin()
#define en end()
#define ret return puts("-1"),0;
#define mod 1000000007
#define N 500055
#define int ll
using namespace std;
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){char c=getchar();int tot=1;while ((c<'0'|| c>'9')&&c!='-') c=getchar();if (c=='-'){tot=-1;c=getchar();}
int sum=0;while (c>='0'&&c<='9'){sum=sum*10+c-'0';c=getchar();}return sum*tot;}
inline void wr(int x){if (x<0) {putchar('-');wr(-x);return;}if(x>=10)wr(x/10);putchar(x%10+'0');}
inline void wrn(int x){wr(x);put;}inline void wri(int x){wr(x);putchar(' ');}
inline void wrn(int x,int y){wri(x);wrn(y);}inline void wrn(int a,int b,int c){wri(a);wrn(b,c);}
int n,m,vis[N],co[N],I,P,Q;
int nedge,Next[N*2],head[N],to[N*2];
#define V to[i]
void add(int a,int b){
	Next[++nedge]=head[a];head[a]=nedge;to[nedge]=b;
}
void add_ne(int a,int b){add(a,b);add(b,a);}
bool dfs(int x){
	vis[x]=1;
	bool num=1;
	go(i,x){
		if (vis[V]) num&=(co[x]!=co[V]);
		else co[V]=co[x]^1,num&=dfs(V);
	}
	return num;
}
signed main(){
	n=read();m=read();
	F(i,1,m){
		add_ne(read(),read());
	}
	F(i,1,n){
		if (!vis[i]){
			if (head[i]==0) I++;
			else if (dfs(i)) Q++;
			else P++;
		}
	}
	wrn(I*I+I*(n-I)*2+P*Q*2+P*P+Q*Q*2);
	return 0;
}

Measured memory_bytes: 20480
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
    auto ABN = readln.split.to!(long[]);
    auto A = ABN[0], B = ABN[1], N = ABN[2];
    auto x = min(B-1, N);
    writeln(cast(long) (floor(cast(double) A * cast(double) x / cast(double) B) - A * cast(double) floor(cast(double) x / cast(double) B)));
}



Measured memory_bytes: 2756
#include <stdio.h>
int main(void){
    int N,M,C,An,To=0;
    scanf("%d%d%d",&N,&M,&C);
    int B[M],A[N][M];
    for(int i=0;i<M;i++)scanf("%d",&B[i]);
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++)scanf("%d",&A[i][j]);
    }
    for(int i=0;i<N;i++){
        An=0;
        for(int j=0;j<M;j++)An+=B[j]*A[i][j];
        if(An+C>0)To++;
    }
    printf("%d\n",To);
    return 0;
}


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

bool ok(string s, string p){
	for(int i=0; i < s.length(); i++){
		bool flag = true;
		for(int j=0; j < p.length(); j++)
			if(s[(i+j)%(s.length())] != p[j])
				flag = false;

		if(flag == true) return true;
	}
	return false;
}


int main(){

	string s; cin >> s;
	string p; cin >> p;

	cout << (ok(s, p)? "Yes": "No") << endl;

	return 0;
}

Measured memory_bytes: 3188
def main():
    L, R = list(map(int, input().split()))
    if (R - L) >= 673:
        print(0)
    else:
        res = float('inf')
        for i in range(L, R):
            for j in range(i+1, R+1):
                res = min(res, (i * j) % 2019)
        print(res)



if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
n,t=map(int,input().split())
x = []
y = []
z=[]
for i in range(n):
    x1,y1=map(int,input().split())
    x.append(x1)
    y.append(y1)
for i in range(n):
    if y[i]<=t:
        z.append(x[i])
if len(z)==0:
    print("TLE")
else:
    print(min(z))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
const int M=1e5+5;
int h[M];
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n,m;
	cin>>n>>m;
	set<int> st;
	for(int i=1;i<=n;i++)
		cin>>h[i];
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		if(h[a]>=h[b])
			st.insert(b);
		if(h[b]>=h[a])
			st.insert(a);
	}
	cout<<n-sz(st)<<"\n";
	return 0;
}

Measured memory_bytes: 6712
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int K;
    string S;
    cin >> K >> S;
    if(S.size() > K){
        rep(i,K){
            cout << S[i];
        }
        cout << "..." << endl;
    }    
    else{
        cout << S << endl;
    }
}

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

constexpr int mod = 1e9+7;

vector<int> g[200005];
map<int, int> match;
int pw2[200005], dp[200005];

deque<pair<int,int>> foo(int c) {
  deque<pair<int,int>> ret;
  if(g[c].empty()) {
    ret.emplace_back(1,1);
    return ret;
  }


  vector<deque<pair<int,int>>> dl;
  for(int i : g[c])
    dl.push_back(foo(i));
  int mi = 0;
  for(int i=1;i<dl.size();i++) {
    if(dl[i].size() > dl[mi].size()) mi = i;
  }
  dl.back().swap(dl[mi]);
  ret = move(dl.back());
  dl.pop_back();
  int m = 0;
  for(auto &l : dl) {
    m = max(m, (int)l.size());
    for(int i=0;i<l.size();i++) {
      long long tot = (0LL + ret[i].first + ret[i].second + dp[i]) % mod;
      tot = tot * (l[i].first + l[i].second) % mod;
      int tz = 1LL * ret[i].first * l[i].first % mod;
      int to = 1LL * ret[i].first * l[i].second % mod;
      to = (to + 1LL * ret[i].second * l[i].first) % mod;
      dp[i] = (tot - tz - to + mod*2) % mod;
      ret[i] = {tz, to};
    }
  }
  for(int i=0;i<m;i++)
    ret[i].first = (ret[i].first + dp[i])%mod;
  memset(dp,0,sizeof(int)*m);
  ret.emplace_front(1,1);
  return ret;
}

int main() {
  int n;
  scanf("%d",&n);
  pw2[0] = 1;
  for(int i=1;i<=n+1;i++)
    pw2[i] = pw2[i-1]*2%mod;
  for(int i=0;i<=n+1;i++)
    match[pw2[i]] = pw2[n+1-i];
  for(int i=1;i<=n;i++) {
    int x;
    scanf("%d",&x);
    g[x].push_back(i);
  }
  deque<pair<int,int>> ret = foo(0);
  int ans = 0;
  for(auto &p : ret) {
    int tot = (p.first + p.second) % mod;
    int tmp = 1LL * p.second * match[tot] % mod;
    ans = (ans + tmp) % mod;
  }
  printf("%d\n",ans);
}


Measured memory_bytes: 192488
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int a, b;
  cin >> a >> b;
  
  int i = (a - 1);
  int j = 1;
  int k = 0;
  
  while(j < b){
    j += i;
    k++;
  }
  cout << k << endl;
}

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

using namespace std;

long long dp[110][1000100]={0};
int main(){
  int N;
  long long W,weight[110],value[110];

  cin>>N>>W;
  for(int i=0;i<N;i++){
    cin>>weight[i]>>value[i];
  }

  for(int i=0;i<N;i++){
    for(int j=0;j<=W;j++){
      if(j-weight[i]>=0){
        dp[i+1][j]=max(dp[i+1][j],dp[i][j-weight[i]]+value[i]);
      }
      dp[i+1][j]=max(dp[i+1][j],dp[i][j]);
    }
  }

  cout<<dp[N][W]<<endl;

  return 0;
}


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

int main()
{
	long long q, h, s, d, n;
	cin >>q >>h >>s >>d >>n;

	long long hp = min(h, 2 * q);
	long long sp = min(s, 2 * hp);
	long long dp = min(d, 2 * sp);

	long long cost = (n / 2) * dp;
	if(n % 2 == 1)
		cost += sp;
	cout <<cost <<"\n";
	return 0;
}


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

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<int>> v(h, vector<int>(w));
  rep (i, h) {
    rep (j, w) {
      char c;
      cin >> c;
      if (c == '#') v[i][j] = 1;
    }
  }
  int ans = 0;
  rep (i, 1<<h) {
    rep (j, 1<<w) {
      int cnt = 0;
      rep(l, h) {
        if ((i>>l)&1) continue;
        rep (m, w) {
          if ((j>>m)&1) continue;
          if (v[l][m]) cnt++;
        }
      }
      if (cnt == k) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main()
{
    lol n; cin >> n;
    //lol k; cin >> k;
    vector<lol> a(n+1, 0);
    FOR(i, 2, n)
    {
        int b;
        cin >> b;
        a[b]++;
    }
    FOR(i, 1, n)
    {
        cout << a[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4796
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int V,E,ans;
ll edge[64];
ll sum_edge[64];
void MDS(int cur,int cost,ll mask){
	if(cost>=ans)return;
	if(mask==(1LL<<V)-1){
		ans=min(ans,cost);
		return;
	}
	if(cur>=V)return;
	//if((mask|sum_edge[cur])!=(1LL<<V)-1)return;
	MDS(cur+1,cost+1,mask|edge[cur]);
	MDS(cur+1,cost,mask);
}
int main(){
	while(cin>>V>>E,V){
		memset(edge,0,sizeof(edge));
		memset(sum_edge,0,sizeof(sum_edge));
		for(int i=0;i<V;i++)edge[i]|=(1LL<<i);
		for(int i=0;i<E;i++){
			int A,B;
			cin>>A>>B;
			edge[A]|=(1LL<<B);
			edge[B]|=(1LL<<A);
		}
		for(int i=V-1;i>=0;i--) sum_edge[i] |= edge[i];
		for(int i=V-2;i>=0;i--) sum_edge[i] |= sum_edge[i+1];
		ans=1e9;
		MDS(0,0,0);
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 3016
#include <iostream>
#define CROSS 101
using namespace std;


int main() {
  int a, b;
  int data[CROSS][CROSS];
  int initFlag = true;
  while(cin >> a >> b) {
    if(initFlag) {
      for(int i = 0; i < CROSS; i++) {
	for(int j = 0; j < CROSS; j++) {
	  data[i][j] = 0;
	}
      }
      initFlag = false;
    }

    if(a == 0 && b == 0) {
      bool ok = true;
      for(int i = 0; i < CROSS; i++) {
	int num = 0;
	for(int j = 0; j < CROSS; j++) {
	  num += data[i][j];
	}
	if(i == 1 || i == 2) {
	  if(num % 2 == 0) {
	    ok = false;
	    break;
	  }
	} else {
	  if(num % 2 != 0) {
	    ok = false;
	    break;
	  }
	}
      }
      if(ok) {
	cout << "OK" << endl;
      } else {
	cout << "NG" << endl;
      }
      initFlag = true;
    } else {
      data[a][b]++;
      data[b][a]++;
    }
  }
}

Measured memory_bytes: 0
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<cstring>
using namespace std;
void fn(vector<int>& a,char s){
  if(0){
  }else if(s=='n'){
    int s=a[0];
    a[0]=a[4];
    a[4]=a[5];
    a[5]=a[1];
    a[1]=s;
  }else if(s=='s'){
    int s=a[0];
    a[0]=a[1];
    a[1]=a[5];
    a[5]=a[4];
    a[4]=s;
  }else if(s=='e'){
    int s=a[0];
    a[0]=a[2];
    a[2]=a[5];
    a[5]=a[3];
    a[3]=s;
  }else if(s=='w'){
    int s=a[0];
    a[0]=a[3];
    a[3]=a[5];
    a[5]=a[2];
    a[2]=s;
  }
  return;
}
int main(){
  int i,j;
  int h,w;
  while(cin>>h>>w,h||w){
    int a[12][12];
    memset(a,-1,sizeof(a));
    for(i=1;i<h+1;i++)
      for(j=1;j<w+1;j++)
	cin>>a[j][i];
    int sx,sy,tx,ty;
    cin>>sy>>sx>>ty>>tx;
    sx++;
    sy++;
    tx++;
    ty++;
    int b[12][12][7][7];
    memset(b,-1,sizeof(b));
    priority_queue<pair<pair<int,vector<int> >,pair<int,int> >,vector<pair<pair<int,vector<int> >,pair<int,int> > >,greater<pair<pair<int,vector<int> >,pair<int,int> > > > c;
    vector<int> d;
    for(i=1;i<7;i++)
      d.push_back(i);
    c.push(make_pair(make_pair(0,d),make_pair(sx,sy)));
    while(c.empty()==0){
      int x,y,z;
      vector<int> d;
      x=c.top().second.first;
      y=c.top().second.second;
      z=c.top().first.first;
      d=c.top().first.second;
      if(x==tx&&y==ty)
	break;
      c.pop();
      if(b[x][y][d[0]][d[1]]==-1||b[x][y][d[0]][d[1]]>z){
	b[x][y][d[0]][d[1]]=z;
	if(a[x-1][y]!=-1){
	  fn(d,'e');
	  c.push(make_pair(make_pair(z+a[x-1][y]*d[5],d),make_pair(x-1,y)));
	  fn(d,'w');
	}
	if(a[x+1][y]!=-1){
	  fn(d,'w');
	  c.push(make_pair(make_pair(z+a[x+1][y]*d[5],d),make_pair(x+1,y)));
	  fn(d,'e');
	}
	if(a[x][y-1]!=-1){
	  fn(d,'s');
	  c.push(make_pair(make_pair(z+a[x][y-1]*d[5],d),make_pair(x,y-1)));
	  fn(d,'n');
	}
	if(a[x][y+1]!=-1){
	  fn(d,'n');
	  c.push(make_pair(make_pair(z+a[x][y+1]*d[5],d),make_pair(x,y+1)));
	  fn(d,'s');
	}
      }
    }
    cout<<c.top().first.first<<endl;
  }
  return 0;
}

Measured memory_bytes: 1060
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	n, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return n
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	a := nextInt(sc)
	b := nextInt(sc)
	if a < b {
		fmt.Println("a < b")
	} else if a > b {
		fmt.Println("a > b")
	} else {
		fmt.Println("a == b")
	}
}



Measured memory_bytes: 1076
#include <bits/stdc++.h>
using namespace std;
using LL  = long long;
using VI  = vector<LL>;
using VVI = vector<VI>;
using VB  = vector<bool>;
using VS  = vector<string>;
using PII = pair<LL, LL>;
using VP  = vector<PII>;
#define PB           push_back
#define MP           make_pair
#define SZ(a)        LL((a).size())
#define EACH(x, c)   for (auto x : (c))
#define ALL(c)       (c).begin(), (c).end()
#define REVERSE(c)   reverse(ALL(c))
#define SORT(c)      stable_sort(ALL(c))
#define RSORT(c)     stable_sort((c).rbegin(), (c).rend())
#define FOR(i, a, b) for (LL i = (a); i < (b); ++i)
#define REP(i, n)    FOR(i, 0, n)
#define dump(x)      cerr << #x << " = " << (x) << endl;

const LL MOD = 1e9 + 7;
inline LL mod_add(LL a, LL b) { return (a + b) % MOD; }
inline LL mod_sub(LL a, LL b) { return (a + MOD - b) % MOD; }
inline LL mod_mul(LL a, LL b) { return ((a % MOD) * (b % MOD)) % MOD; }
inline LL mod_bipow(LL x, LL y) {   // x^y by bisection method
    if (y == 0) return 1;
    else if (y == 1) return x % MOD;
    else if (y % 2 == 0) {
        LL val = mod_bipow(x, (LL)(y / 2));
        return mod_mul(val, val);
    } else {
        LL val = mod_bipow(x, (LL)(y / 2));
        return mod_mul(mod_mul(val, val), x);
    }
}
inline LL mod_inv(LL x) { return mod_bipow(x, MOD - 2); }   // x^{-1} = x^{MOD-2} (MOD: prime number)
inline LL mod_div(LL a, LL b) { return mod_mul(a, mod_inv(b)); }   // a/b = a*b^{-1}

class Combination {
    VI facts, inv_facts;
public:
    Combination(LL N) : facts(N + 1), inv_facts(N + 1) {
        REP(i, N + 1) facts[i] = i == 0 ? 1 : mod_mul(facts[i - 1], i);
        for (LL i = N; i >= 0; i--) inv_facts[i] = i == N ? mod_inv(facts[N]) : mod_mul(inv_facts[i + 1], i + 1);   // (i!)^{-1}=((i+1)!)^{-1}*(i+1)
    }
    LL nCr(LL n, LL r) {
        return mod_mul(facts[n], mod_mul(inv_facts[r], inv_facts[n - r]));
    }
};

int main() {
    LL N, M, K;
    cin >> N >> M >> K;

    LL ans = 0;
    FOR(d, 1, N) {
        ans = mod_add(ans, mod_mul(d, mod_mul(mod_mul(mod_sub(N, d), M), M)));
    }
    FOR(d, 1, M) {
        ans = mod_add(ans, mod_mul(d, mod_mul(mod_mul(mod_sub(M, d), N), N)));
    }
    Combination c(N * M);
    ans = mod_mul(ans, c.nCr(N * M - 2, K - 2));
    cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 3328
n, d = map(int, input().split())

xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]

count = 0

for i, j in zip(x, y):
    if i*i + j*j <= d*d:
        count += 1

print(count)

Measured memory_bytes: 116660
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int Q = 1e+9;
	int x1 = 0, x2 = 1e+9, x3, y1 = 0, y2 = 1, y3, S;
	cin >> S;

	y3 = S / Q;
	if (y3%Q != 0 || y3==0) {
		x3 = Q - S % Q;
		y3++;
	}

	cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;

	
	
	return 0;
}



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

int main()
{
    int n;
    cin >> n;
    if (n%10==3)
    {
        cout << "bon" << endl;
    }
    else if (n%10 == 0 or n%10 == 1 or n%10 == 6 or n%10 == 8 )
    {
        cout << "pon" << endl;
    }
    else
    {
        cout << "hon" << endl;
    }
    
}

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

int main() {
	int N,K;
    cin >> N >> K;
	vector<char> s(N);
    for(int i=0;i<N;i++){
      cin >> s.at(i);
      if(i==K-1){
        s.at(i) += 0x20;
      }
      cout << s.at(i);
    }
    cout << endl;
}

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

const int INF = 1'000'000'000;

int main() {
  string s, t;
  cin >> s >> t;
  int ans = INF;
  for(int i=0; i<=s.size()-t.size(); ++i){
    int cnt = 0;
    for(int j=0; j<t.size(); ++j){
      if (s[i+j] != t[j]) cnt++;
    }
    ans = min(cnt, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define ll long long
#define N 200
using namespace std;

int n, ans, a[N];
bool b[N][N][N];

inline int read(){
	int s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

int main(){
	n = read();
	for (int i = 1; i <= n; ++i) a[i] = read();
	sort(a + 1, a + n + 1);
	for (int i = 1; i < n - 1; ++i)
		for (int j = i + 1; j < n; ++j)
			for (int k = j + 1; k <= n; ++k)
				if (a[i] + a[j] > a[k] && a[i] != a[j] && a[j] != a[k] && a[i] != a[k]) ans++;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
#define LL long long
#define LD long double
#define ULL unsigned long long
#define UI unsigned int
#define PII pair<int,int>
#define MPII(x,y) pair<int,int>{x,y}
#define _for(i,j,k) for(int i=j;i<=k;i++)
#define for_(i,j,k) for(int i=j;i>=k;i--)
#define efor(i,u) for(int i=head[u];i;i=net[i])
#define lowbit(x) (x&-x)
#define ls(x) x<<1
#define rs(x) x<<1|1
#define inf 0x3fffffff
//#pragma comment(linker, "/STACK:10240000000,10240000000")
using namespace std;
const int maxn = 1e6 + 5;
const int M = 1e9 + 7;
inline int mad(int a,int b){return (a+=b)>=M?a-M:a;}
int head[maxn],e[maxn],net[maxn],cnt,vis[maxn],n,m;
void add(int u,int v){
	e[++cnt]=v;
	net[cnt]=head[u];
	head[u]=cnt;
}
bool dfs(int u,int K){
	//cout<<u<<endl;
	if(K<=0) return false;
	vis[u]=-1;
	for(int i=head[u];i;i=net[i]){
		if(vis[e[i]]==-1) return true;
		if(dfs(e[i],K-1)) return true;
	}
	vis[u]=0;
	return false;
}
bool ck(int K){
	//cout<<m<<endl;
	_for(i,1,n){
		_for(j,1,n) vis[j]=0;
		if(dfs(i,K)) return true;
	}
	return false;
}
vector<int> path;
bool dff(int u,int K){
	//cout<<u<<endl;
	if(K<=0) return false;
	vis[u]=-1;
	path.push_back(u);
	for(int i=head[u];i;i=net[i]){
		if(vis[e[i]]==-1) return true;
		if(dff(e[i],K-1)) return true;
	}
	vis[u]=0;
	path.pop_back();
	return false;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	cin>>n>>m;
	int u,v;
	_for(i,1,m){
		cin>>u>>v;
		add(u,v);
	}
	int l=0,r=n+1,mid;//cout<<n<<endl;
	while(l<r){
		//cout<<l<<" "<<r<<endl;
		mid=(l+r)>>1;//cout<<n<<endl;
		if(ck(mid)) r=mid;
		else l=mid+1;
	}
	//cout<<r<<"\n";
	if(r==n+1) puts("-1");
	else{
		cout<<r<<"\n";
		_for(i,1,n){
			path.clear();
			_for(j,1,n) vis[j]=0;
			if(dff(i,r)) break;
		}
		int sz=path.size();
		_for(i,0,sz-1){
			cout<<path[i]<<"\n";
		}
	}
	return 0;
}


Measured memory_bytes: 6528
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

/**
 *  0066 Tic Tac Toe
 */
public class Main {

	public static void main(String[] args) throws IOException {
		List<TicTacToe> ticTacToeList = readTicTacToe();
		for (TicTacToe ticTacToe : ticTacToeList) {
			// System.out.println(ticTacToe);
			System.out.println(ticTacToe.judge());
		}
	}

	private static List<TicTacToe> readTicTacToe() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		List<TicTacToe> ticTacToeList = new ArrayList<>();
		String line = null;
		while((line = reader.readLine()) != null) {
			ticTacToeList.add(new TicTacToe(line));
		}
		return ticTacToeList;
	}

	// Tic Tac Toe
	private static class TicTacToe {

		// Field
		private char[][] field;

		// Constructor
		public TicTacToe(String input) {
			field = new char[3][3];
			for (int i = 0; i < field.length; i++) {
				for (int j = 0; j < field[i].length; j++) {
					field[i][j] = input.charAt(i * field[i].length + j);
				}
			}
		}

		// Judge
		private char judge() {

			// Horizontal
			for (int i = 0; i < field.length; i++) {
				if (field[i][0] != 's' && field[i][0] == field[i][1] && field[i][0] == field[i][2]) {
					return field[i][0];
				}
			}

			// Vertical
			for (int i = 0; i < field.length; i++) {
				if (field[0][i] != 's' && field[0][i] == field[1][i] && field[0][i] == field[2][i]) {
					return field[0][i];
				}
			}

			// Cross
			if (field[0][0] != 's' && field[0][0] == field[1][1] && field[0][0] == field[2][2]) {
				return field[0][0];
			}
			if (field[0][2] != 's' && field[0][2] == field[1][1] && field[0][2] == field[2][0]) {
				return field[0][2];
			}

			return 'd';
		}

		@Override
		public String toString() {
			StringBuilder buffer = new StringBuilder();
			for( int i = 0; i < field.length; i++) {
				for (int j = 0; j < field[i].length; j++) {
					buffer.append(field[i][j]);
				}
				buffer.append("\r\n");
			}
			return buffer.toString();
		}
	}
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if ( a % 2 == 0 || b % 2 == 0) {
    cout << "Even" << endl;
  }
  else  {
    cout << "Odd" << endl;
  }
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
mod = 998244353

def make_array_for_comb(N, mod):
    fact = [1,1]
    fact_inv = [1,1]
    inv = [0,1]
    for i in range(2, N+1):
        fact.append((fact[-1]*i) % mod)
        inv.append((-inv[mod%i] * (mod//i)) % mod)
        fact_inv.append((fact_inv[-1]*inv[i]) % mod)
    return fact, fact_inv

def comb(n, r, mod):
  if (r < 0) or (n < r):
      return 0
  r = min(r, n - r)
  return fact[n] * fact_inv[r] * fact_inv[n-r] % mod

n,m,k = map(int,readline().split())
fact, fact_inv = make_array_for_comb(n,mod)
ans = 0

for i in range(k+1):
  ans += comb(n-1,i,mod)*m*pow(m-1,n-i-1,mod)
  ans %= mod

print(ans)

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

int n, W;
int v[1200], w[1200], dp[1200];

void solve() {
  fill(dp, dp+1200, 0);
  for(int i = 0; i < n; i++) {
    for(int j = W; j >= 0; j--) {
      if(j-w[i] >= 0) dp[j] = max(dp[j], dp[j-w[i]] + v[i]);
    }
  }
  cout << dp[W] << endl;

  for(int i = W; i >= 0; i--) {
    if(dp[W] != dp[i]) {
      cout << i+1 << endl;
      break;
    }
  }
}

int main() {
  int cnt = 1;
  while(cin >> W, W) {
    cin >> n;
    for(int i = 0; i < n; i++) {
      scanf("%d,%d", &v[i], &w[i]);
    }
    
    printf("Case %d:\n", cnt++);
    solve();
  }
}

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

using namespace std;

int main() {
    
    /// De studiat
    long long N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    cout << max(max( (N - 1) / A, (N - 1) / B),max( (N - 1) / C,max( (N - 1) / D, (N - 1) / E ))) + 5 << '\n';
    return 0;
}


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

void solve(long long N, std::string s, std::string t) {
    rep(i, N) {
        string subs = s.substr(i);
        if (t.find(subs) != t.npos) {
            cout << (s.substr(0, N - subs.length()) + t).length() << endl;
            return;
        }
    }
    cout << (s + t).length() << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::string s;
    std::cin >> s;
    std::string t;
    std::cin >> t;
    solve(N, s, t);
    return 0;
}


Measured memory_bytes: 3656
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}


int main(){
	FIO
	
	int a, b;char op;
	while(cin >> a >> op >> b){
		if(op == '?')break;
		if(op == '+')cout << a + b << "\n";
		if(op == '-')cout << a - b << "\n";
		if(op == '*')cout << a * b << "\n";
		if(op == '/')cout << a / b << "\n";
	}
	return 0;
}



Measured memory_bytes: 3184
#include<iostream>
using namespace std;
typedef long long ll;
 
int MAX_NODE=100000;
int main()
{
    int N;
    ll L;
    cin >> N >> L;
 
    int child[MAX_NODE][2];
    fill(child[0], child[0]+MAX_NODE*2, -1);
    int depth[MAX_NODE];
    fill(depth, depth+MAX_NODE, -1);
 
    depth[0]=0;
    int nodeCount=1;
 
    for (int i=0;i<N;i++){
        string s;
        cin >> s;
        int prevNode=0;
        int nextNode=-1;
 
        for (int j=0; j<s.length(); j++){
            int direc = s[j] - '0';
 
            nextNode = child[prevNode][direc];
            if (nextNode == -1){
                nextNode = nodeCount;
                nodeCount += 1;
                child[prevNode][direc]=nextNode;
                depth[nextNode] = j + 1;
            }
            prevNode = nextNode;
        }
    }
 
    ll ans = 0;
    for (int i =0;i<nodeCount;i++){
        ll d = L - depth[i];
        if (d > 0) {
            ll g = d&-d;
            for (int j = 0; j < 2; j++) {
                if (child[i][j] == -1) {
                    ans ^= g;
                }
            }
        }
    }
 
    if (ans!=0){
        cout<<"Alice"<<endl;
    } else {
        cout<<"Bob"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
int main(void){
  int n,d,i,x,a,ans;
  cin >> n >> d >> x;
  ans=x;
  for (i=0;i<n;i++){
    cin >> a;
    ans+=(d+a-1)/a;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T>& a) {
  os << "{";
  for (size_t i = 0; i < a.size(); ++i) os << (i > 0 ? "," : "") << a[i];
  return os << "}";
}

constexpr ll MOD = 1000000007;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

template <typename T, typename C>
ostream& operator<<(ostream& os, const multiset<T, C>& v) {
  os << '{';
  for (auto it = v.begin(); it != v.end(); it++) {
    if (it != v.begin()) os << ", ";
    os << *it;
  }
  os << '}';

  return os;
}
template <typename T1, typename T2, typename C>
ostream& operator<<(ostream& os, const map<T1, T2, C>& mp) {
  os << '[';
  for (auto it = mp.begin(); it != mp.end(); it++) {
    if (it != mp.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  os << ']';

  return os;
}

int main() {
  int h, w;
  cin >> h >> w;
  // 右へ動く最小値を保管
  // ある点から始まった場合、
  // 複数の最短経路結果を持ちたい。
  //

  map<int, int> mp;
  multiset<int> st;
  rep(i, 0, w) {
    mp[i] = i;
    st.insert(0);
  }

  rep(i, 0, h) {
    int a, b;
    cin >> a >> b;
    --a;
    // [a, b]はいけない
    auto itr = mp.lower_bound(a);
    int most_right = -1;
    while (itr != mp.end() && itr->first <= b) {
      most_right = max(most_right, itr->second);
      int x = itr->first - itr->second;
      st.erase(st.find(x));
      itr = mp.erase(itr);
    }

    if (most_right != -1 && b < w) {
      st.insert(b - most_right);
      mp[b] = most_right;
    }
    if (st.size() > 0)
      cout << *st.begin() + i + 1 << '\n';
    else
      cout << -1 << '\n';
  }
  return 0;
}

Measured memory_bytes: 22344
S = input()
ansA = 0
ansB = 0
for i in range(len(S)):
    N = int(S[i])
    if N == 1:
        ansA += 1
    elif N % 2 == 0:
        ansA += N//2
        ansB += N//2
    else:
        N -= 1
        ansA += N//2+1
        ansB += N//2
if ansA == 1 and ansB == 0:
    ans = 10
else:
    ans = ansA+ansB
print(ans)


Measured memory_bytes: 9048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.StringTokenizer;

/**
 * Main
 */
public class Main {

    public static void main(String[] args) {
        FastScanner scan = new FastScanner(System.in);
        final int N = scan.nextInt();
        Map<Integer, Integer> map = new LinkedHashMap<>();
        for (int i = 1; i <= N; i++) {
            map.put(scan.nextInt(), i);
        }
        Object[] key = map.keySet().toArray();
        Arrays.sort(key);
        for (int i = 0; i < N - 1; i++) {
            System.out.print(map.get(key[i]) + " ");
        }
        System.out.print(map.get(key[N - 1]));
    }

    static class FastScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        public String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        public int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = nextLong();
            return a;
        }
    }
}

Measured memory_bytes: 54180
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
//ll dx[4] = {1, 0, -1, 0};
//ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	ll n, k;
	cin >> n >> k;
	ll l = n - k;
	vector<ll> fact(4002), facti(4002);
	fact[0] = facti[0] = 1;
	for (int i = 1; i <= 4000; i++) {
		fact[i]  = (fact[i - 1] * i) % MOD;
		facti[i] = powm(fact[i], MOD - 2, MOD);
	}
	for (int i = 1; i <= k; i++) {
		if (l < i - 1) {
			dump(0);
			continue;
		}
		ll ans = (((fact[k - 1] * facti[i - 1]) % MOD) * facti[k - i]) % MOD;
		ans *= (((fact[l + 1] * facti[l - i + 1]) % MOD) * facti[i]) % MOD;
		ans %= MOD;
		dump(ans);
	}
	return 0;
}


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

vector<int> v[8];
bool vis[8];
int ans,n,m,a,b;

void DFS(int len,int x){
	if(vis[x])return;
	if(len==n-1){
		ans++;
		return;
	}
	vis[x]=true;
	for(int i=0;i<v[x].size();i++){
		DFS(len+1,v[x][i]);
	}
	vis[x]=false;
}

int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++)vis[i]=false;
	for(int i=0;i<m;i++){
		cin>>a>>b;a--,b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	ans=0;
	DFS(0,0);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    vector<int> X(M);
    REP(i, M) {
        cin >> X[i];
    }
    if (N >= M) {
        cout << 0 << endl;
        return 0;
    }
    SORT(X);
    vector<int> diff(M - 1);
    REP(i, M - 1) {
        diff[i] = X[i + 1] - X[i];
    }
    SORT(diff);
    ll res = 0;
    REP(i, M - N) {
        res += diff[i];
    }
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 1024
def solve(A,N):
    A.sort()
    if N == 1:
        return 1
    elif N == 2:
        if A[1] == A[0]:
            return 0
        elif A[1] % A[0] == 0:
            return 1
        else:
            return 2
    else:
        Col = set()
        if A[0] == A[1]:
            Col.add(A[0])
        for i in range(1,N-1):
            if A[i-1] == A[i] or A[i] == A[i+1]:
                Col.add(A[i])
        if A[N-1] == A[N-2]:
            Col.add(A[N-1])

        Mul = set()
        cand = set()
        for i in range(N):
            if A[i] not in Mul:
                if A[i] not in Col:
                    cand.add(A[i])
                for d in range(1,(A[N-1]//A[i])+1):
                    Mul.add(A[i] * d)

        return len(cand)

def main():
    N = int(input())
    A = list(map(int,input().split()))

    print(solve(A,N))

if __name__ == "__main__":
    main()


Measured memory_bytes: 172572
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int H, A;
    cin >> H >> A;
    cout << (H + A - 1)/A;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int N,M;
	scanf("%d %d",&N,&M);
	int L,R;
	int min=1;
	int max=N;

	for(int i=0; i<M; i++){
		scanf("%d %d",&L,&R);
		if(min>R || max<L) {printf("%d\n",0 ); return 0;}
		if(min<L) min=L;
		if(max>R)max=R;
	}

	printf("%d\n",max-min+1 );
}

Measured memory_bytes: 128