akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
const lli INF = 1e9 + 100;
const lli INF64 = (1LL << 61) + 100;
const lli MOD = 1e9 + 7;
const lli MH1 = 1599614977, MH2 = 2034417103, MH3 = 1090250123, MH4 = 2024491871; 
const int N = 105;
const int K = 1e5 + 10;
lli nums[N];
lli dp[N][K];
lli prefSums[N][K];
lli bpow(lli baseee, lli exponenttt) {
	if(exponenttt < 0) return 0;
	lli res = 1;
	baseee %= MOD;
	while (exponenttt > 0) {
		if ((exponenttt & 1) == 1) res = (res*baseee) % MOD;
		baseee = (baseee*baseee) % MOD;
		exponenttt >>= 1;
	}
	return res;
}
lli multInverse(lli a) {//if_mod_is_prime
	return bpow(a, MOD - 2);
}
lli divm(lli a, lli b) {//if_mod_is_prime
	return (a * multInverse(b)) % MOD;
}
lli multm(lli a, lli b) {
	return (a * b) % MOD;
}
lli subm(lli a, lli b) {
	a += MOD;
	lli r = a - b;
	if(r >= MOD) return r - MOD;
	return r;
}
lli addm(lli a, lli b) {
	lli r = a + b;
	if(r >= MOD) return r - MOD;
	return r;
}
signed main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//	freopen("input.txt", "r", stdin);
	//	freopen("output.txt", "w", stdout);
	lli n, k;
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> nums[i];
	
	for(int j = 0; j <= nums[1]; j++)
		dp[1][j] = 1;
		
	prefSums[1][0] = 1;
	for(int j = 1; j <= k; j++)
		prefSums[1][j] = prefSums[1][j-1] + dp[1][j];
	lli sum = nums[1];
	for(int i = 2; i <= n; i++) {
		sum += nums[i];
		for(int j = 0; j <= min(k, sum); j++) {
			if(j <= nums[i])
				dp[i][j] = prefSums[i-1][j];
			else
				dp[i][j] = subm(prefSums[i-1][j], prefSums[i-1][j-nums[i]-1]);
		}
		prefSums[i][0] = 1;
		for(int j = 1; j <= k; j++)
			prefSums[i][j] = addm(prefSums[i][j-1], dp[i][j]);
	}
	cout << dp[n][k] << "\n";
	return 0;
}

Measured memory_bytes: 159232
#include<stdio.h>
#include<string.h>

#define MAX 150000

typedef struct Point{
  char data[100];
  int t;
} Point;

Point set[MAX];
int head;
int tail;
int k;

void equal(Point);
int minixm(int,int);
Point notequal();

int main(){
  int el = 0;
  int c;
  int i;
  int l;
  Point u;

  scanf("%d %d",&k,&l);

  for(i = 0;i < k;i++){
    scanf("%s %d",set[i].data,&set[i].t);
  }
  head = 0;
  tail = k;

  while(head != tail){
    u = notequal();
    c = minixm(l,u.t);
    u.t -= c;
    el += c;
    if(u.t > 0){
      equal(u);
    }
    else{
      printf("%s %d\n",u.data,el);
    }
  }
  return 0;
}


void equal(Point x){
  set[tail] = x;
  tail = (tail + 1) % MAX;
}

Point notequal(){
  Point x = set[head];
  head = (head + 1) % MAX;
  return x;
}

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



Measured memory_bytes: 17024
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N,M = map(int,input().split())
graph = [[] for _ in range(N+1)]
for _ in range(M):
    x,y = map(int,input().split())
    graph[x].append(y)

dp = [None] * (N+1)

def dfs(x):
    if dp[x] is not None:
        return dp[x]
    if graph[x]:
        dp[x] = 1 + max(dfs(y) for y in graph[x])
    else:
        dp[x] = 0
    return dp[x]

answer = max(dfs(x) for x in range(1,N+1))

print(answer)

Measured memory_bytes: 106648
import sys
sys.setrecursionlimit(10**6)

n = int(input())
#b = list(map(int, input().split()))
#n, m = map(int, input().split())
#s = input()
#s,t = input().split()
#
#readline = sys.stdin.readline
#n,m = [int(i) for i in readline().split()]
#ab = [[int(i) for i in readline().split()] for _ in range(n)]

l = [i for i in range(1,10)] + [i for i in range(100,1000)] + [i for i in range(10000,100000)] 

n = [i for i in range(1,n+1)]

ans = len(set(l) & set(n))

print(ans)

Measured memory_bytes: 25548
#include<cstdio>
#include<cstdlib>
#include<cctype>
#include<cstring>
#include<algorithm>
#include<set>
#include<ctime>
#define REP(r,x,y) for(register int r=(x); r<(y); r++)
#define REPE(r,x,y) for(register int r=(x); r<=(y); r++)
#define PERE(r,x,y) for(register int r=(x); r>=(y); r--)
#ifdef sahdsg
#define DBG(...) printf(__VA_ARGS__),fflush(stdout)
#else
#define DBG(...) (void)0
#endif
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

char ch; int si;
char buf[1<<21],*p1=buf,*p2=buf;
int beof = 0;
#define gc() (beof?EOF:(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?(beof=EOF):*p1++))
#define gl(x) {char*s=x;while(isspace(*s=gc()));s++;while(!isspace(*s=gc()))s++;*s=0;}

template<class T>
inline void read(T &x) {
    x=0; si=1; for(ch=gc();!isdigit(ch) && ch!='-';ch=gc()) if(beof) return;
    if(ch=='-'){si=-1,ch=gc();} for(;isdigit(ch);ch=gc())x=x*10+ch-'0';
    x*=si;
}
template<class T, class...A> inline void read(T &x, A&...a){read(x); read(a...);}
char k[17];
int ans=0;
int t[4]={0,0,0,0};
inline void R() {
    gl(k);
    int l=strlen(k);
    int a=k[0]=='B';
    int b=k[l-1]=='A';
    int _=(a<<1)|b;
    REP(i,0,l-1) {
        if(k[i]=='A' && k[i+1]=='B') ans++;
    }
    t[_]++;
}

int main() {
#ifdef sahdsg
    freopen("in.txt","r",stdin);
#endif
    int n; read(n);
    REP(i,0,n) {
        R();
    }
    int anx=0;
    if(t[1]>0) anx+=t[3]+((t[2]--) >0),t[1]--;
    else if(t[2]>0) anx+=t[3]+((t[1]--) >0),t[2]--;
    else if(t[3]>1) anx+=t[3]-1;
    if(t[2]>0 && t[1]>0) anx+=min(t[1],t[2]);

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


Measured memory_bytes: 256
fn main(){
  let nq: Vec<usize> = read_vec();
  let q = nq[1];

  let cv: Vec<usize> = read_vec();
  let mut sc: Vec<bool> = vec![false; 300001];

  for i in 0 .. cv.len() {
    sc[cv[i]] = true;
  }

  let mut nxt: Vec<usize> = vec![0; 300001];
  let mut tv: usize = 0;
  
  for i in 0 .. sc.len() {
    nxt[i] = tv;
    if sc[i] { tv = i; }
  }
  
  for _ in 0 .. q {
    let qi: usize = read();
    let mut i: usize = tv;
    let mut ans: usize = 0;

    while i > 0 {
      let r = i % qi;
      if ans < r { ans = r; }
      i = nxt[i-r];
    }

    println!("{}", ans);
  }
}

fn read<T>() -> T
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.trim().parse().unwrap()
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



Measured memory_bytes: 15048
import numpy as np

from sys import stdin


def main():
    n = int(stdin.readline())
    d = set()
    ans = len(str(n))
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            d.add(i)
    for a in d:
        tmp = np.max([len(str(a)), len(str(int(n / a)))])
        if tmp < ans:
            ans = tmp
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 12480
N, K, S = map(int,input().split())
if N==K:
    print(*([S]*N))
    exit()
if N==1:
    if S!=10**9:
        print(S+1)
        exit()
    else:
        print(S-1)
        exit()
if S==1:
    res = [1]*K
    res += [1000]*(N-len(res))
    print(*res)
    exit()
sa = N-K
val1 = S//2
val2 = S-val1
num = sa//2
res = [val1]
for i in range(K):
    if i%2==0:
        res.append(val2)
    else:
        res.append(val1)
if S != 10**9:
    res += [S+1]*(N-len(res))
else:
    res += [S-1]*(N-len(res))
print(*res)


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;
using Graph = vector<vector<int>>;
 
const double PI = acos(-1);

int H,W,K;
 
int count(int h, int w, vector<vector<int>> arr) {
	int sum = 0;
    rep(i,H) {
    	rep(j,W) {
            if((1<<i&h)!=0&&(1<<j&w)!=0) sum+=arr[i][j];
        }
    }
    return sum;
}
  
int main() {
    cin >> H >> W >> K;
    vector<vector<int>> field;
    field.assign(H, vector<int>(W,0));
    string in;
    rep(i,H) {
        cin >> in;
        rep(j,W) {
            if(in[j] == '#') field.at(i).at(j) = 1;
        }
    }
    int result = 0;
    rep(i,1<<H) {
    	rep(j,1<<W) {
            if(count(i,j,field) == K) result++;
        }
    }
    cout << result << "\n";
}

Measured memory_bytes: 3568
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "{ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "}";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}


#ifdef LOCAL
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    string N; int K;
    cin >> N >> K;

    int MD = N.size();
    ll dp[MD+1][2][K+1];
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1; // digit, smaller, k

    REP(i, MD) {
        int d = N[i] - '0';

        REP(k, K+1) {
            // can select other than 0 for this digit.
            if (k < K) {
                // smaller -> smaller
                dp[i+1][1][k+1] += dp[i][1][k] * 9;

                if(d > 0){
                    // exact -> smaller (select smaller number than d except 0.)
                    dp[i+1][1][k+1] += dp[i][0][k] * (d - 1);

                    // exact -> exact
                    dp[i+1][0][k+1] += dp[i][0][k];
                }
            }

            // select 0 for this digit.
            dp[i+1][1][k] += dp[i][1][k];
            if (d == 0) dp[i+1][0][k] += dp[i][0][k];
            else dp[i+1][1][k] += dp[i][0][k];

        }
    }

    cout << fixed << setprecision(20);
    cout << dp[MD][0][K] + dp[MD][1][K] << endl;

}


Measured memory_bytes: 256
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

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

N=one_int()
A = many_int()

import itertools as it

acc_a = list(it.accumulate(A))

acc_a

maxs = 100000000000
if N>2:
    for i in range(1,len(acc_a)-1):
        if abs((acc_a[-1] - acc_a[i])   - acc_a[i])< maxs:
            maxs=abs(acc_a[-1] - 2*acc_a[i])
else:
    maxs=abs(A[1] - A[0])

print(maxs)

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

#define all(x) x.begin(),x.end()
#define pb(x) emplace_back(x)
#define forn(i,N) for(int i=0;i<N;i++)

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

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

int N,K,X,Y;
cin>>N>>K>>X>>Y;
ll ans=0;
if(N>=K)
  ans=(X*K)+(Y*(N-K));
else
  ans=N*X;
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 3588
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define int long long
using ll = long long;
using namespace std;
const int INF = 1LL << 50;
using P       = pair<int, int>;

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

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

signed main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> bs(n + 1), ws(n + 1); // 黒と白の累積和
    int b = 0, w = 0;
    rep(i, 0, n) {
        if (s[i] == '#') {
            b++;
        } else {
            w++;
        }
        bs[i + 1] = b, ws[i + 1] = w;
    }

    int ans = INF;
    // ある境目より左にある黒の個数 + 右にある白の個数 が変化すべき個数
    // これらのうちの最小値が答え
    rep(i, 0, n + 1) {
        chmin(ans, bs[i] + ws[n] - ws[i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3708
#include <iostream>

using namespace std;

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

    int mod4cnt = 0;
    int mod2cnt = 0;
    int othercnt = 0;
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        if (a % 4 == 0) mod4cnt++;
        else if (a % 2 == 0) mod2cnt++;
        else othercnt++;
    }

    if ((mod4cnt + 1 >= othercnt && mod2cnt == 0) || (mod4cnt >= othercnt && mod2cnt >= 1)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

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

Measured memory_bytes: 3628
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <cmath>
#include <random>
#include <cctype>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define MK make_pair
#define PB push_back
#define VI vector<int>
#define VII vector<int,int>
#define MSI map<string,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define W1 while(1);
int main()
{
	string A, B, C;
	cin >> A >> B >> C;
	cout << A.at(0) << B.at(0) << C.at(0) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vvll=vector<vll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;
using plli=pair<ll,int>;
using vplli=vector<pair<ll,int>>;
using pllll=pair<ll,ll>;
using vpllll=vector<pair<ll,ll>>;

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

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    ll n,m;
    cin>>n>>m;
    vi conne[n];
    rep(i,0,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        conne[a].push_back(b);
        conne[b].push_back(a);
    }
    vi dist(n,1<<30);
    dist[0]=0;
    queue<int> q;
    q.emplace(0);
    while(!q.empty()){
        int e=q.front(); q.pop();
        int idx=e;
        for(int i:conne[idx]){
            if(dist[i]!=1<<30)continue;
            q.emplace(i);
            dist[i]=idx;
        }
    }
    bool check=true;
    rep(i,1,n){
        if(dist[i]==1<<30){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    rep(i,1,n)cout<<dist[i]+1<<endl;
    return 0;
}




Measured memory_bytes: 10276
/*
Looking from a window above
It's like a story of love
Can you hear me?
Came back only yesterday
I'm moving further away
Want you near me
All I needed was the love you gave
All I needed for another day
And all I ever knew
Only you
Sometimes when I think of her name
When it's only a game
And I need you
Listen to the words that you say
It's getting harder to stay
When I see you
All I needed was the love you gave
All I needed for another day
And all I ever knew
Only you, only you
Uh uh uh only you, only you
Only you, only you, only you
This is going to take a long time
And I wonder what's mine
Can't take no more
Wonder if you'll understand
It's just the touch of your hand
Behind a closed door
And all I needed was the love you gave
All I needed for another day
And all I ever knew
Only you, only you, only you
All I needed was the love you gave
All I needed for another day
And all I ever knew
Only you, only you, only you
Only you
*/

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ld long double
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) ((int)(x.size()))
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define see(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define see(x...)
#endif

const int inf = 3e18;
const int N = 5e5 + 100;




int32_t main(){ 
   FAST;
   map<char,char> f;
   f['A'] = 'T' , f['T'] = 'A', f['C'] = 'G', f['G'] = 'C';
   char ch; cin >> ch;
   cout << f[ch] << '\n';
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <map>
#include <functional>
#include <cstring>
#include <queue>
#include <cmath>
#include <deque>
#include <list>
#include <iomanip>
#include <fstream>
#include <string>
#include <iterator>
#include <set>
#include <bitset>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int, int> pii;
#define mp make_pair
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, N) FOR(i, 0, N)
#define SZ(x) ((int)(x).size())

const int MAXN = 107, INF = 1000000007;

int main()
{
	ll Q, H, S, D, N;
	cin >> Q >> H >> S >> D >> N;
	H = min(H, 2*Q);
	S = min(S, 2*H);
	D = min(D, 2*S);
	cout << ((N >> 1)*D + (N & 1)*S);
	//cout << endl; system("pause");//please
	return 0;
}

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef bitset<16> BS;

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 1E+05;

string N;

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

    cin >> N;
    int a = N[0] - '0';
    int b = N[1] - '0';
    int c = N[2] - '0';
    int d = N[3] - '0';
    int s;
    for (int i = 0; i < 1 << 3; i++) {
        int ans = 0;
        if ((i >> 2) & 1) {
            ans = a + b;
        } else {
            ans = a - b;
        }
        if ((i >> 1) & 1) {
            ans += c;
        } else {
            ans -= c;
        }
        if (i & 1) {
            ans += d;
        } else {
            ans -= d;
        }

        if (ans == 7) {
            s = i;
            break;
        }
    }

    /*
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << "i = " << i << ", j = " << j << ", dp = " << dp[i][j] << "\n";
        }
    }
    */
    cout << a;
    if ((s >> 2) & 1) {
        cout << '+';
    } else {
        cout << '-';
    }
    cout << b;
    if ((s >> 1) & 1) {
        cout << '+';
    } else {
        cout << '-';
    }
    cout << c;
    if (s & 1) {
        cout << '+';
    } else {
        cout << '-';
    }
    cout << d << "=7\n";

    return 0;
}

Measured memory_bytes: 3664
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <string>

using namespace std;

#define sqr(x) x * x
#define all(x) x.begin(), x.end()
const int INF = 1e9;
const int MOD = 1e9 + 7;
typedef long long ll;

void solve() {
	long long n, W;
	cin >> n >> W;
	vector<long long> w(n);
	vector<long long> v(n);
	for (long long i = 0; i < n; ++i)
		cin >> w[i] >> v[i];
	vector<vector<long long>> d(W + 1, vector<long long>(n));
	for (long long i = 0; i <= W; ++i)
		if (i < w[0])
			d[i][0] = 0;
		else
			d[i][0] = v[0];
	for (long long i = 1; i < n; ++i)
		for (long long j = 0; j <= W; ++j)
			if (j >= w[i])
				d[j][i] = max(d[j][i - 1], d[j - w[i]][i - 1] + v[i]);
			else
				d[j][i] = d[j][i - 1];
	cout << d[W][n - 1];
}

int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int t = 1;
	//cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 82304
#ifndef _WIN32
#include<iostream>
#endif // !_WIN32

#include<string>
#include<iomanip>
#include<vector>
#include<string>
#include<stack>
using namespace std;

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()



int main() {
	string s;
	while (getline(cin, s), s != ".") {

		int n = s.size();
		vector<int> v;
		REP(i, n) {
			if (s[i] == '(')v.push_back(0);
			if (s[i] == ')')v.push_back(1);
			if (s[i] == '[')v.push_back(2);
			if (s[i] == ']')v.push_back(3);
		}
		string res=[&]() {
			stack<int> st;
			for (auto &it : v) {
				if (it & 1) {
					if (st.empty())return "no";
					if ((st.top() | 1) != it)return "no";
					st.pop();
				}
				else {
					st.push(it);
				}
			}
			if(st.empty())return "yes";
			else return "no";
		}();
		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 3128
#include<stdio.h>
main(){

  int a,b,c,x,y,z;

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

  if(a > b){
    x = a;
    a = b;
    b = x;
  }
  if(b > c){
    y = b;
    b = c;
    c = y;
  }
  if(a > b){
    z = a;
    a = b;
    b = z;
  }

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

  return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
using ll = long long;

ll gcd(ll a,ll b){
    ll tmp;
    ll r;
    if(a==0)return b;
    if(b==0)return a; 
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
 
    /* ユークリッドの互除法 */
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
int main(){
    ll n;
    cin >> n;
    ll a[n];
    for(ll i=0;i<n;i++)cin >> a[i];
    ll m[n]={};
    ll r[n+1];
    ll l[n+1];
    l[0]=0;
    r[n]=0;
    for(ll i=0;i<n;i++)l[i+1]=gcd(l[i],a[i]);
    for(ll i=n;i > 0;i--)r[i-1]=gcd(r[i],a[i-1]);
    for(ll i=0;i<n;i++)m[i]=gcd(l[i],r[i+1]);
    cout << *std::max_element(m,m+n) << endl;
    return 0;
}

Measured memory_bytes: 3328
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            a[i][j] = 0

#for x in a:
#    print(x)

for i in range(3):
    if sum(a[i]) == 0:
        print('Yes')
        exit()
    elif a[0][i] + a[1][i] + a[2][i] == 0:
        print('Yes')
        exit()
    elif a[0][0] + a[1][1] + a[2][2] == 0:
        print('Yes')
        exit()
    elif a[0][2] + a[1][1] + a[2][0] == 0:
        print('Yes')
        exit()

print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdio>
#include <cctype>
using namespace std;

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

string ScanToString(void) {
	const int MAX_LEN = 1200;
	char buf[MAX_LEN] = {};
	scanf("%[^\n]", buf);
	string s(buf);
	REP(i, s.size()) {
		if(isalpha(s[i])) {
			if(isupper(s[i])) {
				s[i] = tolower(s[i]);
			} else {
				s[i] = toupper(s[i]);
			}
		}
	}
	return s;
}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);

	cout << ScanToString() << endl;

	return 0;
}



Measured memory_bytes: 3252
# include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10;
vector < long long > v[26];
long long n , fs[N] , ft[N];
long long find(long long x , long long c){
	long long p = x % n , res = x / n * n;
	vector < long long > :: iterator it = upper_bound(v[c].begin() , v[c].end() , p);
	if(it == v[c].end()) return res + n + *v[c].begin();
	return res + *it;
}
int main(){
	string s , t;
	cin >> s >> t;
	n = s.size();
	for(int i = 0; i < t.size(); i ++)
		ft[t[i] - 'a'] ++;
	for(int i = 0; i < s.size(); i ++)
		fs[s[i] - 'a'] ++,
		v[s[i] - 'a'].push_back(i + 1);
	for(int i = 0; i < 26; i ++){
		if(ft[i] && !fs[i]){
			puts("-1");
			return 0;
		}
	}
	long long cur = 0;
	for(int i = 0; i < t.size(); i ++){
		cur = find(cur , t[i] - 'a');
	}
	printf("%lld" , cur);
}

Measured memory_bytes: 1724
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	// AtCoder Beginner Contest 118
	// https://atcoder.jp/contests/abc118/tasks
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n = sc.nextInt();
		int[] monster = new int[n];
		int res = 0;
		
		for (int i = 0; i < n; i++) {
			monster[i] = sc.nextInt();
		}
		res = gcd(monster[0], monster[1]);
		
		for (int i = 2; i < n; i++) {
			res = gcd(res, monster[i]);
		}
		
		System.out.println(res);
	}
	
	private static int gcd(int m, int n) {
		if (n == 0) {
			return m;
		}
		
		if (m < n) {
			return gcd(n, m);
		}
		return gcd(n, m % n);
	}
	
	static class FastReader { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastReader() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine()); 
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try{ 
                str = br.readLine(); 
            } catch (IOException e) { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
    } 
}


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

int main() {
	// your code goes here
	string s,t,u;
	int a,b;
	cin>>s>>t;
	cin>>a>>b;
	cin>>u;
	if(u==t){
		cout<<a<<" "<<--b;
	}else{
		cout<<--a<<" "<<b;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin>>n;
    int d[n];
    for(int i=0;i<n;i++){
        cin>>d[i];
    }
    sort(d,d+n);
    int count=1;
    for(int j=1;j<n;j++){
        if(d[j-1]!=d[j]){
            count++;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define intmin -2147483647
#define llmax 9223372036854775807
typedef long long ll;
using namespace std;

int h, w, k;
int c[31][30];
char cmem[31][30];
int p[30];
int mx, cnt, cnt2, mem;
bool flag, flag2;

ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	ll g = gcd(x, y);
	return x / g * y;
}


int main(){
	cin >> h >> w >> k;
	if (k > 3) {
		cout << 0 << endl;
		return 0;
	}
	lp(w)
		cmem[0][i] = 10 + i;
	
	lp(h)
		LP(w, j) {
			cin >> cmem[i+1][j];
			cmem[i + 1][j] = cmem[i + 1][j] - '0';
		}
	
	mx = 0;
	if (k == 2) {
		lp(h) {
			LP(w, j) {
				LP(h + 1, l) {
					LP(w, m) {
						c[l][m] = cmem[l][m];
					}
				}
				c[i + 1][j] = 0;

				cnt = 0;
				cnt2 = 0;
				flag2 = true;

				while (flag2) {
//					LP(h + 1, l) {
//						LP(w, m) {
//							cout << c[l][m] << sp;
//						}
//						cout << endl;
//					}
//					cout << endl;
					flag2 = false;
					cnt2++;

					LP(w, l)
						p[l] = h+1;

					LP(h, l) {
						LP(w, m) {
							p[m]--;
							if (p[m] < 0)p[m] = 0;
							while (c[p[m]][m] == 0)p[m]--;
						}
						LP(w - 1, m) {
							if (c[p[m]][m] == c[p[m + 1]][m + 1]) {
								flag2 = true;
								for (int n = m; n < w-1; n++) {
									if (c[p[n]][n] == c[p[n + 1]][n + 1])mem = n + 1;
									else break;
								}
								cnt += c[p[m]][m] * (mem - m + 1) << (cnt2 - 1);
								for (int n = m; n <= mem; n++)
									c[p[n]][n] = 0;
								m = mem;
							}
						}
						
					}
				}
				mx = max(mx, cnt);
			}
		}
	}
	else {
		lp(h) {
			LP(w, j) {
				LP(h + 1, l) {
					LP(w, m) {
						c[l][m] = cmem[l][m];
					}
				}
				c[i + 1][j] = 0;

				cnt = 0;
				cnt2 = 0;
				flag2 = true;

				while (flag2) {
					//					LP(h + 1, l) {
					//						LP(w, m) {
					//							cout << c[l][m] << sp;
					//						}
					//						cout << endl;
					//					}
					//					cout << endl;
					flag2 = false;
					cnt2++;

					LP(w, l)
						p[l] = h + 1;

					LP(h, l) {
						LP(w, m) {
							p[m]--;
							if (p[m] < 0)p[m] = 0;
							while (c[p[m]][m] == 0)p[m]--;
						}
						LP(w - 2, m) {
							if (c[p[m]][m] == c[p[m + 1]][m + 1] && c[p[m + 1]][m + 1] == c[p[m + 2]][m + 2]) {
								flag2 = true;
								for (int n = m; n < w - 1; n++) {
									if (c[p[n]][n] == c[p[n + 1]][n + 1])mem = n + 1;
									else break;
								}
								cnt += c[p[m]][m] * (mem - m + 1) << (cnt2 - 1);
								for (int n = m; n <= mem; n++)
									c[p[n]][n] = 0;
								m = mem;
							}
						}

					}
				}
				mx = max(mx, cnt);
			}
		}
	
	}

	cout << mx << endl;

	return 0;
}

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


bool val(char ch) {
    vector<char> val {'A', 'C', 'T', 'G'};
    for (auto el: val) if (el == ch) return true;
    return false;
}


int main() {
    ios::sync_with_stdio(false);
    
    string str;
    cin >> str;

    int i = 0, l = str.size(), res = 0;
    while( i < l )  {
        int j = i;
        while( j < l && val(str[j]) ) j++;
        res = max(res, j - i);
        if (j == i) i++;
        else i = j;
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#input
n, a, b = map(int, input().split())

#output
mod = pow(10, 9) + 7

def cmb(n, k):
    numerator = 1
    denominator = 1

    for i in range(k):
        numerator *= n-i
        numerator %= mod
        denominator *= i+1
        denominator %= mod
    return numerator*pow(denominator, mod-2, mod) % mod


answer = pow(2, n, mod) - 1 - cmb(n, a) - cmb(n, b)
print(answer % mod)

Measured memory_bytes: 3064
object Main extends App {
  def f(n: Int): Int = {
    (for {
      i <- 1 to n
      if i.toString.length % 2 == 1
    } yield i).length
  }
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  println(f(n))
}

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

typedef vector<bool> vec;
typedef vector<vec> mat;

int n,m,z;
int a[110],b[110];
mat go;

mat operator*(const mat a, const mat b){
  int s = a.size();
  mat res;
  bool f;

  res.resize(s);
  for(int i=0;i<s;i++)res[i].resize(s);

  for(int i=0;i<s;i++){
    for(int j=0;j<s;j++){
      f = false;
      for(int k=0;k<s;k++)f |= a[i][k] && b[k][j];
      res[i][j] = f;
    }
  }
  return res;
}

mat pow(mat a, int x){
  if(x==1)return a;
  mat b = pow(a,x/2);
  if(x&1)return a*b*b;
  return b*b;
}

int main(){
  while(cin >> n >> m >> z, n||m||z){    for(int i=0;i<m;i++){
      cin >> a[i] >> b[i];
      a[i+m] = b[i]; b[i+m] = a[i];
    }
    a[2*m] = 0; b[2*m] = 1;

    go.resize(2*m+1);
    for(int i=0;i<2*m+1;i++)go[i].resize(2*m+1);

    for(int i=0;i<2*m+1;i++)
      for(int j=0;j<2*m+1;j++)go[i][j] = false;

    for(int i=0;i<2*m+1;i++){
      for(int j=0;j<2*m+1;j++){
	if(b[i] == a[j] && !(a[i] == b[j]))go[i][j] = true;
      }
    }

    mat ans = pow(go,z);
    bool res = false;
    for(int i=0;i<2*m+1;i++){
      if(b[i] == n)res |= ans[2*m][i];
    }
    /*
    for(int i=0;i<2*m+1;i++){
      for(int j=0;j<2*m+1;j++)cout << ans[i][j] << " ";
      cout << endl;
    }
    */
    cout << (res?"yes":"no") << endl;
  }
}

Measured memory_bytes: 1508
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define pb push_back






int main(){

    int n;
    cin>>n;

    vector<int> data(n);

    rep(i,n){
        int tmp;
        cin>>tmp;
        data.at(i)=tmp;
    }

    sort(ALL(data));

    int mymax=data.at(n-1);
  

    vector<int>  mycheck((mymax+1),0);

    rep(i,n){
        mycheck.at(data.at(i))=1;
    }


    rep(i,n){
        int tmp=data.at(i);
        if (mycheck.at(tmp)==0){
            continue;
        }
        else {
            for (int j=2*tmp;j<=mymax;j+=tmp){
                mycheck.at(j)=0;
            }
       }

    }

    int answer=0;
  
  
  	for (int a:data){
      if ((upper_bound(ALL(data),a)-lower_bound(ALL(data),a))>=2){
        mycheck.at(a)=0;
      }
    }
      
      
  
     for (int i=data.at(0);i<=mymax;i++){
        if (mycheck.at(i)==1){
            answer++;
        }
    }


 

    cout<<answer<<endl;
    


    





}

Measured memory_bytes: 8008
'use strict'

const main = (input) => {
    const s = input.split('\n')[0].split('')
    const ans = []

    s.forEach(v => {
        if(v === '1' || v === '0'){
            ans.push(v)
        }
        if(v === 'B' && ans.length !== 0){
            ans.pop()
        }
    })

    console.log(ans.join(''))
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

Measured memory_bytes: 21064
/* */

#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int n, a, b;
	cin >> n >> a >> b;
	int maxi, mini;

	maxi = min(a,b);

	if(n < a + b) mini = (a + b) - n;
	else mini = 0;

    cout << maxi << endl << mini << endl;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def prime_factorize(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])
    if temp != 1:
        arr.append([temp, 1])
    if arr == []:
        arr.append([n, 1])
    return arr


def main():
    N, P = map(int, input().split())
    A = prime_factorize(P)
    ans = 1
    for num, count in A:
        ans *= num**(count//N)
    print(ans)

if __name__ == '__main__':
    main()


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

int main() {
    
    int n,m,x,y;
    cin>>n>>m>>x>>y;
    
    int arr[n],brr[m];
    
    
    for(int i=0;i<n;++i)
        cin>>arr[i];
    
    for(int i=0;i<m;++i)
        cin>>brr[i];
    
    
    sort(arr,arr+n);
    sort(brr,brr+m);
    
    int xxx = arr[n-1] + 1;
    
    if(xxx>x&&xxx<=y)
    {
       if(xxx<=brr[0])
       {
           cout<<"No War";
       }
        else
            cout<<"War";
    }
    else
    {
        cout<<"War";
    }
	  
	return 0;
}


Measured memory_bytes: 384
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();

    public static void main(String[] args){
        int sx, sy, tx, ty; 
        {int[] a = in.ii(); sx = a[0]; sy = a[1]; tx = a[2]; ty = a[3];}
        StringBuilder sb = new StringBuilder();
        int x = sx;
        int y = sy;
        int dx = tx-sx;
        int dy = ty-sy;
        char[] ans = new char[4*(dx+dy)+8];
        int j = 0;
        for(int i = dx; i != 0; i--){
            ans[j++] = 'R';
        }
        for(int i = dy; i != 0; i--){
            ans[j++] = 'U';
        }
        for(int i = dx; i != 0; i--){
            ans[j++] = 'L';
        }
        for(int i = dy+1; i != 0; i--){
            ans[j++] = 'D';
        }
        for(int i = dx+1; i != 0; i--){
            ans[j++] = 'R';
        }
        for(int i = dy+1; i != 0; i--){
            ans[j++] = 'U';
        }
        ans[j++] = 'L';
        ans[j++] = 'U';
        for(int i = dx+1; i != 0; i--){
            ans[j++] = 'L';
        }
        for(int i = dy+1; i != 0; i--){
            ans[j++] = 'D';
        }
        ans[j++] = 'R';
        out.println(ans);
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int M;
    cin >> M;
    cout << 24 + 24 - M << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main(){
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(A*N, B) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int items = Integer.parseInt(sc.nextLine());
		int[] cards = Stream.of(sc.nextLine().split(" ", 0)).mapToInt(Integer::parseInt).toArray();

		Arrays.sort(cards);

		int a_let = 0;
		int b_let = 0;

		for (int i = 0; i < items; i++) {
			if (i % 2 == 0) {
				a_let += cards[i];
			} else {
				b_let += cards[i];
			}
		}

		System.out.println(Math.abs(a_let - b_let));
	}

}


Measured memory_bytes: 36064
N = int(input())
A = sorted(list(map(int, input().split())))

vt = 1

for v in A:
    if v == 0:
        print(0)
        exit(0)
    if v > 10**18:
        print(-1)
        exit(0)
    vt *= v
    if vt > 10**18:
        print(-1)
        exit(0)

print(vt)
    


Measured memory_bytes: 21660
#include <iostream>
#include <cstring>
#include <set>
#include <string>
using namespace std;

int t[26][26];

//m[hid©ç¢­ÂÌm[hÉÚ®Â\©
//·ÅÉTõÏÝÌm[hÍÊçÈ¢
int reachableNode(int id,bool *used){
  int res = 1;

  used[id] = true;
  for(int i=0;i<26;i++){
    if(t[id][i] > 0 && !used[i]){
      res += reachableNode(i,used);
    }
  }

  return res;
}

int main(void){
  int n;

  while(cin>>n && n){
    string s;
    int from,to;
    set<int> ap;

    memset(t,0,sizeof(t));

    for(int i=0;i<n;i++){
      cin>>s;
      from = s[0] - 'a';
      to = s[s.length()-1] - 'a';

      //©È[vÈOÌÓÍJEg
      if(from != to){
        t[from][to]++;
      }
      ap.insert(from);
      ap.insert(to);
    }

    //XªêÂ¾¯Å é©ÌmF
    bool used[26];
    memset(used,0,sizeof(used));
    int count = reachableNode(from,used);
    if(count != ap.size()){
      cout<<"NG\n";
      continue;
    }

    //üÆoª¯¶©Ç¤©ÌmF
    set<int>::iterator i = ap.begin();
    for(;i!=ap.end();i++){
      int in=0,out=0;
      for(int j=0;j<26;j++){
        in += t[j][*i];
        out += t[*i][j];
      }

      if(in != out) break;
    }

    if(i == ap.end())
      cout<<"OK\n";
    else
      cout<<"NG\n";
  }

  return 0;
}

Measured memory_bytes: 916
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

ll dp[2010][2010];

int main(){
    int N,M; cin >> N >> M;
    vector<int> S(N),T(M);
    rep(i,N) cin >> S[i];
    rep(i,M) cin >> T[i];

    rep(i,N+1) dp[i][0] = 1;
    rep(i,M+1) dp[0][i] = 1;
    rep(i,N)rep(j,M){
        if(S[i] == T[j]){
            dp[i+1][j+1] += dp[i+1][j]+dp[i][j+1];
            dp[i+1][j+1] %= MOD;
        }
        else{
            dp[i+1][j+1] += ((dp[i][j+1]+dp[i+1][j])%MOD-dp[i][j]+MOD)%MOD;
            dp[i+1][j+1] %= MOD;
        }
    }
    cout << dp[N][M] << endl;

}



Measured memory_bytes: 31744
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin>>N;
  int ans=0;
  vector<int>A(N);
  vector<int>B(N-1);
  rep(i,N-1){
    cin>>B[i];
  }
  A[0]=B[0];
  for(int i=1;i<N-1;i++){
    A[i]=min(B[i],B[i-1]);
  }
  A[N-1]=B[N-2];
  rep(i,N){
    ans+=A[i];
    //cout<<A[i]<<endl;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;


//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;




/*
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
*/
/*
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
*/

const ll mod = 1e9 + 7;
const ll modl=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ll gcd(ll x,ll y){
   if(y==0)return x;
   return gcd(y,x%y);
}
                                              // SIEVE

/*
bool isPrime[100001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/
/*
const int N=100001;
ll fact_inverse[N];
ll num_inverse[N];
ll fact[N];
void number_inverse(int m){
   num_inverse[0]=1;
   num_inverse[1]=1;
   for(int i=2;i<=N;i++){
     num_inverse[i]=num_inverse[m%i]*(m - m/i)%m;
   }
}

void factorial_inverse(int m){
   fact_inverse[0]=1;
   fact_inverse[1]=1;
   for(int i=2;i<=N;i++){
      fact_inverse[i]=(num_inverse[i]*fact_inverse[i-1])%m;
   }
}

void factorial(int m){
  fact[0]=1;
  for(int i=1;i<=N;i++)fact[i]=(i*fact[i-1])%m;
}

int modular_nCr(int n,int r,int m){
   ll res=((fact[n]*fact_inverse[r])%m *  fact_inverse[n-r])%m;
   return res;
}
*/
int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
       int n;
       cin>>n;
       ll r=n/500;
       ll ans=r*1000;
       n%=500;
       ans+=(n/5)*5;
       cout<<ans<<endl;
  }
}









Measured memory_bytes: 3572