akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std; //头文件和命名空间
int main(){
    ios::sync_with_stdio(false); //输入输出加速
    string sInput; //输入的字符串
    int i; //循环计数器
    cin >> sInput; //读入
    for (i = 0; i < sInput.length(); i+=2){ //枚举奇数位置，注意由于string中第一个字符的索引号为0，因此题目的奇数位事实上是字符串中索引号为偶数的位置
        cout << sInput[i]; //输出对应位置的字符，注意string中第一个字符的索引号为0
    }
    cout << endl; //换行
    return 0; //结束
}

Measured memory_bytes: 592
#include <stdio.h>
#include <stack>
using namespace std;
stack<char> s;
int main(){
	char c;
	int cnt=0;
	while(~scanf("%c",&c)){
		if(c=='\n') break;
		if(s.empty()) s.push(c);
		else{
			if(s.top()!=c){
				s.pop();
				cnt+=2;
			}
			else s.push(c);
		}
	}
	printf("%d",cnt);
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>
// #define int long long
const int inf = 1 << 30;
#define INF 1e+9
#define MAX_V 100008


int main(){
  int n; cin >> n;
  vector<long long> v(n);
  priority_queue<long long> pq;
  rep(i, 0, n){
    cin >> v[i];
    // pq.push(v[i]);
  }
  sort(all(v), greater<long long>());
  long long ans = v[0];
  pq.push(v[1]);
  pq.push(v[1]);
  if(v.size() > 2){
    for(int i=2; i<n;i++){
      long long tmp = pq.top(); pq.pop();
      ans += tmp;
      pq.push(v[i]);
      pq.push(v[i]);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 6924
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const i64 inf = (i64)1.05e15;

typedef pair<int,i64> edge;
typedef vector<edge> vertex;
typedef vector<vertex> graph;

void mark(int v, i64 d, graph& g, vector<i64>& xs)
{
	if(xs[v] != -inf)
		return;
	xs[v] = d;

	for(auto& e : g[v]) {
		int w = e.first;
		mark(w, d + e.second, g, xs);
	}
}

int main()
{
	int n, m;
	graph g;

	scanf("%d%d", &n, &m);
	g.resize(n);
	for(int i = 0; i < m; ++i) {
		int l, r, d;
		scanf("%d%d%d", &l, &r, &d);
		l -= 1;
		r -= 1;
		g[l].push_back({r, (i64)d});
		g[r].push_back({l, (i64)-d});
	}

	vector<i64> xs(n, -inf);
	bool invalid = false;

	for(int v = 0; v < n; ++v) {
		mark(v, 0, g, xs);
		for(auto& e : g[v]) {
			int w = e.first;
			if(xs[w] - xs[v] != e.second)
				invalid = true;
		}
	}

	printf("%s\n", invalid ? "No" : "Yes");

	return 0;
}

/* waffle */


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

int main()
{
	int m, f, r;
	
	while(1)
	{
	cin >> m >> f >> r;
	if(m == -1 && f == -1 && r == -1)
	{
		break;
	}
	
	if(m == -1 || f == -1)
	{
		cout << 'F' << endl;
	}
	else if(m + f >= 80)
	{
		cout << 'A' << endl;
	}
	else if(m + f >= 65)
	{
		cout << 'B' << endl;
	}
	else if(m + f >= 50)
	{
		cout << 'C' << endl;
	}
	else if(m + f >= 30)
	{
		if(r >= 50)
		{
			cout << 'C' << endl;
		}
		else
		{
			cout << 'D' << endl;
		}
	}
		else
		{
			cout << 'F' << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3104
#include <stdio.h>
 
int main(void) {
    char c;
    int A[26]= {0},i,j;
     
    while(scanf("%c", &c) != EOF){
        for (j=0; j<26; j++){
            if(c == 'a'+j || c == 'A'+j){
                A[j]++;
            }
        }
    }
    for(i=0; i<26; i++){
        printf("%c : %d\n", 'a'+i, A[i]);
    }
     
    return 0;
}

Measured memory_bytes: 540
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
const int MOD = 1000000007;
const ll INF = 1LL << 60;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   string s;
   cin >> s;
   for(int i = 0;i < s.length();i++) {
       if(s[i] == '7') {
           cout << "Yes" << endl;
           return 0;
       }
   }
   cout << "No" << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int N;
double T,A;
double H[1000];

int main(){
    cin>>N>>T>>A;
    rep(i,N) cin>>H[i];

    int ans;
    double val=10001001;
    rep(i,N){
        double abst=abs(A-(T-H[i]*0.006));
        if(abst<val){
            val=abst;
            ans=i+1;
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front

using namespace std;

typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

vector<vector<ll>> d;

void warshall_floyd(int n){
    rep(i,0,n)rep(st,0,n)rep(fin,0,n){
        d[st][fin] = min(d[st][fin],d[st][i]+d[i][fin]);
    }
}


int main(){
    ll H,W;
    cin>>H>>W;
    vector<string> S(H);
    rep(i,0,H)cin>>S[i];
    d.resize(H*W,vector<ll>(H*W));
    rep(i,0,H*W)rep(j,0,H*W){
        d[i][j] = INF;
        if(i == j) d[i][j] = 0;
    }
    rep(i,0,H)rep(j,0,W){
        if(S[i][j] == '#')continue;
        rep(k,0,2){
            if(i+dx[k]<0 || i+dx[k]>=H || j+dy[k]<0 ||j+dy[k]>=W)continue;
            if(S[i+dx[k]][j+dy[k]] == '.'){
                d[i*W+j][(i+dx[k]) * W + (j+dy[k])]=1;
                d[(i+dx[k]) * W + (j+dy[k])][i*W+j]=1;
            }
        }
    }

    warshall_floyd(H*W);
    ll max_d = 0;
    rep(i,0,H*W)rep(j,0,H*W){
        if(d[i][j] == INF)continue;
       max_d = max(max_d, d[i][j]); 
    }
    cout<<max_d;
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    bool state = 0;
    long c1 = 0;
    long c2 = 0;
    for (auto i : s) {
        if (i=='0' && state) c1++;
        if (i=='1' && !state) c1++;
        state = !state;
    }
    state = 1;
    for (auto i : s) {
        if (i=='0' && state) c2++;
        if (i=='1' && !state) c2++;
        state = !state;
    }
    cout << min(c1,c2);
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <queue>
#include <cctype>
#include <stdio.h>
#include <map>
#include <string.h>
#include <algorithm>

using namespace std;

int main(int argc, char const* argv[])
{
    int n,m;
    while (cin >> n >> m) 
    {
        //テァツオツづァツォツッテ・ツ按、テヲツ鳴ュ
        if (n == 0 && m==0){break;}
        //テ・ツ?・テ・ツ環?
        int arr[n][m];
        for (int i = 0; i < n; i++) 
        {
            for (int j = 0; j < m; j++) 
            {
                cin >> arr[i][j];
            }
        }

        vector<int> order(m);
        vector<int> count(m);
        //テ・ツ按敕ヲツ慊淌・ツ個?
        for (int t = 0; t < m; t++) 
        {
            count[t]=0;
            order[t] = t;
        }
        for (int j = 0; j < m; j++) 
        {
            for (int i = 0; i < n; i++) 
            {
                count[j] += arr[i][j];
            }
        }
        //
        //
        //for (int t = 0; t < m; t++) 
        //{
        //    cout << count[t] << " ";
        //}
        //cout << endl;
        //for (int i = 0; i < m-1; i++) 
        //{
        //    for (int j = i+1; j < m; j++) 
        //    {
        //        if (count[i] < count[j]) 
        //        {
        //            swap(order[i], order[j]);
        //        }
        //    }
        //}

        //sort
        for (int i = 0; i < m; i++) 
        {
            for (int j = m-1; i < j; j--) 
            {
                //cout << "order " << endl; 
                //for (int t = 0; t < m; t++) 
                //{
                //    cout << order[t];
                //}
                //cout << endl;
                //cout << "count " << endl;
                //for (int t = 0; t < m; t++) 
                //{
                //    cout << count[order[t]] << " ";
                //}
                //    cout << endl;
                if (count[order[j-1]] < count[order[j] ]) 
                {
                    //puts("swap");
                    //cout << j-1<< " " << j << endl;
                    swap(order[j-1], order[j]);
                }
            }
        }

        for (int t = 0; t < m-1; t++) 
        {
            cout << order[t] + 1 << " " ;
        }
        cout << order[m-1] + 1 << endl;
    }
    return 0;
}

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

int main()
{
    int n; cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d.at(i);
    set<int> tmp;


    rep(i,n) {
        tmp.insert(d.at(i));
    }

    cout << tmp.size() << endl;
}

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

using ll = long long;

int main(){
    int N;
    cin >> N;
    // vector<string> S(N);
    // set<string> ss;
    map<string, int> ma;
    string buf;
    ll count = 0;
    for(int i = 0; i<N; i++){
        cin >> buf;
        sort(buf.begin(), buf.end());
        if(ma.find(buf) != ma.end()){
            ma[buf]++;
        }else{
            ma[buf] = 1;
        }
    }

    for(auto it = ma.begin(); it!=ma.end(); it++){
        ll bb = it->second;
        count += bb * (bb-1) /2;
    }
    cout << count << endl;


}




Measured memory_bytes: 11136
//ΔAPC001G
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
typedef double DB;
const int N = 222222;
int n,q,a[N],b[N];
string s;
void ans(){
	int i,x=0,y=0;
	for(i=1;i<=n;i=i+1){
		if(a[i]&&a[i-1]&&!b[i]){
			if(x){
				if(y)
					b[i]=q,x=0,y=0;
				else
					b[i]=q-1,x=1,y=1;
			}
			else
				b[i]=++q,x=y,y^=1;
		}
	}
	cout<<"Yes\n";
	for(i=1;i<=n;i=i+1)
		cout<<b[i]<<' ';
	exit(0);
}
int main()
{
	int i,x,y,z,w,r;
	cin>>n>>s;
	n=n+n;
	for(i=1;i<n;i=i+1)
		a[i]=s[i-1]-'0';
	a[0]=1,a[n]=1;
	x=0;
	for(i=1;i<=n;i=i+1){
		if(!a[i]&&!a[i-1]){
			if(x)
				b[i]=q,x=0;
			else
				b[i]=++q,x=i;
		}
	}
	if(x){
		cout<<"No";
		return 0;
	}
	x=0,r=0;
	for(i=1;i<=n;i=i+1){
		if(a[i]^a[i-1]){
			if(x)
				b[i]=q,x=0;
			else
				b[i]=++q,x=i;
		}
		if(a[i]&&a[i-1])
			r++;
	}
	if(r&1){
		cout<<"No";
		return 0;
	}
	if(!(r&3))
		ans();
	x=0,y=0,z=0,w=0;
	for(i=1;i<=n;i=i+1){
		if(a[i]&&a[i-1]){
			if(!x)
				x=i;
			if(y&&!z)
				z=i;
		}
		if(a[i]^a[i-1]){
			if(x&&!y)
				y=i;
			if(z&&!w)
				w=i;
		}
	}
	if(w){
		x=y-1;
		swap(b[y],b[w]);
		b[x]=++q,b[z]=q;
		ans();
	}
	x=0,y=0,z=0,w=0;
	for(i=1;i<=n;i=i+1){
		if(a[i]^a[i-1]){
			if(!x)
				x=i;
			if(y&&!z)
				z=i;
		}
		if(a[i]&&a[i-1]){
			if(x&&!y)
				y=i;
			if(z&&!w)
				w=i;
		}
	}
	if(w){
		y=z-1;
		swap(b[x],b[z]);
		b[y]=++q,b[w]=q;
		ans();
	}
	cout<<"No";
	return 0;
}
/*
5
110111011

*/

Measured memory_bytes: 3332
<?php

$nkq = explode(' ', trim(fgets(STDIN)));
$n = $nkq[0];
$k = $nkq[1];
$q = $nkq[2];

for($i=1; $i<=$n; $i++){
  $a[$i] = $k-$q;
}

for($i=0; $i<$q; $i++){
  $w = trim(fgets(STDIN));
  $a[$w]++;
}

for($i=1; $i<=$n; $i++){
  if ($i !== 1) echo "\n";
  if ($a[$i] > 0){
    echo "Yes";
  } else {
    echo "No";
  }
}

  
?>

Measured memory_bytes: 10744
from collections import deque

h,w,K = map(int,input().split())

maze = [[x for x in input()] for _ in range(h)]

sx = 0
sy = 0

for i in range(h):
    for j in range(w):
        if maze[i][j] == 'S':
            sx = j
            sy = i

d = [[float('inf')]*w for _ in range(h)]
d[sy][sx] = 0

q = deque([[sy,sx]])
c = 0

visited = [[False]*w for _ in range(h)]
visited[sy][sx] = True

while q:
    y,x = q.popleft()
    for j,k in [[1,0],[-1,0],[0,1],[0,-1]]:
        ny,nx = y+j,x+k
        if maze[ny][nx] == '.' and not visited[ny][nx]:
            d[ny][nx] = d[y][x] + 1
            if ny in {0,h-1} or nx in {0,w-1}:
                if d[ny][nx] <= K:
                    print(1)
                    exit()
                else:
                    continue
            else:
                visited[ny][nx] = True
                if d[ny][nx] == K:
                    continue
                else:
                    q.append([ny,nx])
    

def BFS(sy,sx):
    visited = [[-1]*w for _ in range(h)]
    q = deque([[sy,sx]])
    visited[sy][sx] = 0
    while q:
        y,x = q.popleft()
        if y == 0 or y == h-1 or x == 0 or x == w-1:
            return visited[y][x]
        for l,k in [[1,0],[-1,0],[0,1],[0,-1]]:
            new_y,new_x = y+l,x+k
            if visited[new_y][new_x] == -1:
                visited[new_y][new_x] = visited[y][x] + 1
                q.append([new_y,new_x])

ans = float('inf')

for i in range(h):
    for j in range(w):
        if d[i][j] <= K:
            ans = min(ans,min(i,h-1-i,j,w-1-j))

print((ans-1) // K +2)

Measured memory_bytes: 89436
(defun num-list-from-string (n)                                                                                   
  (read-from-string (concatenate 'string "(" n ")")))

(defun alice-cards-helper (alis lis)
  (if (eq lis nil)                                                                                                
      alis
      (alice-cards-helper (+ alis (car lis)) (cddr lis)))) 

(defun main ()                                                                                                    
  (let ((l (sort (num-list-from-string (read-line)) #'> )))           
    (format t "~a" (- (alice-cards-helper 0 l) (alice-cards-helper 0 (cdr l)))))) 

(read)
(main)

Measured memory_bytes: 3944
#include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;

int main(){
  int m,n,l;
  int t;
  int ans;
  cin>>l;
  while(l!=0){
    t=0;
    ans=0;
    for(int i=0;i<12;i++){
      cin>>m>>n;     
      t+=m-n;
      if(t>=l && ans==0){
	ans=i+1;
      }
    }
    if(t<l){
      cout<<"NA"<<endl;
    }else{
      cout<<ans<<endl;
    }
    cin>>l;
  }

  return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<math.h>

using namespace std;

int main(void) {
	int a = 0, b = 0;
	int v = 0;
	int length = 0;
	cin >> a >> b;
	
	v = a * b;
	length = 2 * (a + b);

	cout << v << " " << length << endl;
	return 0;
}

Measured memory_bytes: 1168
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

void solve(int w, int h){
    vector<vector<bool>> ud(h+1, vector<bool>(w, false));
    vector<vector<bool>> lr(h, vector<bool>(w+1, false));

    int x;
    rep(i, h-1){
        rep(j, w-1){
            cin >> x;
            if(x == 0){
                lr[i][j+1] = true;
            }
        }

        rep(j, w){
            cin >> x;
            if(x == 0){
                ud[i+1][j] = true;
            }
        }
    }
    rep(i, w-1){
        cin >> x;
        if(x == 0){
            lr[h-1][i+1] = true;
        }
    }

    queue<tuple<int, int, int>> que;
    que.emplace(0, 0, 1);
    vector<vector<int>> mark(h, vector<int>(w, 0));
    while(not que.empty()){
        tuple<int, int, int> p = que.front();
        que.pop();

        int x = get<0>(p);
        int y = get<1>(p);
        int d = get<2>(p);

        if(mark[x][y] != 0){
            continue;
        }

        mark[x][y] = d;

        if(ud[x][y]){
            que.emplace(x-1, y, d+1);
        }
        if(ud[x+1][y]){
            que.emplace(x+1, y, d+1);
        }
        if(lr[x][y]){
            que.emplace(x, y-1, d+1);
        }
        if(lr[x][y+1]){
            que.emplace(x, y+1, d+1);
        }
    }

    cout << mark[h-1][w-1] << endl;
}

signed main(){
    while(true){
        int w, h;
        cin >> w >> h;

        if(w == 0 && h == 0){
            break;
        }

        solve(w, h);
    }

    return 0;
}



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

typedef long long int ll;
typedef unsigned long long int ull;

#define REP(i, n) for (ll i = 0; i < n; i++)

using namespace std;

int main()
{
  int p, q, r;
  cin >> p >> q >> r;
  int m = max(p, max(q, r));

  cout << p + q + r - m << endl;

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<math.h>
#include<bitset>
#include<random>
using namespace std;
using ll = __int64_t;
using lll = __int128_t;
typedef pair<ll,ll> P;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
const ll longinf=1ll<<60;
const int inf=(1<<30)-1;
const ll mod=1e9+7;

//II→factorialを計算するrange
const ll MOD = 1e9+7;
const int II = 1e6+5;
 
ll addMod(ll a,ll b){
      return ((a%MOD)+(b%MOD))%MOD;
}
 
ll mulMod(ll a,ll b){
      return ((a%MOD)*(b%MOD))%MOD;
}
 
ll powMod(ll a,ll b){
      if(b==0) return 1;
      else if(b%2==0){
            ll ret=powMod(a,b/2);
            return ((ret%MOD)*(ret%MOD))%MOD;
      }
      else return ((powMod(a,b-1)%MOD)*(a%MOD))%MOD;
}
ll divMod(ll a,ll b){
      return ((a%MOD)*(powMod(b,MOD-2)%MOD))%MOD;
}
 
ll fact[II+1];
ll invfact[II+1];

void calc(){ //main関数内にcalc();を入れること(前計算)
      fact[0]=1;
      invfact[0]=1;
      rep0(i,II){
            fact[i+1]=mulMod(fact[i],i+1);
            invfact[i+1]=divMod(1,fact[i+1]);
      }
}


int main(){
      calc();
      int n;
      cin>>n;
      int a[n];
      rep0(i,n){
            cin>>a[i];
      }
      int cnt[n];
      fill(cnt,cnt+n,0);
      rep0(i,n){
            cnt[a[i]]++;
      }
      bool b=true;
      int d=0;
      rep0(i,n){
            if(cnt[a[i]]==2&&b){
                  d+=i;
                  b=false;
            }
            else if(cnt[a[i]]==2){
                  d+=(n-i);
            }
      }
      rep1(i,n+1){
            ll ans=mulMod(mulMod(fact[n+1],invfact[i]),invfact[n+1-i]);
            ll hosei=0;
            if(i<=d+1){
                  hosei=mulMod(mulMod(fact[d],invfact[i-1]),invfact[d+1-i]);
            }
            cout<<(MOD+ans-hosei)%MOD<<endl;
      }
      return 0;
}


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

int main() {
    int n, d;
    while(cin >> n >> d, n) {
        vector<stack<int>> missiles(n);
        vector<int> sum(n);
        for(int i=0; i<n; ++i) {
            int m;
            cin >> m;
            for(int j=0; j<m; ++j) {
                int c;
                cin >> c;
                missiles[i].push(c);
                sum[i] += c;
            }
        }

        bool ok = true;
        while(!all_of(missiles.begin(), missiles.end(), [](auto const& s) { return s.size() == 0; })) {
            bool update = false;
            for(int i=0; i<n; ++i) {
                if(missiles[i].size() == 0) {
                    continue;
                }
                sum[i] -= missiles[i].top();
                int ma = *max_element(sum.begin(), sum.end());
                int mi = *min_element(sum.begin(), sum.end());
                if(ma - mi <= d) {
                    missiles[i].pop();
                    update = true;
                    break;
                } else {
                    sum[i] += missiles[i].top();
                }
            }
            if(!update && !all_of(missiles.begin(), missiles.end(), [](auto const& s) { return s.size() == 0; })) {
                ok = false;
                break;
            }
        }
        cout << (ok ? "Yes" : "No") << endl;
    }
}


Measured memory_bytes: 3200
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////


int main(){
    
    int n,m;
    cin >> n >> m;
    P((1900 * m + 100 * (n-m)) * pow(2,m));
    return  0;
}


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

void ini() {

}

void Solve() {
    long long a, b;
    cin >> a >> b;
    cout << a * b << endl;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ini();
    Solve();
    return 0;
}


Measured memory_bytes: 3648
#include<cstdio>
using namespace std;
const int N=10010;
int dp[N],n,x,k;
bool can[10];
bool check(int x)
{
	while(x)
	{
		if(can[x%10])
			return 0;
		x/=10;
	}
	return 1;
}
int main()
{
	scanf("%d%d",&n,&k);
	while(k--)
	{
		scanf("%d",&x);
		can[x]=1;
	}
	for(int j=n;; j++)
		if(check(j))
			return 0*printf("%d",j);
}

Measured memory_bytes: 256
import itertools

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

A = [a, b, c, d, e]
ans = 'Yay!'
for i, j in itertools.combinations(A, 2):
    if abs(i - j) > k:
        ans = ':('
        
print(ans)

Measured memory_bytes: 3064
#include <vector>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<n;i++)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a) (a).begin(),(a).end()

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

  int mod = 1e9 + 7;
  int n;
  cin >> n;
  int num = n;
  ll ans = 1;
  vector<int> v(n+1);
  while(num > 1){
      int tmp = num;
      for(int i = 2; i <= n; i++){
          while(tmp % i == 0){
              v.at(i)++;
              tmp /= i;
          }
      }
      num--;
  }
  for(int i = 2; i <= n; i++){
      ans *= (v.at(i) + 1);
      ans %= mod;
  }
  cout << ans << endl;
}


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

namespace AtTest.Nikkei2019
{
    class C
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            bool[] used = new bool[n];
            var abArray = new long[n][];
            long allSum = 0;
            long[] abSums = new long[n];
            for (int i = 0; i < n; i++)
            {
                long[] ab = ReadLongs();
                allSum += ab[0];
                abSums[i] = ab[0] + ab[1];
            }
            Array.Sort(abSums);
            Array.Reverse(abSums);
            for(int i = 1; i < n; i += 2)
            {
                allSum -= abSums[i];
            }
            Console.WriteLine(allSum);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 21056
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

char A[1005][1005];
int dp[1005][1005];
const int MOD = 1e9+7;

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

    int h,w; cin>>h>>w;
    FOR(r, h)
    FOR(c, w)
    cin>>A[r][c];

    dp[0][0]=1;

    FOR(r, h) {
        FOR(c, w) {
            if(A[r][c]=='#')
                continue;
            dp[r+1][c] += dp[r][c];
            dp[r+1][c] %= MOD;
            dp[r][c+1] += dp[r][c];
            dp[r][c+1] %= MOD;
        }
    }

    cout<<dp[h-1][w-1]<<endl;

    return 0;
}



Measured memory_bytes: 5248
import { readFileSync } from 'fs'

function main(input: string) {
  const [header, ...lines] = input.split('\n')

  lines
    .map((v, i) => {
      const [town, point] = v.split(' ')
      return { id: i + 1, town, point: +point }
    })
    .sort((a, b) => {
      if (a.town !== b.town) {
        return a.town > b.town ? 1 : -1
      }
      return b.point - a.point
    })
    .forEach(({ id }) => {
      console.log(id)
    })
}

main(readFileSync('/dev/stdin', 'utf8').trim())


Measured memory_bytes: 9548
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
int main()
{
    int n;
    int t[100005];
    int sum = 0;
    cin>>n;
    for(int i = 1; i <= n; i++){
        cin>>t[i];
        sum += t[i];
    }
    int m;
    cin>>m;
    for(int i = 1; i <= m; i++){
        int p, x;
        cin>>p>>x;
        cout<<sum-t[p]+x<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, ll> Pil;

int A, B, C, K;

int main() {
    cin >> A >> B >> C >> K;
    
    int ans = 0;
    if (A >= K) ans = K;
    else {
        if (A + B >= K) ans = A;
        else ans = A - (K - A - B);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3568
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
mn=abs(A-(T-H[0]*0.006))
c=0
for i in range(N):
    if mn>abs(A-(T-H[i]*0.006)):
        mn=abs(A-(T-H[i]*0.006))
        c=i
print(c+1)

Measured memory_bytes: 9280
#include <bits/stdc++.h>
//typedef pair<int,int> pii;
using namespace std;


int main(){
    int n,m;
    cin >> n >> m;
    vector<int64_t> h(n);
//    vector<vector<int>> root(n,vector<int>(n,0));
    vector<queue<int>> root(n);
    for(int ix=0;ix<n;ix++) cin >> h.at(ix);
    for(int ix=0;ix<m;ix++){
        int a,b; cin >> a >> b; a--; b--;
        root.at(a).push(b); root.at(b).push(a);
//        root.at(a).at(b) = root.at(b).at(a) = 1;
    }
    int cnt=0;
    for(int ix=0;ix<n;ix++){
        int64_t v = h.at(ix); bool can=true;
        while(!root.at(ix).empty()){
            int64_t a=root.at(ix).front(); root.at(ix).pop();
            if(h.at(a) >= v) can = false;
            if(can == false) break;
        }
//        
        if(can) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 71632
n,m=map(int,input().split())
denk=[]
for _ in range(m):
  s=list(map(int,input().split()))
  denk.append(s[1:])
amari=list(map(int,input().split()))

ans=0


for i in range(2**n):
  kara=[]
  check=0
  for j in range(n):
    if (i>>j)&1:
      kara.append(j+1)
  for q in range(m):
    kari=denk[q]
    kyoutuu=set(kari)&set(kara)
    aa=len(kyoutuu)%2
    if aa==amari[q]:
      check+=1
  if check==m:
    ans+=1
    
print(ans)
      

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

using namespace std;
struct ct
{
    string s;
    int score;
    int ma;
   bool operator < (struct ct x)
    {
        if(s!=x.s)
            return x.s>s;
        else
            return x.score<score;
    }
} a[200];

int main()
{
    int i,n;
    cin>>n;
    for(i=1; i<=n; i++)
    {
        cin>>a[i].s>>a[i].score;
        a[i].ma=i;
    }
    sort(a+1,a+1+n);
    for(i=1; i<=n; i++)
        cout<<a[i].ma<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define mp make_pair
#define si short int
#define speed ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define pill pair<ll,ll>
#define f first
#define s second
#define pilc pair<ll,char>
#define all(a) (a).begin(),(a).end()
#define rep(s,e,step) for(int i = (s); i < (e) ; i += step)
#define vrep(s,e,step) for(int j = (s); j < (e) ; j += step)
#define ex exit(0) 
#define sz(a) (a).size()
#define triple pair<pill, ll>
#define pinode pair<node*, node*>
#define quadra pair<pill, pill>
using namespace std;
 
/*
 tips :
 Sqrt opt
 Binary search
 Try to find the easiest solution
 Recursiya
 FUCK YOU pishi kod akuratnee daun yobani
 sdohni v adu nahui blyat' y ub'uy tebya
 esli ti blyad' budesh pisat' kod gryaznim
 to ya tebya v rot viebu
*/
 
const ll N = 1E6 + 10;
const ll M = 3e3 + 10;
const ll big = 1e18;
const ll shift = 1000;
const ll block = 500;
const ll has = 200123140004043;

const ll mod = 998244353;

mt19937 srnd(chrono::steady_clock::now().time_since_epoch().count()); 

ll n;
ll p[N];
int main() {
    speed;
	cin >> n;
	ll ans = 0;
	for(int i = 1; i < n; i++) {
		for(int j = i; j < n; j += i)
			p[j]++;
		ans += p[i];
	}
	cout << ans;
}             
                     
 
/*
6 0
1 2 4 6 8 10
1 4  d
*/ 

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

using namespace std;
typedef long long ll;

int main() {
    int n, x;
    cin >> n;
    vector<int> a;
    for (int i = 0; i < n; i++) {
        cin >> x;
        if (a.empty()) {
            a.push_back(x);
            continue;
        }
        if (a.size() % 2) {
            // max
            if (x < a[a.size() - 1]) a[a.size() - 1] = x;
            else if (x > a[a.size() - 1]) a.push_back(x);
        } else {
            // min
            if (x > a[a.size() - 1]) a[a.size() - 1] = x;
            else if (x < a[a.size() - 1]) a.push_back(x);
        }
    }
    ll cash = 1000, stock = 0;
    for (int i = 0; i + 1 < a.size(); i += 2) {
        stock = cash / a[i];
        cash = cash % a[i];
        cash += stock * a[i + 1];
    }
    cout << cash << "\n";
}


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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
  is >> p.first >> p.second;
  return is;
}
template <typename T> void printvv(const vector<vector<T>> &v) {
  cerr << endl;
  rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
    if (typeid(v[i][j]) == typeid(INF) and v[i][j] == INF) {
      cerr << "INF";
    } else
      cerr << v[i][j];
    cerr << (j == v[i].size() - 1 ? '\n' : ' ');
  }
  cerr << endl;
}
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
    if ('0' <= s[i] && s[i] <= '9')
      ret = 10 * ret + s[i] - '0';
  return ret;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  vector<vector<int>> v(111, vector<int>(111, -1));
  vector<int> x(N), y(N), h(N);
  rep(i, 0, N) {
    cin >> x[i] >> y[i] >> h[i];
    v[x[i]][y[i]] = h[i];
  }
  int l = max(*min_element(all(h)) - 200, 0);
  int r = *max_element(all(h)) + 200;
  rep(i, 0, 101) rep(j, 0, 101) for (int k = l; k <= r; k++) {
    bool f = true;
    rep(l, 0, N) {
      f &= (max(k - abs(i - x[l]) - abs(j - y[l]), 0) == h[l]);
//      dump(max(k - abs(i - x[l]) - abs(j - y[l]), 0), h[l]);
    }
    if (f) {
      cout << i << " " << j << " " << k << endl;
      // return 0;
    }
  }

  return 0;
}


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

using ull = unsigned long long;
using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;
const int inf = INT_MAX;
const int N = 2e5 + 5;

int n, a[N], b[N], cnt1[N], cnt2[N], bad[N];

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

    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i], cnt1[a[i]]++;
    for (int i = 1; i <= n; i++) cin >> b[i], cnt2[b[i]]++;

    for (int i = 1; i <= n; i++) {
        int pos1 = lower_bound(a, a + n, b[i]) - a, pos2 = pos1 + cnt1[b[i]] - 1;
        if (pos1 <= i and i <= pos2) {
            bad[0]++;
            bad[pos2 - i + 1]--;
            bad[n - (i - pos1)]++;
        } else if (i < pos1) {
            bad[pos1 - i]++;
            bad[pos2 - i + 1]--;
        } else {
            bad[n - (i - pos1)]++;
            bad[n - (i - pos2) + 1]--;
        }
    }

    int rot = -1;
    for (int i = 1; i <= n; i++) {
        bad[i] += bad[i - 1];
    }

    for (int i = 0; i < n; i++) {
        if (!bad[i]) {
            rot = i;
            break;
        }
    }

    if (rot == -1) {
        cout << "No\n";
        return 0;
    }

    if (rot != 0)
        rotate(b + 1, b + n + 1 - rot, b + n + 1);

    cout << "Yes\n";
    for (int i = 1; i <= n; i++) cout << b[i] << " \n"[i == n];
    return 0;
}

Measured memory_bytes: 7464
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

int main()
{
	int N;
	cin >> N;
	vector<int> A(N);
	map<int, int> cnt;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		cnt[A[i]] += 1;
	}
	vector<int> all;
	for (auto p : cnt) {
		all.emplace_back(p.second);
	}
	sort(all.begin(), all.end());
	int K = all.size();
	vector<int> sum(K + 1);
	for (int i = 0; i < K; i++) {
		sum[i + 1] = sum[i] + all[i];
	}
	for (int i = 1; i <= N; i++) {
		int lb = 0, ub = N / i + 1;
		while (ub - lb > 1) {
			int m = (lb + ub) / 2;
			int p = lower_bound(all.begin(), all.end(), m) - all.begin();
			(sum[p] + (K - p) * m < m * i ? ub : lb) = m;
		}
		printf("%d\n", lb);
	}
	return 0;
}


Measured memory_bytes: 17904
/**
  @date Time-stamp: <2019-05-25 23:40:38 tagashira>
  @file c.cpp
  @title C - Prison
  @brief https://atcoder.jp/contests/abc127/tasks/abc127_c
**/

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <sstream> // std::ostringstream
#include <string>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
  uint N, M;
  cin >> N >> M;
  vector<uint> L(M, 0);
  vector<uint> R(M, 0);

  for (uint i = 0; i < M; i++) {
    cin >> L[i] >> R[i];
  }

  uint maxL = *max_element(L.begin(), L.end());
  uint minR = *min_element(R.begin(), R.end());

  int ans = minR - maxL + 1;
  if (ans >= 0) {
    cout << ans << endl;
  } else {
    cout << "0" << endl;
  }

  return 0;
}


Measured memory_bytes: 1024
use std::cmp::min;

// knapsack-2.rs --- Knapsack-2
// author: Seong Yong-ju <sei40kr@gmail.com>

// tanakah's input macro
// cf https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
        n: usize,
        w_max: u64,
        items: [(u64, u64); n],
    }

    let mut dp = vec![1_000_000_001; 100_001];
    dp[0] = 0;

    for (w, v) in items.into_iter() {
        for j in (0..100_001).rev() {
            if v <= j as u64 {
                dp[j] = min(dp[j], dp[j - v as usize] + w)
            }
        }
    }

    let ans = dp
        .iter()
        .enumerate()
        .filter(|&(_, &w)| w <= w_max)
        .map(|(v, _)| v)
        .max()
        .unwrap();
    println!("{}", ans);
}


Measured memory_bytes: 4476
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String args[]) {
        Scanner input=new Scanner(System.in);
        int n=input.nextInt();
        int k=input.nextInt();
        int cost[]=new int[n];
        for(int i=0;i<n;i++) {
            cost[i]=input.nextInt();
        }
        System.out.println(solve(n,k,cost));
    }
    public static int solve(int n,int k,int[] cost) {
        int dp[]=new int[n];
        dp[1]=Math.abs(cost[0]-cost[1]);
        for(int i=2;i<n;i++) {
            dp[i]=Integer.MAX_VALUE;
            for(int j=1;j<=Math.min(i,k);j++) {
                dp[i]=Math.min(dp[i],dp[i-j]+Math.abs(cost[i]-cost[i-j]));
            }
        }
        return dp[n-1];
    }
}


Measured memory_bytes: 51108
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
const long long MOD =1000000000+7;

int main()
{
	string s;
	long long shortd=0;
	long long ans=0;
	cin >>s;
	// o o o o o o o o o o
	for(long long bit =0;bit <(1<< s.size());bit++){
		for(int i=0; i<s.size();i++){
			if(bit & (1<<i)){
				ans+=shortd;
				shortd=0;
			}else{
				shortd=shortd*10+int(s[i]-'0');
			}
		}
		ans+=shortd;
		shortd=0;
	}
	cout << ans<<endl;;
}


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

using namespace std;

const int MAXN = 1E5;
const int BIAS = MAXN + 2;
int a[MAXN + 1];
int pre[MAXN + 1];
int bit[MAXN + BIAS + 1];

void inc(int pos, int amt)
{
    while (pos <= MAXN + BIAS)
    {
        bit[pos] += amt;
        pos += pos & -pos;
    }
}

int query(int pos)
{
    int ans = 0;
    while (pos > 0)
    {
        ans += bit[pos];
        pos -= pos & -pos;
    }
    return ans;
}

bool check(int n, int x)
{
    fill(bit, bit + MAXN + BIAS + 1, 0);
    long long pairs = 0;
    inc(BIAS, 1);
    for (int i = 1; i <= n; i++)
    {
        pre[i] = pre[i - 1];
        if (a[i] <= x)
            pre[i]++;
        else
            pre[i]--;
        pairs += query(pre[i] - 1 + BIAS);
        inc(pre[i] + BIAS, 1);
    }
    return pairs > (long long) n * (n + 1) / 2 - pairs;
}

int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    int ans = 0;
    for (int jump = 1E9; jump > 0; jump /= 2)
    {
        while (ans + jump <= 1E9 && !check(n, ans + jump))
            ans += jump;
    }
    cout << ans + 1 << endl;
    return 0;
}


Measured memory_bytes: 1792
n = int(input())
s = [input() for i in range(n)]
march = [0,0,0,0,0]
for i in range(n):
    if s[i][0:1] == "M":
        march[0] += 1
    elif s[i][0:1] == "A":
        march[1] += 1
    elif s[i][0:1] == "R":
        march[2] += 1
    elif s[i][0:1] == "C":
        march[3] += 1
    elif s[i][0:1] == "H":
        march[4] += 1

ans = 0
ans += march[0]*march[1]*march[2]
ans += march[0]*march[1]*march[3]
ans += march[0]*march[1]*march[4]
ans += march[0]*march[2]*march[3]
ans += march[0]*march[2]*march[4]
ans += march[0]*march[3]*march[4]
ans += march[1]*march[2]*march[3]
ans += march[1]*march[2]*march[4]
ans += march[1]*march[3]*march[4]
ans += march[2]*march[3]*march[4]
print(ans)

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

int main(){
    int a, b;
    cin >> a >> b;

    if(a==b){
        cout << "Draw" << endl;
    } else if(a==1 || b==1) {
        if(a==1){
            cout << "Alice" << endl;
        } else {
            cout << "Bob" << endl;
        }
    } else if(a>b){
        cout << "Alice" << endl;
    } else {
        cout << "Bob" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 3620
function main(input) {
  var temp = input.split('\n');
  var foo = temp[0].split(' ');
  var h = parseInt(foo[0]);
  var w = parseInt(foo[1]);

  temp.shift();
  var arr = [];
  for (var i = 0; i < h; i++) {
    arr[i] = temp[i].split(' ').map(Number);
  }
  var c = [];
  for (var j = 0; j < (temp.length - h - 1); j ++) {
    c.push(parseInt(temp[(j+h)]));
  }
  for (var k = 0; k < arr.length; k++) {
    var line = 0;
    for (var l = 0; l < w; l++) {
      line += arr[k][l]*c[l];
    }
    console.log(line);
  }  
}

var x = require('fs').readFileSync('/dev/stdin', 'utf-8');
main(x);


Measured memory_bytes: 17440
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,d[60],t[20]={},now[30]={},ans=0;
    vll v;
    cin>>n;
    map<ll,ll> mp;
    mp[0]++;
    rep(i,n){
        cin>>d[i];
        mp[d[i]]++;
        t[d[i]]++;
    }
    rep(i,13){
        if((i==0||i==12)&&mp[i]>=2){
            cout<<0<<endl;
            return 0;
        }
        else if(mp[i]>=3){
            cout<<0<<endl;
            return 0;
        }
    }
    now[0]=1;
    rep2(i,1,12){
        if(mp[i]==2){
            now[i]++;
            now[24-i]++;
        }
        else if(mp[i]==1){
            v.push_back(i);
        }
    }
    if(mp[12]) now[12]++;
    rep(bit,(1<<(v.size()))){
        ll now2[30];
        rep(i,24){
            now2[i]=now[i];
        }
        rep(i,v.size()){
            if(bit&(1<<i)){
                now2[v[i]]++;
            } else{
                now2[24-v[i]]++;
            }
        }
        ll fi=0,en=0,ans0=30,bef=0;
        rep2(i,1,24){
            if(now2[i]){
                en=i;
                if(i!=bef)ans0=min(ans0,i-bef);
                bef=i;
            }
        }
        if(en!=0)ans0=min(fi+24-en,ans0);
        ans=max(ans,ans0);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N,D = gets.chomp.split.map(&:to_i)
X = N.times.map{gets.split.map(&:to_i)}

ans = 0

(0..N-1).each do |i|
  if (X[i][0]**2+X[i][1]**2)<=D**2
    ans += 1
  end
end

puts ans

Measured memory_bytes: 28344
n = int(input())
mx = 55555
ans = []
primes = [2]
for i in range(3, mx + 1, 2):
    if all(i % p != 0 for p in primes):
        primes.append(i)
        if i % 5 == 1:
            ans.append(i)
        if len(ans) == n:
            break
print(*ans)


Measured memory_bytes: 2940