akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for (int i = 0; i < (n) ; ++i)
#define sz(v) (ll)(v).size()
#define int long long
#define mod 1000000007

void solve() {
        int n, m, k; cin >> n>> m>> k;
        string arr[101]= {};
        int b= 0;
        lp(i, n) {
                cin >> arr[i];
        }
        lp(i, n) {
                lp(j, m) {
                        if (arr[i][j]== '#') { b++; }

                }
        }
        int gen= n+ m, ans= 0;
        for (int i = 0; i< 1<<gen; i++) {
                int an= b;
                bool vis[10][10]= {};
                for (int j = 0; j< gen; j++) {
                        if (i& (1<<j)) {
                                if ((j+ 1) <= n) {
                                        lp(k, m) {
                                                if (!vis[j][k]) {
                                                        vis[j][k]= 1;
                                                        if (arr[j][k]== '#') an--;
                                                }
                                        }
                                } else {
                                        lp(k, n) {
                                                if (!vis[k][j- n]) {
                                                        vis[k][j- n]= 1;
                                                        if (arr[k][j- n]== '#') an--;
                                                }
                                        }
                                }
                        }
                }
                if (an== k) ans++;
        }
        cout << ans<< "\n";
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int t = 1;
        //cin >> t;
        while ( t-- ) {
                solve();
        }
return 0;
}


Measured memory_bytes: 3660
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define INF 1e6
int n;
int c[1005],w[1005];
int sum[1005];

bool data[1005][1005];
int dp[1005];


int main(void){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d %d",&c[i],&w[i]);
	}
	memset(data,false,sizeof(false));
	for(int i=1;i<=n;i++){
		sum[i]=sum[i-1]+w[i];
		dp[i]=INF;
		data[i][i]=true;
	}
	for(int l=1;l<n;l++){
		for(int i=1;i<=n-l;i++){
			int r=i+l;
			if(data[i][r-1] && c[r]>=sum[r-1]-sum[i-1])data[i][r]=true;
			if(data[i+1][r] && c[i]>=sum[r]-sum[i])data[i][r]=true;
		}
	}
	dp[0]=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=i;j++){
			if(data[j][i])dp[i]=min(dp[i],dp[j-1]+1);
		}
	}
	printf("%d\n",dp[n]);
	return 0;
}

Measured memory_bytes: 2024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
int n,k;
int h[100000+10];
int dp[100000+10];
int cha(int x,int y)
{
    if(x>=y)    return x-y;
    else    return y-x;
    return  y-x;
}
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++)    cin>>h[i];
    dp[0]=0;
    dp[1]=cha(h[1],h[0]);
    for(int i=2;i<n;i++)
    {
        int least=inf;
        for(int j=max(0,i-k);j<i;j++)
        {
            least=min(least,dp[j]+cha(h[i],h[j]));
        }
        dp[i]=least;
    }
    cout<<dp[n-1];
    return 0;
}

Measured memory_bytes: 1024
MOD = 10**9+7

n = int(input())

ans = 1
for i in range(n):
    ans = ans*10%MOD

minus = 1
minus2 = 1
for i in range(n):
    minus = minus*8%MOD
    minus2 = minus2*9%MOD
    
print((ans-2*minus2+minus)%MOD)

Measured memory_bytes: 63596
#include<bits/stdc++.h>
using namespace std;
int n,a[200005],b[200005],c; 
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	{
		if(a[i]!=a[i+1])
		{
			b[++c]=a[i];
		}
	}
	if(c==n)  cout<<"YES"<<endl;
	else    cout<<"NO"<<endl;

	return 0;
}

Measured memory_bytes: 1792
import java.io.*;

class Main {
    public static void main(String[] args) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));// ??\????????????????????????
            String line = br.readLine();
            int deptWeek = Integer.parseInt(line);
            int dept = 100000;
            for(int i = 0; i < deptWeek; i++ ){
            	int checkDept = (int)(dept * 0.05);
            	dept = dept + checkDept;
            	String strCheckDept = String.valueOf(dept);
            	String num = strCheckDept.substring(strCheckDept.length() - 3, strCheckDept.length());
            	if(!num.equals("000")){
            		int numnum = Integer.parseInt(num);
            		dept = dept + 1000 - numnum;
            	}
            }
            System.out.println(dept); 
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 24176
object Main {
  def main(args:Array[String]){
    val vals = readLine().split(" ").map(s => s.toInt)
    val a = vals(0)
    val b = vals(1)
    if (a < b) println("a < b")
    if (a > b) println("a > b")
    if (a == b) println("a == b")
  }
}

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

int main() {
  int H,W;
  string word;
  cin >> H >> W;
  for(int i = 0;i < W+2;i++){
    cout << "#";
  }
  cout << endl;
  for(int i = 0;i < H;i++){
  cout << "#";
  cin >> word;
  cout << word << "#" << endl;
  }
    for(int i = 0;i < W+2;i++){
    cout << "#";
  }
  
}


Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	r, g, b := sc.nextInt(), sc.nextInt(), sc.nextInt()
	n := r*100 + g*10 + b
	if n%4 == 0 {
		fmt.Fprintln(wtr, "YES")
	} else {
		fmt.Fprintln(wtr, "NO")
	}

	wtr.Flush()
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
double pie=3.14159265358979;
long long mod=998244353;
//
int main(){
	string t;
	cin>>t;
	int n=t.size();
	for(int i=0;i<n;i++){
		if(t[i]=='?'){
			if(i+1<n&&t[i+1]=='D'){
				t[i]='P';
			}else if(i+1<n&&t[i+1]=='P'){
				t[i]='D';
			}else if(i+1<n&&t[i+1]=='?'){
				t[i]='P';
				t[i+1]='D';
			}
		}else if(t[i]=='P'){
			if(i+1<n&&t[i+1]=='?'){
				t[i+1]='D';
			}
		}else if(t[i]=='D'){
			continue;
		}
	}
	for(int i=0;i<n;i++){
		if(t[i]=='?'){
			t[i]='D';
		}
	}
	cout<<t<<endl;
	return 0;
}

Measured memory_bytes: 3764
# S の長さが K 以下であれば、 S をそのまま出力してください。 
# S の長さが K を上回っているならば、先頭 K 文字だけを切り出し、末尾に ... を付加して出力してください。

k = int(input())
s = input()

if len(s) <= k:
    print(s)
else:
    print(s[:k] + "...")	

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

int main() {
  string s;
  cin >> s;
  
  for(int i = 0; i < s.size(); i++){
    if(s[i] == ','){
      s[i] = ' ';
    }
  }
  
  cout << s << endl;
  
  return 0;
}

Measured memory_bytes: 256
import sys
n, k = list(map(int, input().split()))
nums = [-1] + list(map(int, input().split()))

visited = [0 for _ in range(n + 1)]
path = [1]
cur = 1
visited[1] = 1
for i in range(k):
	cur = nums[cur]
	path.append(cur)
	if visited[cur] == 1:
		for idx, val in enumerate(path):
			if val == cur:
				break
		# print(k, idx, path)
		# print((k - idx) % (len(path) - idx - 1))
		print(path[idx + (k - idx) % ((len(path) - idx - 1))])
		sys.exit()
	else:
		visited[cur] = 1
print(cur)


Measured memory_bytes: 32380
#include<iostream>
using namespace std;
int main(){
    int n, m, a[100][100], b[100], sum[100]={};
    cin>>m>>n;
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
        for(int j=0;j<n;j++){
            cin>>b[j];
        }
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            sum[i] += b[j] * a[i][j] ;
        }
        cout<<sum[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 3104
#include<iostream>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define INF 1e6
using namespace std;

int cost[100][100];
int mincost[100];
bool used[100];
int V;

int prim(){
	rep(i,V){mincost[i]=INF;used[i]=false;}
	mincost[0]=0;
	int res=0;
	while(1){
		int v=-1;
		rep(u,V)if(!used[u] && (v==-1 || mincost[u]<mincost[v]))v=u;
		if(v==-1)break;
		used[v]=true;
		res+=mincost[v];
		mincost[v]=0;
		rep(u,V){
			mincost[u]=min(mincost[u],cost[v][u]);
		}
	}
	return res;
}

int main(){
	int n,m,a,b,d;
	while(cin>>n,n){
		V=n;
		cin>>m;
		rep(i,V){
			rep(j,V)cost[i][j]=cost[j][i]=INF;
		}
		rep(i,m){
			scanf("%d,%d,%d",&a,&b,&d);
			cost[a][b]=cost[b][a]=d/100-1;
		}
		cout<<prim()<<endl;
	}
	return 0;
}

Measured memory_bytes: 1284
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  long long ans = 0;

  for(int i = 1; i <= n; i++) {
    if(i % 3 != 0 && i % 5 != 0) {
      ans += i;
    }
  }

  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1704
#include<iostream>
#include<string>
#include<map>
using namespace std;
int main(){
	map<int,string> blood;
	int n[4],a;
	string b;
	char cn;
	n[3]=n[2]=n[1]=n[0]=0;
	while(cin>>a>>cn>>b){
		blood.insert(make_pair(a,b));
	}
	map<int,string>::iterator it;
	for(it=blood.begin();it!=blood.end();it++){
		if((*it).second=="A") n[0]++;
		else if((*it).second=="B") n[1]++;
		else if((*it).second=="AB") n[2]++;
		else if((*it).second=="O")n[3]++;
	}
	for(int i=0;i<4;i++) cout<<n[i]<<endl;
}

Measured memory_bytes: 0
// vim: shiftwidth=2 expandtab foldmethod=marker

// include {{{
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <utility>
#include <cstdlib>
#include <random>
#include <chrono>
// }}}

// debug(...) {{{
#ifdef LOCAL_DEBUG
#include "./debug.h"
#else
bool debug_enabled = false;
#define debug(...)
#define debugn(...)
#define debug_reset()
#endif

#include <cstdio>

template<class T>
std::string bin(int bits, const T& x) {
  char buf[bits + 1];
  buf[bits] = '\0';
  for(int i = 0; i < bits; i++) {
    if((x >> i) & 1) {
      buf[bits - i - 1] = '1';
    } else {
      buf[bits - i - 1] = '0';
    }
  }
  return std::string(buf);
}
std::string bin(int x) {
  if(x < 0) return bin(32, x);
  for(int i = 4; i < 31; i++) {
    int y = 1 << i;
    if(x < y) return bin(i, x);
  }
  return bin(32, x);
}
// }}}

// misc {{{
using namespace std;
template<class T, class U>

using umap = unordered_map<T, U>;
template<class T>
using uset = unordered_set<T>;

typedef long long ll;

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

template<class T>
void sort(T& arr) { // {{{
  std::sort(arr.begin(), arr.end());
} // }}}
template<class T, class By>
void sort_by(T& arr, By by) { // {{{
  std::sort(arr.begin(), arr.end(), [by](auto l, auto r){return  by(l) < by(r); });
} // }}}

template<class T>
void reverse(T& arr) { // {{{
  std::reverse(arr.begin(), arr.end());
} // }}}

class Random { // {{{
  public:
  std::uniform_int_distribution<> uniform_int;
  std::mt19937 rnd;
  std::bernoulli_distribution bern_dist;
  int uniform(int l, int r) {
    return uniform_int(rnd, std::uniform_int_distribution<>::param_type(l, r));
  }
  int next(int N) {
    return uniform(0, N - 1);
  }
  int bern(double p) {
    return bern_dist(rnd, std::bernoulli_distribution::param_type(p));
  }
}; // }}}

template <class A>
ostream& out_vec(const vector<A>& x, const string& sep) { // {{{
  rep(i, x.size()) {
    cout << x[i];
    if(i < x.size() - 1)
      cout << sep;
  }
  return cout;
} // }}}
// }}}

// main {{{
void solve();
int main() {
  cout << setprecision(20);
  solve();
}
// }}}

void solve() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  vector<int> ans(N);
  for(int i = N; i >= 1; --i) {
    int sum = 0;
    for(int j = i * 2; j <= N; j += i) {
      sum += ans[j - 1];
    }
    if(sum % 2 != A[i - 1]) ans[i - 1] = 1;
  }

  debugn(ans);

  int count = 0;
  rep(i, N) if(ans[i] == 1) ++count;
  cout << count << endl;
  rep(i, N) {
    if(ans[i] == 1) cout << (i + 1) << " ";
  }
}


Measured memory_bytes: 2560
#include<cstdio>
#include<algorithm>
#define st first
#define nd second

using namespace std;
using pii = pair<int, int>;
const int N = 2e5 + 10;
int prefixArray[N];
pii mons[N];

int main(){
    int n, d, a;
    scanf("%d %d %d", &n, &d, &a);
    for(int i = 1; i <= n; i++){
        scanf("%d %d", &mons[i].st, &mons[i].nd);
    }
    sort(mons + 1, mons + n + 1);
    int ptr = 1;
    long long ans = 0LL;
    for(int i = 1; i <= n; i++){
        while(ptr <= n && mons[ptr].st <= mons[i].st + 2 * d)
            ptr++;
        prefixArray[i] += prefixArray[i - 1];
        if(prefixArray[i] >= mons[i].nd)
            continue;
        int bombTime = (mons[i].nd - prefixArray[i] + a - 1) / a;
        ans += 1LL * bombTime;
        prefixArray[i] += bombTime * a;
        prefixArray[ptr] -= bombTime * a;
    }
    printf("%lld", ans);


}


Measured memory_bytes: 2560
while True:
    H,W = map(int,input().split())
    if H == 0 and W== 0:
        break
    for i in range(H):
        for k in range(W):
            if (i+k)%2 == 0:
                print('#',end = '')
            else:
                print('.',end = '')
        print()
    print ()


Measured memory_bytes: 7000
#include <iostream>//cout<<right で右揃え
#include <iomanip>//cout<<setw(数字) で空白による桁揃え
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <cstdlib>//abs()で整数絶対値
#include <cmath>//abs()かfabs()で少数絶対値
#include <functional>//sort第三引数greater<型名>()で降順
#include <map>

using namespace std;
using ll = long long int;

int main(){
    int X,Y;cin>>X>>Y;
    for(int i=0;i<=X;i++){
        if(2*i+4*(X-i)==Y){
            cout << "Yes" << endl;
            exit(0);
        }
    }
    cout << "No" << endl;
    return 0;
}

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

#define REP(i,a,b) for(int i=int(a);i<int(b);i++)

using namespace std;

typedef long long int lli;

int main () {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int cnt = 0;
    int l = 0;
    REP (i, 0, N) {
        if (S[i] == '(') {
            cnt++;
        }
        if (S[i] == ')') {
            cnt--;
        }
        if (cnt < 0) {
            cnt = 0;
            l++;
        }
    }
    REP (i, 0, l) cout << '(';
    cout << S;
    REP (i, 0, cnt) cout << ')';
    cout << endl;

    return 0;
}


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

using namespace std;

int solve(uint64_t h, uint64_t w) {
  uint64_t ans = INT_MAX;
  {
    uint64_t sizes[3];
    for (int i = 0; i < 3; ++i) {
      sizes[0] = (w / 3 + i) * h;
      sizes[1] = (w / 3) * h;
      sizes[2] = h * w - sizes[0] - sizes[1];
      sort(sizes, sizes + 3);
      ans = min(ans, sizes[2] - sizes[0]);
    }
  }
  for (int i = -5; i < 5; ++i) {
    for (int j = -5; j < 5; ++j) {
      uint64_t sizes[3];
      uint64_t wid = w / 3 + i;
      sizes[0] = wid * h;
      sizes[1] = (w - wid) * (h / 2 + j);
      sizes[2] = h * w - sizes[0] - sizes[1];
      sort(sizes, sizes + 3);
      ans = min(ans, sizes[2] - sizes[0]);
    }
  }
  return ans;
}

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

  uint64_t h, w;
  cin >> h >> w;
  if (h % 3 == 0 || w % 3 == 0) {
    cout << "0\n";
    return 0;
  }
  cout << min(solve(h, w), solve(w, h)) << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <map>
#include <stdio.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define pie 3.141592653

using namespace std;


int main()
{
	IO;

	int n;
	string s;
	vector <pair<string, int>>vp;
	vp.push_back(make_pair("AC", 0));
	vp.push_back(make_pair("WA", 0));
	vp.push_back(make_pair("TLE", 0)); 
	vp.push_back(make_pair("RE", 0));
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> s;
		for (int j = 0; j < 4; j++)
		{
			if (vp[j].first == s)
			{
				vp[j].second++;
				break;
			}
		}
	}
for(int i=0 ;i<4 ;i++)
	{
		cout << vp[i].first << " x " << vp[i].second;
		if (i < 3)
			cout << "\n";
	}
	return 0;
}


Measured memory_bytes: 3640
N, A, B, C, D = map(int, input().split())
S = input()
A -= 1
B -= 1
C -= 1
D -= 1


def f():
    if "##" in S[A: C + 1]:
        return False

    if "##" in S[B: D + 1]:
        return False

    if C < D:
        return True

    can_over = False
    prev_2 = ""
    prev_1 = ""
    for i in range(B - 1, D + 2):
        now = S[i]
        if prev_1 == prev_2 == now == ".":
            can_over = True

        prev_2, prev_1 = prev_1, now

    return can_over

print("Yes" if f() else "No")



Measured memory_bytes: 3572
n = int(input())
t, a = map(int, input().split())
cand = []
xs = list(map(int, input().split()))
for i in range(n):

    temp = t - xs[i] * 0.006
    cand.append(abs(a - temp))
copy = cand[:]
cand.sort()
print(copy.index(cand[0]) + 1)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;

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


Measured memory_bytes: 1408
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    int max = a[n-1];
    int m1 = max/2;
    int m2 = (max+1)/2;
    int minDiff = max+10;
    int idx = n-1;
    for (int i = 0; i < n-1; i++) {
      int diff = Math.min(Math.abs(a[i]-m1), Math.abs(a[i]-m2));
      if (minDiff > diff) {
        minDiff = diff;
        idx = i;
      }
    }
    System.out.println(max + " " + a[idx]);
  }
}

Measured memory_bytes: 50876
//#pragma once
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cctype>
#include <cstdlib>      // srand,rand


using namespace std;
#define modd 1000000007



typedef pair<long long, long long> pl;


typedef string::const_iterator State;
class ParseError {};




#define ll long long




class UnionFind {
public:
	vector <ll> par;
	vector <ll> siz;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL){
		for (ll i = 0; i < sz_; ++i) par[i] = i;
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};


class SegmentTree {
private:
	int n;
	vector <ll> node;

public:
	// 元の配列　v をセグメントツリーで表現する。
	SegmentTree(vector<ll> v) {
		//最下段のノード数は元配列のサイズ以上になる最小の2冪->これをnとおく。
		//セグ木全体で必要なノード数は2n-1個である。
		int sz = v.size();
		n = 1; 
		while (n < sz)n *= 2;

	}

};




long long N, M, K, a, b, c, d, e, H, W, L,T;
ll A[300005] = {};
ll B[300005] = {};
ll C[100][3005] = {};
bool f, ff;
string S,SS;
set <long long>sll;
pl bufpl;
vector <long long>vl[100005];
vector <long long>vll;
vector <pl>vpl;
vector <string> vs;
set<ll> llset[50];
multiset<ll> llmset;
queue<ll> ql;


struct ST
{
	ll first;
	ll second;
	ll kaisuu;
	

	bool operator<(const ST& another) const
	{
		return first < another.first;//比較
	};

};



/*vector <ST> vst;
ST st[200005];
ST bufst;
bitset<5000> bits;*/


long long modinv(long long aa, long long mm) {
	long long bb = mm, uu = 1, vv = 0;
	while (bb) {
		long long tt = aa / bb;
		aa -= tt * bb; swap(aa, bb);
		uu -= tt * vv; swap(uu, vv);
	}
	uu %= mm;
	if (uu < 0) uu += mm;
	return uu;
}


ll minn, maxx;
double ansa;

ll zettai(ll aa) {

	if (aa < 0) {
		aa *= -1;
	}
	return aa;

}


bool itta[300000];

int main() {
	
	cin >> N;

	a = 0;

	if (N >= 105) {
		a++;
	}

	if (N >= 165) {
		a++;
	}

	if (N >= 135) {
		a++;
	}

	if (N >= 189) {
		a++;
	}

	if (N >= 15*13) {
		a++;
	}

	cout << a << endl;

	//cout << fixed << setprecision(10) << ansa << endl;
	return 0;



}


Measured memory_bytes: 4096
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		if(isEven(a*b)){
			System.out.println("Even");
			return;
		}
		System.out.println("Odd");
	}

	private static boolean isEven(int a) {
		return a % 2 == 0;
	}

}


Measured memory_bytes: 21076
H, W = 5, 5
None, Wall = 0, 1
R, D, L, U = (0...4).to_a
Letter = ["R", "D", "L", "U"]
dy = [0, 1, 0, -1]
dx = [1, 0, -1, 0]

horizontalWall = Array.new(5+2) {Array.new(4+2, 0)}
verticalWall = Array.new(4+2) {Array.new(5+2, 0)}
horizontalWall[1][1,4] = gets.chomp.chars.map(&:to_i)
for i in 1..4 do
  verticalWall[i][1,5] = gets.chomp.chars.map(&:to_i)
  horizontalWall[i+1][1,4] = gets.chomp.chars.map(&:to_i)
end

frontWall = Array.new(H) {Array.new(W) {Array.new(4, 0)}}
rightWall = Array.new(H) {Array.new(W) {Array.new(4, 0)}}
for i in 0...5 do
  for j in 0...5 do
    rightWall[i][j][R] = horizontalWall[i+1][j+1]
    rightWall[i][j][L] = horizontalWall[i+1][j]
    rightWall[i][j][U] = verticalWall[i][j+1]
    rightWall[i][j][D] = verticalWall[i+1][j+1]

    frontWall[i][j][R] = verticalWall[i][j+1]
    frontWall[i][j][L] = verticalWall[i+1][j+1]
    frontWall[i][j][U] = horizontalWall[i+1][j]
    frontWall[i][j][D] = horizontalWall[i+1][j+1]
  end
end

y = x = 0
direction = R
while true do
  break if [y, x] == [0, 0] && direction != R
  if frontWall[y][x][direction] == Wall
    direction = (direction - 1) % 4
  else
    while rightWall[y][x][direction] != Wall do
      direction = (direction + 1) % 4
    end
  end
  print Letter[direction]
  y += dy[direction]
  x += dx[direction]
end
puts ""

Measured memory_bytes: 6136
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define pb push_back
#define eq push
#define dq pop
#define f front
#define inf 100000000
int main()
{
int n,d;
cin>>n>>d;
int m=d*2+1;
int a=floor(n/m);
if(n%m==0)
	cout<<a<<endl;
else
	cout<<a+1<<endl;
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int N;
	cin >> N;
	for(int i=1;i<=9;i++){
		int abc = i * 111;
		if(abc >= N){
			cout << abc << endl;
			return 0;
		}
	}
	
	
	
	
	
    return 0;
}

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

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

using namespace std;

using LL = long long int;
using LD = long double;

using pii = pair<int, int>;
using pll = pair<LL, LL>;
using pdd = pair<double, double>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<LL>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const LL INF64 = ((LL)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
LL gcd(LL x, LL y) { return y ? gcd(y, x % y) : x; }

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

	int n;
	cin >> n;

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

	int ans = 1, sum = 0;
	for (int i = 0; i < n - 1; i++) {
		ans = (2 * a[i] >= a[i + 1] ? ans + 1 : 1);
		a[i + 1] += a[i];
	}

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

Measured memory_bytes: 1024
from itertools import chain
H, W = map(int, input().split())
S = [input()+"#" for _ in range(H)]
S.append("#"*(W+1))
A = [[0]*(W) for _ in range(H)]

for i in range(H):
    tmp = 0
    stack = []
    for j in range(W+1):
        if S[i][j] == ".":
            tmp += 1
            stack.append(j)
        # elif j == W-1:
        #     if S[i][j] == ".":
        #         tmp += 1
        #         stack.append(j)
            
        #     while stack:
        #         tmp_j = stack.pop()
        #         A[i][tmp_j] += tmp
        #     tmp = 0
        else:
            while stack:
                tmp_j = stack.pop()
                A[i][tmp_j] += tmp
            tmp = 0
for j in range(W):
    tmp = 0
    stack = []
    for i in range(H+1):
        if S[i][j] == ".":
            tmp += 1
            stack.append(i)
        # elif i == H-1:
        #     if S[i][j] == ".":
        #         tmp += 1
        #         stack.append(i)
        #     while stack:
        #         tmp_i = stack.pop()
        #         A[tmp_i][j] += tmp
        #     tmp = 0
        else:
            while stack:
                tmp_i = stack.pop()
                A[tmp_i][j] += tmp
            tmp = 0
ans = max(chain.from_iterable(A))-1
print(ans)

Measured memory_bytes: 111560
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    int A[3];
    cin >> A[0] >> A[1] >> A[2];
    sort(A,A+3);
    if(A[0]==A[1] && A[1]!=A[2]){
        cout << "Yes" << endl;
        return 0;
    }
    if(A[0]!=A[1] && A[1]==A[2]){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 998244353;


int main(){
  ll r,g,b,n;cin>>r>>g>>b>>n;
  ll ans=0;
  rep(i,0,n/r+1){
    rep(j,0,(n-i*r)/g+1){
      if((n-i*r-j*g)%b==0){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}




Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    ll n,m;
    ll ans;
    cin >> n >> m;
    if(n*2 >= m) ans = m/2;
    else{
        ans = n;
        m -= n*2;
        ans += m/4;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
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; }
typedef long long ll;
typedef pair<int,int> P;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  //fact 階乗　iface 階乗の逆数
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
  int n,k;
  cin >> n >> k;
  combination c(200005);
  mint ans = 0;
  rep(i,k+1){
    if(i==n)break;
    mint res = 1;
    res *= c(n,i);
    res *= c(n-1,i);
    ans += res;
  }
  cout << ans << endl;
}

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

using namespace std;

#define int long long
// #define double long double
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
#define rAll(a) (a).rbegin(), (a).rend()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Printv(v)                                                              \
    {                                                                          \
        REP(x, v.size()) { cout << v[x] << (x == v.size() - 1 ? "\n" : " "); } \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<double> VD;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};
#define PI 3.141592653589793238

ll X[100001], N, A, B;

signed main() {
    cin >> N >> A >> B;
    ll ans = 0;
    REP(i, N) {
        cin >> X[i];
        if(i) ans += min((X[i] - X[i - 1]) * A, B);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
			int n = s.nextInt();
			int m = s.nextInt();
			int x = n*(n-1)/2 + m*(m-1)/2;
			System.out.println(x);
		s.close();
	}

}

Measured memory_bytes: 21716
import heapq
import math
n,m = map(int,input().split())
a = list(map(lambda x: int(x)*(-1),input().split()))
heapq.heapify(a)
for i in range(m):
    max = math.ceil(heapq.heappop(a)/2)
    heapq.heappush(a,max)
print(-sum(a))

Measured memory_bytes: 14536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

		String[] set = readline.split(" ");

		int a = Integer.parseInt(set[0]);
		int b = Integer.parseInt(set[1]);

		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: 24288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll h,c=1,ans;
int main(void){
	cin>>h;
	while(h>0){
		h=h/2;
		ans+=c;
		c=c*2;
	}
	cout<<ans<<endl;
	
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main()
{
	int d, g;
	scanf("%d %d", &d, &g);

	int p[d], c[d], min = 0;
	for (int i = 0; i < d; i++) {
		scanf("%d %d", &p[i], &c[i]);
		min += p[i];
	}

	int sum, count, is_already_used[d];
	for (int i = 0; i < pow(2, d); i++) {
		sum = 0;
		count = 0;
		for (int j = 0; j < d; j++) {
			if ((i >> j) & 1) {
				sum += 100 * (j + 1) * p[j] + c[j];
				count += p[j];
				is_already_used[j] = 1;
			} else {
				is_already_used[j] = 0;
			}
		}

		if (sum <  g) {
			for (int i = d - 1; i >= 0; i--) {
				if (is_already_used[i] == 1) continue;
				int left = g - sum;
				if (left <= 100 * (i + 1) * (p[i] - 1)) {
					int rem = left % (100 * (i + 1));
					int div = left / (100 * (i + 1));
					count += (rem == 0) ? div : div + 1;
					sum += (rem == 0) ? 100 * (i + 1) * div : 100 * (i + 1) * (div + 1);
					goto COMPARE;
				}
			}
			continue;
		}

		COMPARE: if (min > count) min = count;
	}
	printf("%d\n", min);
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"math/cmplx"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 0
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	eps := 1e-10
	q := getNextInt(scanner)
	for i := 0; i < q; i++ {
		xx := make([]float64, 4)
		yy := make([]float64, 4)
		for i := 0; i < 4; i++ {
			xx[i] = getNextFloat64(scanner)
			yy[i] = getNextFloat64(scanner)
		}
		s1 := complex(xx[1]-xx[0], yy[1]-yy[0])
		s2 := complex(xx[3]-xx[2], yy[3]-yy[2])
		s := s1 / s2

		if math.Abs(real(s)) < eps {
			fmt.Fprintln(writer, 1)
			continue
		}
		if math.Abs(imag(s)) < eps {
			fmt.Fprintln(writer, 2)
			continue
		}
		fmt.Fprintln(writer, 0)
	}
}

func rotate(v complex128, theta float64) complex128 {
	r, th := cmplx.Polar(v)
	th += theta
	return cmplx.Rect(r, th)
}



Measured memory_bytes: 1252
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <utility>

using namespace std;

template<typename T> 
void show(T a){
  for(auto i : a){ cout << i << " "; }
  cout << endl;
}
template<typename T> 
void showmatrix(T a){
  for(auto j: a){for(auto i : j){ cout << i; }cout << endl;}
  cout << endl;
}


int main(int argc, char *argv[]){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int t, x;
  cin >> t >> x;
  cout << (double)t/(double)x << endl;
}

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

int hon[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(M);
	for (auto& i : A) cin >> i;
	sort(A.begin(), A.end());
	reverse(A.begin(), A.end());

	vector<vector<int>> dp(N + 11, vector<int>(M));
	vector<string>num(N + 1);
	for (int i = 0; i <= N; i++) {
		int now = 0;
		for (int j = 0; j < M; j++) {
			now += dp[i][j];
		}

		if (i != 0 && now == 0) continue;

		for (int j = 0; j < M; j++) {
			bool flag = false;
			for (int k = 0; k < M; k++) {
				if (dp[i][k] + (j == k ? 1 : 0) >= dp[i + hon[A[j]]][k]) {
					if (dp[i][k] + (j == k ? 1 : 0) > dp[i + hon[A[j]]][k]) {
						flag = true;
					}
				} else {
					break;
				}
			}

			int next = 0;
			for (int k = 0; k < M; k++) {
				next += dp[i + hon[A[j]]][k];
			}

			if (next < now + 1) flag = true;

			if (flag == false || next > now + 1) continue;
			for (int k = 0; k < M; k++) {
				dp[i + hon[A[j]]][k] = dp[i][k] + (j == k ? 1 : 0);
			}
		}

		num[i] = "";
		for (int j = 0; j < M; j++) {
			for (int k = 0; k < dp[i][j]; k++) {
				num[i] += '0' + A[j];
			}
		}
	}


	cout << num[N] << endl;

	return 0;
}


Measured memory_bytes: 50048
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll a(n);
  multiset<ll> s;
  rep(i,n){
    cin>>a[i];
    s.insert(a[i]);
  }
  sort(all(a));
  a.erase(unique(all(a)),a.end());
  vll k(1000005);
  rep(i,sz(a)){
    ll cu=2;
    while(a[i]*cu<sz(k)){
      k[a[i]*cu]++;
      cu++;
    }
  }
  ll ans=0;
  rep(i,sz(a)){
    if(k[a[i]]==0&&s.count(a[i])==1)ans++;
  }
  COUT(ans);
}


Measured memory_bytes: 22012
#include <iostream>
#include <cstdio>
#include <algorithm>
#define endl '\n'
using namespace std;

int main()
{
    long long int n;
    int k, cnt=0;
    cin >> n >> k;
    while (n > 0) {
        n/=k;
        cnt++;
    }
    cout << cnt << endl;
}


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

using namespace std;


template<typename T>
void show(T a){
  for(auto i : a){
  }
  cout << endl;
}

int main(int argc, char *argv[]){
  int n, w;
  cin >> n >> w;
  vector<int> value(n, 0);
  vector<int> weight(n, 0);
  vector<int> dplist(w+1, 0);
  for(int i = 0; i < n; i++){
    int t1, t2;
    cin >> t1 >> t2;
    value[i] = t1;
    weight[i] = t2;
  }

  //dplist[i] : a
  //i : weight
  //a : max value at that weight
  //subproblem: max value at that weight(minium subproblem is that what value is a single object?)
  for(int i = 1; i <= w; i++){
    int maxium = 0;
    for(int j = 0; j < n; j++){
      if(weight[j] > i) continue;
      int tmp = dplist[i-weight[j]] + value[j];
      maxium = max(tmp, maxium);
    }
    dplist[i] = maxium;
  }

  cout << dplist[w] << endl;
  return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N;
vector<int> E[1010];
int M;
int ID[1010][1010];
int G[1010][1010];
int P[1010][1010];
int D[2][1010];
int A[202020],B[202020];

void dfs(int cur,int org) {
	G[org][cur]=1;
	FORR(e,E[cur]) if(G[org][e]==0) dfs(e,org);
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	MINUS(ID);
	
	FOR(i,M) {
		cin>>A[i]>>B[i];
		A[i]--;
		B[i]--;
		E[A[i]].push_back(B[i]);
		ID[A[i]][B[i]]=i;
	}
	
	FOR(i,N) dfs(i,i);
	FOR(i,N) {
		FOR(j,2) {
			FOR(x,N) D[j][x]=-1<<30;
			priority_queue<pair<int,int>> PQ;
			FOR(x,N) if(ID[i][x]>=0) {
				D[j][x]=ID[i][x];
				if(j) D[j][x]=-D[j][x];
				PQ.push({D[j][x],x});
			}
			
			while(PQ.size()) {
				int cur=PQ.top().second;
				int sc=PQ.top().first;
				PQ.pop();
				
				if(D[j][cur]!=sc) continue;
				FORR(e,E[cur]) if(D[j][e]<sc) {
					if(e==i) continue;
					D[j][e]=sc;
					PQ.push({sc,e});
				}
			}
		}
		FOR(x,N) {
			if(D[0][x]!=-1<<30 && D[0][x]!=-D[1][x]) P[i][x]=1;
		}
	}
	
	FOR(i,M) {
		if(P[A[i]][B[i]]==G[B[i]][A[i]]) cout<<"same"<<endl;
		else cout<<"diff"<<endl;
	}
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 16384
# @author 

import sys

class CMaximalValue:
    def solve(self):
        n = int(input())
        b = [int(_) for _ in input().split()] + [float('inf')]
        ans = 0
        for i in range(n):
            ans += min(b[i], b[i - 1])
        
        print(ans)

solver = CMaximalValue()
input = sys.stdin.readline

solver.solve()


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

/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)

/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair 

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int

/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;

/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

/*struct*/
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };  //Counterclockwise from the 9o'clock direction
//Take the x-axis downward and the y-axis right

//#define int ll
//#define int long long

signed main()
{
  int a,b,c;cin>>a>>b>>c;
  int x,y;cin>>x>>y;
  int numc{};
  ll cost = (1LL << 60);
  
  for(ll i = 0; i <= 1e5; ++i){
    //0LLにしてないとmax(int,llになって詰む)
    ll X = max(0LL,x-i);
    ll Y = max(0LL,y-i);
    cost = min(cost, X*a + Y*b + i*c*2);
  }

  
  cout << cost << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_set>

typedef unsigned short     ushort;
typedef unsigned int       uint;
typedef unsigned long long ullong;


int main( void )
{
    uint N;
    std::cin >> N;
    
    std::unordered_set<std::string> kinds;
    
    for ( uint i = 0; i < N; ++i )
    {
        std::string str;
        std::cin >> str;
        kinds.emplace(str);
    }
    
    std::cout << kinds.size() << std::endl;
    return 0;
}

Measured memory_bytes: 17700