akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {

		//?????£?????????
		int numN = 0;
		int i = 0;

		//????????¨????????°
		String outputNum = "";

		String[] NumList;

		try {
			//??\????????????
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String line = br.readLine();

			numN = Integer.parseInt(line);

			//????????????
			line = br.readLine();

			if (line != null) {

				//??°??£?????´??°?????????
				NumList = line.split(" ", 0);
				//System.out.println(numN );

				int Count = numN - 1;
				for (i = 0; i < NumList.length;i++) {
					
					//???????????????????????????
					if(Count != numN - 1){
						outputNum += " ";
					}
					outputNum += NumList[Count];
					Count--;
				}
				System.out.println(outputNum);
			}
		} catch (NumberFormatException e) {
			System.out.println(e);
		}catch (IOException e) {
			System.out.println(e);
		}

	}

}

Measured memory_bytes: 24404
// ABC 050 A- Addition and Subtraction Easy

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

int main() {
  int A, B;
  char op;

  cin >> A >> op >> B;
  if (op == '+') {
    cout << A + B << endl;
  }
  else {
    cout << A - B << endl;
  }
}


Measured memory_bytes: 3600
from collections import defaultdict

S = input()
d = defaultdict(int)
for s in S:
    d[s] += 1

ret = 'No'
#print(d)
if len(d) == 2:
    for dd in d.values():
        #print(dd)
        if dd == 2:
            ret = 'Yes'
            break

print(ret)

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

const ll mod = 998244353;
struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    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;
    }

    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;
    }
};

struct combination {
    vector<mint> fact, ifact;
    // init struct with "n" of "nCk" (maximum number in other words)
    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;
    }
    // c(n,k) returns mint that contains nCk (mod p (= 1e9+7)) in x
    // i.e.) mint num = c(n,k), then num.x == nCk (mod p (= 1e9+7))
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }

    // nPk - permutation
    mint p(int n, int k) {
        return fact[n] * ifact[n - k];
    }
};


int main() {
    ll n, a, b, k;
    cin >> n >> a >> b >> k;
    
    mint ans;
    combination nck(n);
    rep(i, n + 1) {
        ll rest = k - i * a;
        if (rest < 0) break;
        if (rest % b != 0) continue;
        ll j = rest / b;

        ans += nck(n, i) * nck(n, j);
    }
    cout << ans.x << endl;
}


Measured memory_bytes: 7996
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNextInt()) {
			int n = sc.nextInt();
			int c = 0;
			boolean[] p = new boolean[n+1];
			for (int i = 0; i <= n; i++) {
				p[i] = true;
			}
			int l = Double.valueOf(Math.sqrt((double)n)).intValue()+1;
			for (int i = 2; i <= l; i++) {
				for (int j = i*2; j <= n; j+=i) {
					p[j] = false;
				}
			}
			for (int i = 2; i <= n; i++) {
				if(p[i]){
					c++;
				}
			}
			System.out.println(c);
		}
	}
}

Measured memory_bytes: 16000
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 300005
#define inf 0x3f3f3f3f
void Read(int &p)
{
	p = 0;
	char c = getchar();
	for (; c < '0' || c > '9'; c = getchar());
	for (; c >= '0' && c <= '9'; c = getchar())p = p * 10 + c - '0';
}
int n, A[N], S[N], s1, s2;
int main()
{
	Read(n);
	for (int i = 1; i <= n; i++)
	{
		Read(A[i]);
		if (i & 1)
			s1 += A[i], S[i] = S[i - 1] + A[i];
		else
			s2 += A[i], S[i] = S[i - 1] - A[i];
	}
	if (n & 1)
	{
		int l = 1, r = inf;
		while (l < r)
		{
			int mid = (l + r + 1) >> 1;
			int now = 0;
			for (int i = 1; i < n; i += 2)
				if (S[i] - now >= mid)
					now = min(now, S[i + 1]);
			if (S[n] - now >= mid)
				l = mid;
			else
				r = mid - 1;
		}
		printf("%d %d\n", s2 + l, s1 - l);
	}
	else
	{
		printf("%d %d\n", max(s1, s2), min(s1, s2));
		return 0;
	}
}


Measured memory_bytes: 2560
#include<iostream>
#include<ctime>
#include<vector>
#include<iomanip>

using namespace std;

int main()
{
	string str;
	cin >> str;

	int total = 0;

	for (int i = 0; i < str.size(); i++)
	{
		total += (str[i] - '0');
	}

	cout << ((total % 9 == 0) ? "Yes" : "No") << endl;

	return 0;
}

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

using namespace std;


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<int, int> mp;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    ans += mp[i - x];
    mp[i + x]++;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 20680
#include <cstdio>
#include <vector>
#include <queue>
using namespace std;

vector<int> con[2010];
int par[2010];

queue<int> q;
int dist[2010];

int main(){
  int N, K; scanf("%d%d", &N, &K);
  for(int i = 0; i < N - 1; i++){
    int x, y; scanf("%d%d", &x, &y);
    con[x].push_back(y);
    con[y].push_back(x);
  }

  par[1] = 1; q.push(1);
  while(!q.empty()){
    int x = q.front(); q.pop();
    for(int nx : con[x]){
      if(nx != par[x]){ par[nx] = x; q.push(nx); }
    }
  }

  int ans = N;

  for(int i = 1; i <= N; i++){ // center
    for(int j = 1; j <= N; j++) dist[j] = N;

    int cov = 0;

    dist[i] = 0; q.push(i); cov++;
    if(K % 2 == 1 && par[i] != i){
      dist[par[i]] = 0; q.push(par[i]); cov++;
    }

    while(!q.empty()){
      int x = q.front(); q.pop();
      int nd = dist[x] + 1;
      for(int nx : con[x]){
        if(nd < dist[nx]){
          dist[nx] = nd; q.push(nx);
          if(nd <= K / 2) cov++;
        }
      }
    }

    // printf("%d : %d\n", i, cov);

    int res = N - cov;
    if(res < ans) ans = res;
  }

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

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;


void solve(){
  int n,ma,mb;
  cin>>n>>ma>>mb;
  vector<int>a(n),b(n),c(n);
  int ans=1e5;
  rep(i,n){
    cin>>a[i]>>b[i]>>c[i];
  }
  int x=(n+1)/2;
  vector<pair<int,int>>v;
  for(int bit=0;bit<(1<<x);++bit){
    int suma=0,sumb=0,sumc=0;
    rep(i,x){
      if(bit&(1<<i)){
        suma+=a[i];
        sumb+=b[i];
        sumc+=c[i];
      }
    }
    v.eb(ma*sumb-mb*suma,sumc);
  }
  sort(v.begin(),v.end());
  //for(auto e:v)cout<<e.first<<" "<<e.second<<"\n";
  int y=n-x;
  for(int bit=0;bit<(1<<y);++bit){
    int suma=0,sumb=0,sumc=0;
    rep(i,y){
      if(bit&(1<<i)){
        suma+=a[x+i];
        sumb+=b[x+i];
        sumc+=c[x+i];
      }
    }
    int lb=lower_bound(v.begin(),v.end(),make_pair(mb*suma-ma*sumb,-1))-v.begin();
    int ub=upper_bound(v.begin(),v.end(),make_pair(mb*suma-ma*sumb,100000))-v.begin();
    for(int i=lb;i<ub;++i){
      //cout<<v[i].second<<"\n";
      if(sumc+v[i].second!=0){
        chmin(ans,sumc+v[i].second);
        break;
      }
    }
  }
  if(ans!=1e5)cout<<ans;
  else cout<<-1;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


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

long long int gcd(long long int a,long long int b)
{
	if(b==0)
	{
		return a;
	}
	return gcd(b,a%b);
}

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

	int n;
	long long int t;
	vector <long long int> a;

	cin >> n;

	for(int i=0;i<n;i++)
	{
		cin >> t;
		a.push_back(t);
	}

	long double res = (1.0)/a[0];
	for(int i=1;i<n;i++)
	{
		res += ((1.0)/a[i]);
	}

	cout << 1.0/res << '\n';

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#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>
#include <random>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#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 fi first
#define sc second
#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 LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 510000;
const double pi = acos(-1);
const double eps = 1e-9;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,ans=1,a[100010],M=-1;
    cin>>n;
    map<ll, ll> mp;
    rep(i,n){
        cin>>a[i];
        mp[a[i]]++;
        M=max(M,a[i]);
    }
    if(a[0]!=0) ans=0;
    rep(i,M+1){
        if(mp[i]==0||mp[0]>1){
            cout<<0<<endl;
            return 0;
        }
        if(i==0) continue;
        ll a=1;
        rep(j,mp[i]){
            a*=mp[i-1];
            a%=998244353;
        }
        ans*=a;
        ans%=998244353;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7296
#include <iostream>
using namespace std;
 
 int main (){
     int a,b;
     cin >> a >> b;
     if (a<b){
         cout << "a < b" << endl;
     }else if (a>b){
         cout << "a > b" << endl;
     }else if ( a==b){
         cout << "a == b" << endl;
     }
 }


Measured memory_bytes: 3080
N=int(input())
strings=sorted([sorted(list(input())) for i in range(N)])
strings.append("000")
cnt=0
i=0
same=1
while i<N:
    if strings[i]==strings[i+1]:
        same+=1
    else:
        cnt+=same*(same-1)/2
        same=1
    i+=1
print(int(cnt))

Measured memory_bytes: 99544
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}





int main() {

	ll N, A, B;
	cin >> N >> A >> B;
	if ((A - B) % 2 == 0) {
		cout << (B - A) / 2 << endl;
	}
	else {
		cout << min(A - 1, N - B) + (B - A + 1) / 2 << endl;
	}


}

Measured memory_bytes: 256
/*
	Author      : akgarhwal
	Date        : 16-04-2017 12:20:42
	Description : 
*/

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

typedef long long 			ll;
typedef vector<int> 		vi; 
typedef pair<int,int> 		ii; 
#define sz(a) 				int((a).size()) 
#define pb 					push_back 
#define all(c) 				(c).begin(),(c).end() 
#define tr(c,i) 			for(auto i = (c).begin(); i != (c).end(); i++) 
#define present(c,x) 		((c).find(x) != (c).end()) 
#define cpresent(c,x) 		(find(all(c),x) != (c).end())  

int F(ll A,ll B){

	int da = 0;
	while(A){
		da++;
		A = A/10;
	}
	int db = 0;
	while(B){
		db++;
		B = B/10;
	}
	
	return max(da,db);

}


int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	ll n;
	cin>>n;
	int ans=INT_MAX;
	for(ll i=1; i*i<=n ; i++){
		if(n%i!=0){
			continue;
		}

		ll B = n/i;
		

		ans = min(ans,F(i,B));


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

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

using namespace std;

int N, K, buff, ans=0;
vector<int> vec;

int main(){
    cin >> N >> K;

    for(int i = 0; i < N; i++){
        cin >> buff;
        vec.push_back(buff);
    }
    
    sort(vec.begin(), vec.end());
    reverse(vec.begin(), vec.end());

    for(int i = 0; i < K; i++) ans += vec[i];

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int gcd(int x, int y){
  if(y == 0){
    return x;
  }
  else{
    gcd(y, x % y);
  }
}

int main(void){
  int a, b, c, temp;

  scanf("%d", &a);
  scanf("%d", &b);

  if(a < b){
    temp = a;
    a = b;
    b = temp;
  }

  c = gcd(a, b);
  printf("%d\n", c);

  return 0;
}

Measured memory_bytes: 592
<?php
fscanf(STDIN, "%d", $A);
while(TRUE){
    $limit = ceil(sqrt($A));
    $flg = true;
    for($i=2;$i<$limit; $i++){
        if($A % $i == 0){
            $flg = false;
            break;
        }
    }
    if($flg){
        break;
    }
    $A++;
}
echo $A;
?>

Measured memory_bytes: 4604
import sys
k, a, b = map(int, input().split())
if b - a < 2:
    print(k + 1)
    sys.exit(0)

count = a
k -= (a - 1)
if k % 2 == 1:
    count += 1
    k -= 1
count += (b - a) * (k // 2)
print(count)

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

#define int long long

using namespace std;

#define N 100005
#define inf 1e18


int ans[105][N];



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

        int n, w1;
        cin>>n>>w1;

        vector < int > w(n),v(n);
        for(int i=0;i<n;i++)
                cin>>w[i]>>v[i];

        for(int i=0;i<n;i++)
                for(int j=0;j<N;j++)
                        ans[i][j]=inf;

        ans[0][v[0]]=w[0];
        ans[0][0]=0;
        for(int i=1;i<n;i++)
        {
                for(int j=0;j<N;j++)
                {
                        ans[i][j]=ans[i-1][j];
                        if(j>=v[i])
                                ans[i][j]=min(ans[i][j],ans[i-1][j-v[i]]+w[i]);
                }
        }
        
        for(int i=N-1;i>=0;i--)
        {
                if(ans[n-1][i]<=w1)
                {
                        cout<<i<<endl;
                        return 0;
                }
        }

        return 0;

}



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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	int n; read(n);
	vector<int> v(n + 1);
	rep(i, 1, n + 1) read(v[i]);
	int a = 0;
	rep(i, 1, n + 1) if (i % 2 == 1 && v[i] % 2 == 1) a++;
	write(a);
}


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

//#define int long long

#define INF 1e+10
#define MAX_V 10


// <最短距離, 頂点の番号>
using P = pair<long double, int>;



signed main(){
    long double xs, ys, xt, yt;
      long double t = 0;
    int n;
    cin >> xs >> ys >> xt >>yt>>n;
    long double x[n+2],y[n+2],r[n+2];
    x[0]=xs;y[0]=ys;r[0]=0;x[n+1]=xt;y[n+1]=yt;r[n+1]=0;
    for(int i=1;i<=n;i++){
        cin >> x[i] >> y[i] >> r[i];
    }
    long double G[n+2][n+2];
    for(int i=0;i<n+2;i++){
        for(int j=0;j<n+2;j++){
          
            G[i][j]=max(t,(sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i] - y[j])* (y[i] - y[j])) - r[i] -r[j]));
        }
    }
    long double d[n+2];
        priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+n+2, INF);
    d[0] = 0;
    que.push(P(0, 0));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<n+2; i++) {
            long double e = G[v][i];
            if (d[i] > d[v] + e) {
                d[i] = d[v] + e;
                que.push(P(d[i], i));
            }
        }
    }
    printf("%.10Lf\n", d[n+1]);
    return 0;


}

Measured memory_bytes: 25068
#include<set>  
#include<map>  
#include<stack>  
#include<cmath>  
#include<cstdio>  
#include<queue>  
#include<vector>  
#include<climits>  
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;     
int read(){     
    int f=1,x=0;char c=getchar();        
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}       
    while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();     
    return x*f;    
}
#define MAXN 400
#define INF 0x3f3f3f3f
int H,W,dx[4]={0,0,1,-1},dy[4]={1,-1,0,0};
LL Ans,cnt1,cnt2;
bool vis[MAXN+5][MAXN+5];
char Map[MAXN+5][MAXN+5];
void BFS(int X,int Y){
	cnt1=0,cnt2=0;
	queue<pair<int,int> > Q;
	Q.push(make_pair(X,Y)),vis[X][Y]=1;
	while(!Q.empty()){
		int nx=Q.front().first,ny=Q.front().second;
		Q.pop();
		if(Map[nx][ny]=='.') cnt1++;
		else cnt2++;
		for(int i=0;i<4;i++){
			int x=nx+dx[i],y=ny+dy[i];
			if(x<1||y<1||x>H||y>W||vis[x][y]||Map[x][y]==Map[nx][ny]) continue;
			vis[x][y]=1,Q.push(make_pair(x,y));
		}
	}
	Ans+=cnt1*cnt2;
	return ;
}
int main(){
	H=read(),W=read();
	for(int i=1;i<=H;i++)
		scanf("%s",Map[i]+1);
	for(int i=1;i<=H;i++)
		for(int j=1;j<=W;j++)
			if(!vis[i][j]&&Map[i][j]=='.')
				BFS(i,j);
	cout<<Ans<<endl;
    return 0;
}


Measured memory_bytes: 512
# D問題とほぼ同じだが計算量が問題になる．
# 前回と違い重さの制約が，W<10^9なので，重さのノードを作ってしまうと，計算量がどう仕様もなくなる
# なので，価値に対してノードを作ってあげて，最小の重さを計算するようにする

N, W_max = map(int, input().split())

W = []
V = []

for i in range(N):
    w,v = map(int,input().split())
    W.append(w)
    V.append(v)
# dp[v][i] := 商品iまで選択して，価値がv以下となった場合について，最小の重さ
import math
import numpy as np
dp = np.ones((10**3*(N+10))) * np.inf
dp[0] = 0
for v,w in zip(V,W):
    np.minimum(dp[:-v]+w, dp[v:],out=dp[v:])
print(np.where(dp<=W_max)[0][-1])




Measured memory_bytes: 14168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    ll n, cur, res = 0, cur_max = 0;
    cin >> n;

    for(int i = 0; i < n; ++i)
    {
        cin >> cur;
        cur_max = max(cur_max, cur);

        res += cur_max - cur;
    }

    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>
#include <functional>
#include <map>
#include <cstdlib>
#include <iomanip>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    const double pi = atan(1) * 4;
    double A, B, H, M;
    cin >> A >> B >> H >> M;
    double t1 = pi * (H / 6.0 + M / 360.0);
    double t2 = pi * M / 30.0;
    double d = A * B * (cos(t1)*cos(t2) + sin(t1)*sin(t2));

    printf("%.20f\n", sqrt(A*A + B*B - 2*d));
}

Measured memory_bytes: 4152
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 400010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int n;
vector<int> h(100);
int water(int l,int r){
    int res = 100;
    int index = -1;
    if (r-l == 1) return h[l];
    if (l >= r) return 0;
    rep(i,l,r){
        if (h[i] < res){
            index = i;
            res = h[i];
        }
    }
    rep(i,l,r) h[i] -= res;
    return water(l,index)+res+water(index+1,r);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i,n) cin >> h[i];
    PRINT(water(0,n));
}


Measured memory_bytes: 256
def C_ExceptionHandling():
    N = int(input())
    A = [int(input()) for x in range(N)]
    a_left = [0] * (N + 1)
    a_right = [0] * (N + 1)
    for x in range(N):
        a_left[x+1] = max(a_left[x], A[x])
        a_right[-x-2] = max(a_right[-x-1], A[-x-1])
    for x in range(N):
        print(max(a_left[x], a_right[x+1]))
    
if __name__ == "__main__":
    C_ExceptionHandling()

Measured memory_bytes: 15708
x1,y1,x2,y2=map(int,input().split())
x3,x4,y3,y4=0,0,0,0
a=x2-x1
b=y2-y1
x3=x2-b
y3=a+y2
x4=x3-a
y4=y3-b
print(x3,y3,x4,y4)

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

int main(int argc, char const *argv[])
{
	int h, n; cin >> h >> n;
	vector<int> a(n); rep(i, n) cin >> a[i];
	int sum = 0; rep(i, n) sum += a[i];
	cout << (sum >= h ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 640
n = int(input())
a = list(map(int, input().split()))

ans = 0
for aa in a:
    if aa % 2 == 0:
        cnt = 0
        while True:
            if aa % 2 == 0:
                cnt += 1
                aa /= 2
            else:
                break
        ans += cnt


print(ans)


Measured memory_bytes: 4148
/*{{{*/
// think twice code once
// Start:[]
// End  :[]
#include <bits/stdc++.h>
using namespace std;

#define rep(i, x, y) for(int i = (x), _ = (y); i <= _; ++ i)
#define per(i, x, y) for(int i = (x), _ = (y); i >= _; -- i)
#define dprintf(...) fprintf(stderr, __VA_ARGS__)
#define disp(x) cout << #x << " = " << x << "; "
#define x first
#define y second
#define mp make_pair
#ifdef __linux__
#define getchar getchar_unlocked
#define LLFORMAT "%lld"
#else
#define LLFORMAT "%I64d"
#endif

typedef long long LL;

template <class T> bool chkmin(T& a, T b) { return a > b ? a = b, true : false; }
template <class T> bool chkmax(T& a, T b) { return a < b ? a = b, true : false; }

template <class T> void read(T& a) {
	char c = getchar(); T f = 1; a = 0;
	for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
	for(; isdigit(c); c = getchar()) a = a * 10 + c - '0';
	a *= f;
}
/*}}}*/

int N, M;
LL ans;

void work(int N, int M)
{
	rep(i, 1, N)
	{
		LL a = (LL) M * i;
		LL b = (LL) (M / 2) * (N - i);
		LL c = (LL) ((M + 1) / 2) * (N - i);
		if(b == 0 || c == 0) continue;
		//disp(a), disp(b), disp(c), puts("");
		//disp(min(min(abs(a - b), abs(b - c)), abs(a - c))), puts("");
		chkmin(ans, max(max(abs(a - b), abs(b - c)), abs(a - c)));
		b = (LL) ((N - i) / 2) * M;
		c = (LL) ((N - i + 1) / 2) * M;
		chkmin(ans, max(max(abs(a - b), abs(b - c)), abs(a - c)));
	}
}

int main()
{
#ifdef Leeson
	freopen("tmp.in", "r", stdin);
	freopen("tmp.out", "w", stdout);
#endif

	ans = LLONG_MAX;
	read(N), read(M);
	work(N, M);
	work(M, N);
	cout << ans << endl;

	return 0;
}


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


int main(void) {
	int H, W;
	cin >> H >> W;
	string S[60];
	for (int i = 0; i < H; i++) cin >> S[i];

	int A[60][60] = { 0 };
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (S[i][j] == '#') {
				for (int k = 0; k < 3; k++)
				{
					for (int l = 0; l < 3; l++)
					{
						++A[i+k][j+l];
					}
				}
			}
		}
	}
	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			if (S[i][j] == '.') cout << A[i + 1][j + 1];
			else cout << '#';
		}
		cout << endl;
	}

}

Measured memory_bytes: 256
import java.util.*;
import java.math.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static String start, end;
    static int n;
    static long[] Osaki;
    public static void main(String[] args) {
        while(read()){
            print();
        }
    }
    static boolean read(){
        n = sc.nextInt();
        if(n == 0)return false;

        Osaki = new long[216000];
        for(int i = 0; i < n; i++){
            start = sc.next();
            end = sc.next();
            solve();
        }
        return true;
    }
    static void solve(){
        String[] s = start.split(":");
        String[] e = end.split(":");
        int iStart = Integer.parseInt(s[2]) + Integer.parseInt(s[1])*60 + Integer.parseInt(s[0])*3600;
        int iEnd = Integer.parseInt(e[2]) + Integer.parseInt(e[1])*60 + Integer.parseInt(e[0])*3600;
        //System.out.println(iStart + " " + iEnd);
        for(int i = iStart; i < iEnd; i++){
            ++Osaki[i];
        }
    }

    static void print(){
        int max = -1;
        for(int i = 0; i < Osaki.length; i++){
            Math.max(max, Osaki[i]);
        }
        //System.out.println(Osaki[3600]);
        //System.out.println(max);
        Arrays.sort(Osaki);
        System.out.println(Osaki[Osaki.length-1]);
    }
}

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

#define ll long long
#define f(i, x, n) for(int i = x; i < (int)(n); ++i)
#define all(c) (c).begin(), (c).end()
#define speed ios::sync_with_stdio(0); cin.tie(0);

int const N = 2 * 1e5 + 2;
int lcs[3003][3003];

int main(){
    speed
   	string x, y;
   	cin >> x >> y;
   	int sz1 = x.size(), sz2 = y.size();
   	f(i, 0, sz1 + 1){
   		f(j, 0, sz2 + 1){
   			if (j == 0 || i == 0)lcs[i][j] = 0;
   			else if (x[i - 1] == y[j - 1])lcs[i][j] = lcs[i - 1][j - 1] + 1;
   			else lcs[i][j] = max(lcs[i - 1][j], lcs[i][j - 1]);
   		}
   	}
    int i = sz1, j = sz2;
    string ans = "";
    while (i > 0 && j > 0){
    	if (x[i - 1] == y[j - 1]){
    		j--;
    		i--;
    		ans += x[i];
    	} else {
    		if (lcs[i - 1][j] > lcs[i][j - 1])i--; else j--;
    	}
    }
    reverse(all(ans));
    cout << ans << endl;
}

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

long N,K;
long ans=0;
//int tmp[200010]={};

int main(){
  ans=0;
  cin >> N >> K;
  long t=N/K;
  long s=(N+(K/2))/K;
  if(K%2==1){
    ans=t*t*t;
  }
  else{
    for(int a=1;a<=N;a++){
      if(a%K==0){
        ans+=t*t;
      }
      else if(a%K==(K/2)){
        ans+=s*s;
      }
    }

    /*

    for(int a=K/2;a<=N;++a){
    for(int b=K/2;b<=a;++b){
    for(int c=K/2;c<=b;++c){
    if((a+b)%K==0 && (b+c)%K==0 && (a+c)%K==0){
    if(a==b && b==c && c==a){
    ans+=1;
    //tmp[a]+=1;
  }
  else if(a==b || b==c || c==a){
  ans+=3;
  //tmp[a]+=3;
}
else{
ans+=6;
//tmp[a]+=6;
}
}
}
}
}*/

/*for(int i=2;i*K<=N;++i){
ans+=ans;
}*/
}


cout << ans << endl;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!(
    x: usize
    );
    let mut ans = 0;
    ans += x / 500 * 1000;
    let x = x % 500;
    ans += x / 5 * 5;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <string>

int N;
int ABC[3];
std::vector<std::vector<int>> c;
std::string s_buf;
std::string answer;
std::vector<char> choice;

long long SumABC (void) {
  return ABC[0] + ABC[1] + ABC[2];
}

char intToABC (int x) {
  if (x == 0) {
    return 'A';
  } else if (x == 1) {
    return 'B';
  } else {
    return 'C';
  }
}

void solve() {
    for (int i = 0; i < N; i++) {
    std::cin >> s_buf;
    if (s_buf == "AB") {
      c[i][0] = 0;
      c[i][1] = 1;
    } else if (s_buf == "BC") {
      c[i][0] = 1;
      c[i][1] = 2;
    } else {
      c[i][0] = 0;
      c[i][1] = 2;
    }
  }
  for (int i = 0; i < N; i++) {
    if (ABC[c[i][0]] == 0 && ABC[c[i][1]] == 0) {
      answer = "No";
      return;
    } 
    if (ABC[c[i][0]] == 0 && ABC[c[i][1]] > 0) {
      ++ABC[c[i][0]];
      choice[i] = intToABC(c[i][0]);
      --ABC[c[i][1]];
    } else if (ABC[c[i][0]] > 0 && ABC[c[i][1]] == 0) {
      --ABC[c[i][0]];
      ++ABC[c[i][1]];
      choice[i] = intToABC(c[i][1]);
    } else if ((ABC[c[i][0]] == 1 || ABC[c[i][1]] == 1) && i != N-1 && ABC[3-c[i][0]-c[i][1]] == 0 && (c[i+1][0] != c[i][0] || c[i+1][1] != c[i][1])) {
      int next_p, next_m;
      next_p = (c[i][0] == c[i+1][0] || c[i][0] == c[i+1][1]) ? c[i][0] : c[i][1];
      next_m = (c[i][0] == c[i+1][0] || c[i][0] == c[i+1][1]) ? c[i][1] : c[i][0];
      ++ABC[next_p];
      choice[i] = intToABC(next_p);
      --ABC[next_m];
    } else {
      --ABC[c[i][0]];
      ++ABC[c[i][1]];
      choice[i] = intToABC(c[i][1]);
    }
  }
  answer = "Yes";
  return;
}

int main() {
  std::cin >> N >> ABC[0] >> ABC[1] >> ABC[2];
  c.assign(N, std::vector<int>(2, 0));
  choice.assign(N, 'A');
  solve();
  std::cout << answer << std::endl;
  if (answer == "Yes") {
    for (int i = 0; i < N; i++) {
      std::cout << choice[i] << std::endl;
    }
  }
}


Measured memory_bytes: 8804
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
ll n;
vi parent;
vi rankk;
ll root(ll i){
    if(parent[i]==i)return i;
    parent[i]=root(parent[i]);
    return parent[i];
}
void heigou(ll x,ll y){
  x=root(x);y=root(y);
  if(x==y)return;
  if(rankk[x]<rankk[y])parent[x]=y;
  else if(rankk[x]>rankk[y])parent[y]=x;
  else{parent[y]=x;rankk[x]++;}
}
int main(){
    cin>>n;
    parent=vi(n);
    rankk=vi(n);
    rep(i,n)parent[i]=i;
    vi ans(n);
    ll m,k;cin>>m>>k;
    rep(i,m){
        ll a,b;cin>>a>>b;a--;b--;
        heigou(a,b);
        ans[a]--;ans[b]--;
    }
    rep(i,k){
        ll a,b;cin>>a>>b;a--;b--;
        if(root(a)==root(b)){ans[a]--;ans[b]--;}
    }
    vi num(n);
    rep(i,n)num[root(i)]++;
    rep(i,n)ans[i]+=num[root(i)];
    rep(i,n)ans[i]--;
    outv(ans);
}


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

int main(){
  int N;
  cin >>N;
  vector <int> a(N);
  for (int i=0;i<N;i++){
    cin>>a[i];
  }
    for(int k=0;k<N;k++){
      if(k<N-1){
        cout<<a[k]<<" ";
      }
      else cout<<a[k]<<endl;
    }
  for (int i=1;i<N;i++){
    int v=a[i];
    int j=i-1;
    while((j>=0)&&(a[j]>v)){
      a[j+1]=a[j];
      j--;
    }
    a[j+1]=v;
    for(int k=0;k<N;k++){
      if(k<N-1){
        cout<<a[k]<<" ";
      }
      else cout<<a[k]<<endl;
    }
  }
  return 0;
}

  


  
  
  

  

  


  
  
  

  


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 998244353;

long long MODpow(long long a, long long n){
    long long res = 1;
    while(n > 0){
        if(n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

signed main(){
    int n;
    cin >> n;
    int d[n];
    REP(i,n){
        cin >> d[i];
    }
    if(d[0] != 0){
        cout << 0 << endl;
        return 0;
    }
    sort(d, d + n);
    if(d[1] != 1){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1, cnt = 1, pre = 1;
    for(int i = 2; i < n; i++){
        if(d[i - 1] != d[i]){
            if(d[i] - d[i - 1] > 1){
                cout << 0 << endl;
                return 0;
            }else{
                ans *= MODpow(pre, cnt);
                ans %= MOD;
                pre = cnt;
                cnt = 1;
            }
        }else{
            cnt++;
        }
    }
    ans *= MODpow(pre, cnt);
    ans %= MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
int num;
int a,b,c,d;
int counter=0;
while(scanf("%d",&num)!=EOF){
   for(a=0;a<=9;a++)
     for(b=0;b<=9;b++)
	   for(c=0;c<=9;c++)
	     for(d=0;d<=9;d++)
		    if(a+b+c+d==num)
			   counter++;
	printf("%d\n",counter);
	counter=0;                 /*&#35760;得恢&#22797;counter*/
	}
	return 0;
	}

Measured memory_bytes: 596
using System;

namespace ChokudaiScanner
{
    class MainClass
    {
        static void Main()
        {
            Scanner cin = new Scanner();

            int[] A = cin.ArrayInt(3);
            Console.WriteLine("{0} {1} {2}",A[2],A[0],A[1]);
        }
    }
    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public string[] ArrayNext(int N)
        {
            string[] Array = new string[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Next();
            }
            return Array;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextInt() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }
    }
}

Measured memory_bytes: 27200
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string HEX = "0123456789ABCDEF";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")

int main(void) {
    int n,a,b;
    cin >> n >> a >> b;
    cout << ((n*a<b)?n*a:b) << endl;
    return 0;
}


Measured memory_bytes: 256
def Floor_Sum(A,B,N,M,K=0):
    """sum_{i=0}^{N-1} floor((A*i+B)/M) を求める.
    """

    if K!=0:
        return Floor_Sum(A,B,N,M)-Floor_Sum(A,B,K-1,M)

    T=0
    P,A=divmod(A,M)
    R,B=divmod(B,M)

    T=P*((N*(N-1))//2)+R*N

    y_max=(A*N+B)//M
    x_max=y_max*M-B

    if y_max==0:
        return T

    T+=(N-(x_max+A-1)//A)*y_max
    T+=Floor_Sum(M, (A-x_max%A)%A, y_max, A)

    return T
#================================================
Q=int(input())
X=[0]*Q
for i in range(Q):
    N,M,A,B=map(int,input().split())
    X[i]=Floor_Sum(A,B,N,M)
print("\n".join(map(str,X)))

Measured memory_bytes: 87460
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 5000
#define MOD 1000000007

long long modpow(long long a,long long n,long long mod){
  long long res=1;
  while(n>0){
    if(n&1){       //nのbitと...00001を比較  nが2で割り切れるならtrue
      res=(res*a)%mod;
    }
    a=(a*a)%mod;
    n>>=1;
  }
  return res;
}

long long modinv(long long a,long long mod){
  return modpow(a,mod-2,mod);
}

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

void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<MAX;i++){
    fac[i]=(fac[i-1]*i)%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

long long COM(int n,int k){
  if(n<k){
    return 0;
  }
  if(n<0||k<0){
    return 0;
  }
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
  int N,K;
  cin>>N>>K;
  COMinit();


  for(int i=1;i<=K;i++){
    if(i>N-K+1){
      cout<<0<<endl;
      continue;
    }
    if(i==1){
      cout<<N-K+1<<endl;
      continue;
    }
    if(i==N-K){
      ll ans=COM(K-1,i-1)*((2*COM(N-K-1,i-1)+COM(N-K-1,i-2))%MOD)%MOD;
      cout<<ans<<endl;
      continue;
    }
    if(i==N-K+1){
      cout<<COM(K-1,i-1)<<endl;
      continue;
    }
    ll ans=COM(K-1,i-1)*((COM(N-K-1,i)+2*COM(N-K-1,i-1)+COM(N-K-1,i-2))%MOD)%MOD;
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}
#define REP(i, n) for (long long i = 0; i < (n); i++)

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
map<long long, long long> cnt;
void primeFactors(long long n) {
    while (n % 2 == 0) {
        cnt[2]++;
        n = n / 2;
    }
    for (int i = 3; i <= sqrt(n); i = i + 2) {
        while (n % i == 0) {
            cnt[i]++;
            n = n / i;
        }
    }
    if (n > 2) {
        cnt[n]++;
    }
}

signed main() {
    long long n;
    cin >> n;
    long long ans = 0;
    primeFactors(n);
    for (pair<long long, long long> cur : cnt) {
        for (int j = 1; j < 50; j++) {
            if (cur.second - j >= 0) {
                cur.second -= j;
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3684
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long

const int N = 333333;
const int MOD = 998244353;

char sumb = '#';

int n, m;
string s[5000];

int d[2100][2100];

bool bd(int i, int j)
{
    int cnt = 0;
    cnt += s[i - 1][j] == sumb;
    cnt += s[i - 1][j + 1] == sumb;
    cnt += s[i][j] == sumb;
    cnt += s[i][j + 1] == sumb;
    return cnt % 2;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++) cin >> s[i];
    for (int j = 0; j < m - 1; j++)
        d[n][j] = n;
    for (int i = n - 1; i >= 0; i--)
    {
        for (int j = 0; j < m - 1; j++)
        {
            d[i][j] = d[i + 1][j];
            if (i && bd(i, j)) d[i][j] = i;
        }
    }
    int ans = max(n, m);
    for (int i = 0; i < n; i++)
    {
        vector<int> r(m);
        vector<int> l(m);
        for (int j = 0; j < m; j++) r[j] = j, l[j] = j;
        vector<vector<pair<int, int> > > v(n + 2);
        for (int j = 0; j + 1 < m; j++)
        {
            int x = d[i + 1][j];
            v[x].push_back({j, j + 1});
        }
        int s = 1;
        for (int j = n; j > i; j--)
        {
            for (int k = 0; k < v[j].size(); k++)
            {
                int R = v[j][k].first;
                int L = v[j][k].second;
                int RR = r[L];
                int LL = l[R];
                int len = RR - LL + 1;
                s = max(s, len);
                l[RR] = LL;
                r[LL] = RR;
            }
            //cout << i << " " << j << " " << s * (j - i) << "\n";
            ans = max(ans, s * (j - i));
        }
    }
    cout << ans;
}


Measured memory_bytes: 37600