akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > > 
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N ; cin >> N ;
    string s1, s2;
    cin >> s1 >> s2;
    
    ll ans = 1;
    ll start = 0;
    bool beforeis__ ;
    // 最初は縦で詰めた
    if(s1[0] == s2[0]){
        start = 1;
        ans = 3;
        beforeis__ = false;
    }
    else{// 最初は横で詰めた
        start = 2;
        ans = 6;
        beforeis__ = true;
    }
    
    for(ll i = start; i<N; i++){
        if(s1[i] == s2[i]){
            if(beforeis__ == true) ans *= 1;
            if(beforeis__ == false) ans *= 2;
        }
        else{
            if(beforeis__ == true) ans *= 3;
            else ans *= 2;
        }
        if(s1[i]==s2[i]) beforeis__ = false;
        else {
            beforeis__ = true;
            i++;
        }
        ans %= 1000000007;
    }
    
    cout << ans << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
<?php
  $sum;
  fscanf(STDIN, "%d %d", $n, $k);
  $array = explode(' ',trim(fgets(STDIN)));
  sort($array);
  for($i = 0 ; $i < $k; $i++){
  	$sum += $array[$i];
  }
  
  echo $sum;

Measured memory_bytes: 16288
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

class ModCalc
{
	LLONG m_mod = MOD;
	vector<LLONG> m_fac;
	vector<LLONG> m_ifac;

public:
	ModCalc(const LLONG mod)
	{
		m_mod = mod;
	}

	// Combinationを計算したいときの前処理：O(max)
	ModCalc(const int max, const LLONG mod)
	{
		m_mod = mod;
		m_fac = vector<LLONG>(max + 1);
		m_ifac = vector<LLONG>(max + 1);
		m_fac[0] = m_ifac[0] = 1;
		for (int i = 0; i < max; ++i)
		{
			m_fac[i + 1] = m_fac[i] * (i + 1) % mod;    // n! (mod M)
			m_ifac[i + 1] = m_ifac[i] * ModPow(i + 1, mod - 2) % mod;   // k!^(M-2) (mod M)
		}
	}

	const LLONG ModAdd(LLONG a, LLONG b) const
	{
		return (a + b) % m_mod;
	}

	const LLONG ModSubtract(LLONG a, LLONG b) const
	{
		LLONG diff = a - b;
		return diff >= 0 ? diff : diff + m_mod;
	}

	const LLONG ModMulti(LLONG a, LLONG b) const
	{
		LLONG prod = a * b % m_mod;
		return prod >= 0 ? prod : prod + m_mod;
	}

	const LLONG ModDiv(LLONG a, LLONG b) const
	{
		LLONG c = m_mod, u = 1, v = 0;
		while (c)
		{
			LLONG t = b / c;
			b -= t * c; swap(b, c);
			u -= t * v; swap(u, v);
		}
		u %= m_mod;
		if (u < 0) u += m_mod;
		return (a % m_mod) * u % m_mod;
	}

	const LLONG ModPow(LLONG x, LLONG n) const
	{
		LLONG ret = 1;
		while (n != 0)
		{
			if (n & 1) ret = ret * x % m_mod;
			x = x * x % m_mod;
			n = n >> 1;
		}
		return ret;
	}

	const LLONG ModComb(LLONG n, LLONG r) const
	{
		if (n == 0 && r == 0) return 1;
		if (n < r || n < 0) return 0;
		LLONG tmp = m_ifac[n - r] * m_ifac[r] % m_mod;
		return tmp * m_fac[n] % m_mod;
	}
};

int main()
{
	int N; cin >> N;
	map<int, int> ai2NumMap;
	REP(i, N)
	{
		int ai; cin >> ai; ++ai2NumMap[ai];
	}
	bool isOK = true;
	for (int ai = N - 1; ai > 0; ai -= 2)
	{
		if (ai2NumMap.count(ai) > 0 && ai2NumMap[ai] == 2)
		{
			continue;
		}
		isOK = false;
		break;
	}
	if (N % 2 == 1 && ai2NumMap.count(0) != 1)
	{
		isOK = false;
	}
	if (isOK == false)
	{
		cout << 0 << endl;
	}
	else
	{
		ModCalc mod(MOD);
		cout << mod.ModPow(2, N / 2) << endl;
	}
}


Measured memory_bytes: 6584
import sys
from collections import Counter
from collections import deque
import math
import bisect
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

def f(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors
n=int(input())
l=f(n)
ans=10**13
for i in l:
    ans=min(ans,i+n//i-2)
print(ans)

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

using namespace std;
vector<vector<pair<int,int>>>vc(100001);
int comp1(int a,int b){
       return (a>b);
}
void go(int node,int col){
          int col2=1;
        for(int i=0;i<vc[node].size();i++){
            if(col2==col)
                col2++;
            vc[node][i].second=col2;
            go(vc[node][i].first,col2);
            col2++;
        }
    return;
}
int main(){
    int n;
    cin>>n;
    vector<pair<int,int>>p1;
    int arr[n+1]={0};
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        arr[a]++;
        arr[b]++;
        vc[a].push_back(make_pair(b,0));
        p1.push_back(make_pair(a,b));
      //  vc[b].push_back(make_pair(a,0));
    }
  sort(arr,arr+n,comp1);
    cout<<arr[0]<<endl;
     int flg=0;
   for(int i=1;i<=n;i++){
      if(vc[i].size()!=0){
         go(i,0);
         flg=1;
         break;
      }
      if(flg==1)
        break;
   }
   /* for(int i=1;i<=n;i++){
        for(int j=0;j<vc[i].size();j++){
            cout<<vc[i][j].second<<endl;
        }
    }*/
    for(int i=0;i<=n;i++)
        arr[i]=0;
    for(int i=0;i<p1.size();i++){
        cout<<vc[p1[i].first][arr[p1[i].first]].second<<endl;
        arr[p1[i].first]++;
    }

return 0;
}
/*
9
1 6
1 4
1 9
4 5
1 7
2 3
4 8
1 2
*/


Measured memory_bytes: 7928
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;



int main(){
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  int mn=a[0],mx=a[0];
  for (int i=1; i<n;i++) {
    if (mn>a[i]) mn=a[i];
    if (mx<a[i]) mx=a[i];

  }
  cout << mx-mn << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define int long long

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 3e18;
const ll linf = 3e18;
const double eps = 1e-9;

int N, M, K;
int A[20005];
int memo[20005];

inline int rec(int now)
{
    if (~memo[now]) return memo[now];

    int res = inf;
    int mi = inf, ma = -inf;
    
    for (int i = 0, to = min(N - now, M); i < to; ++i) {
        mi = min(mi, A[now + i]);
        ma = max(ma, A[now + i]);

        res = min(res, K + (ma - mi) * (i + 1) + rec(now + i + 1));
    }

    if (res == inf) res = 0;

    return memo[now] = res;
}

signed main()
{ // #define int long long ?????????????????§scanf???????????¨???????????????????????\?????????????????????
    omajinai;
    cin >> N >> M >> K;

    rep(i, N) {
        cin >> A[i];
    }

    memset(memo, -1, sizeof (memo));

    cout << rec(0) << endl;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, bool>> towers(N);
  for (int i = 0; i < N; i++) {
    int h;
    cin >> h;
    towers[i].first = h;
  }
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    if (towers[a-1].first <= towers[b-1].first) {
      towers[a-1].second = true;
    }
    if (towers[a-1].first >= towers[b-1].first) {
      towers[b-1].second = true;
    }
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (towers[i].second == false) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4044
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
typedef long long ll;

string s;

int main()
{
  cin >> s;
  for(int i = 0; i < sz(s); i++)
    if(s[i] == '?')
      s[i] = 'D';
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 3752
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793



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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int f(int i)
{
	long long int ans=0;
	long long int x,y,z,n=i;
	for(x=1;x<=pow(i,0.5);x++)
	{
		for(y=1;y<=pow(i,0.5);y++)
		{
			for(z=1;z<=pow(i,0.5);z++)
			{
				if(x*x+y*y+z*z+x*y+y*z+x*z==n)
				{
					ans++;
					break;
				}
				else if(x*x+y*y+z*z+x*y+y*z+x*z>n)
				break;
			}
		}
	}
	return ans;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	int n;
	cin>>n;
	int i;
	long long int x,y,z;
	int dp[n+1];
	memset(dp,0,sizeof(dp));
	for(x=1;x<sqrt(n);x++)
	{
		if(x*x+2*x+3>n)
		break;
		for(y=1;y<sqrt(n);y++)
		{
			if(x*x+x*y+y*y+1+y+x>n)
			break;
			for(z=1;z<sqrt(n);z++)
			{
				if( x*x+y*y+z*z+x*y+y*z+x*z>n)
				break;
				dp[x*x+y*y+z*z+x*y+y*z+x*z]++;
			}
		}
	}
	for(i=1;i<=n;i++)
	cout<<dp[i]<<"\n";
	return 0;
}



Measured memory_bytes: 3580
import scala.io.StdIn._
import java.util.Scanner

object Main {
  def main(args: Array[String]) = {
    val s = new Scanner(System.in)
    val H = s.nextLong
    val W = s.nextLong
    if (H == 1 || W == 1) {
      println("1")
    } else {
      println((H * W + 1) / 2)
    }
  }
}

Measured memory_bytes: 26940
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
using namespace std;

#define LL long long

const int CN = 1e5+5;
const LL INF = 0x3f3f3f3f3f3f3f2f;

LL read(){
    LL s = 0,ne = 1; char c = getchar();
    for(;c<'0'||c>'9';c=getchar()) if(c=='-') ne=-1;
    for(;c>='0'&&c<='9';c=getchar()) s=(s<<1)+(s<<3)+c-'0';
    return s*ne;
}

class fs{
  public: int to,nxt; LL di; void init(int t,int n,LL d) {to=t;nxt=n;di=d;}
}E[CN * 51];
int hd[CN],ecnt = 0;
void add(int x,int y,LL z) {E[++ecnt].init(y, hd[x], z); hd[x] = ecnt;}

int n,m;

/* DJ */
class DJ{
  public: int id; LL v; bool operator < (const DJ& a)const {return v > a.v;}
};
priority_queue<DJ> Q; 
LL d[CN]; bool vis[CN];
LL SP(int st,int ed){
    memset(vis, 0, sizeof(vis));
    memset(d, 0x3f, sizeof(d));
    Q.push((DJ){st, d[st] = 0});
    while(!Q.empty()){
        int u = Q.top().id; Q.pop();
        if(vis[u]) continue; vis[u] = true;
        for(int k = hd[u]; k; k = E[k].nxt){
            int v = E[k].to;
            if(d[v] > d[u] + E[k].di){
                d[v] = d[u] + E[k].di;
                Q.push((DJ){v, d[v]});
            }
        }
    }
    return d[ed] < INF ? d[ed] : -1;
}

int main()
{
    n = read(); m = read();
    while(m--){
        int u = read(),v = read(); LL c = read();
        add(u, v, c); add(v, u, c);
    }
    for(int i=1;i<n;i++) add(i + 1, i, 0);

    printf("%lld", SP(1, n));
}

Measured memory_bytes: 8564
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <ctime>
#include <map>
#include <set>
#define MEM(x,y) memset ( x , y , sizeof ( x ) )
#define rep(i,a,b) for (int i = (a) ; i <= (b) ; ++ i)
#define per(i,a,b) for (int i = (a) ; i >= (b) ; -- i)
#define pii pair < int , int >
#define one first
#define two second
#define rint read<int>
#define int long long
#define pb push_back
#define db double
#define ull unsigned long long
#define lowbit(x) ( x & ( - x ) )

using std::queue ;
using std::set ;
using std::pair ;
using std::max ;
using std::min ;
using std::priority_queue ;
using std::vector ;
using std::swap ;
using std::sort ;
using std::unique ;
using std::greater ;

template < class T >
    inline T read () {
        T x = 0 , f = 1 ; char ch = getchar () ;
        while ( ch < '0' || ch > '9' ) {
            if ( ch == '-' ) f = - 1 ;
            ch = getchar () ;
        }
       while ( ch >= '0' && ch <= '9' ) {
            x = ( x << 3 ) + ( x << 1 ) + ( ch - 48 ) ;
            ch = getchar () ;
       }
       return f * x ;
    }

int n ;

signed main (int argc , char * argv[]) {
    n = rint () ; bool f = false ;
    for (int i = 1 ; i <= 9 ; ++ i) {
        for (int j = 1 ; j <= 9 ; ++ j)
            if ( i * j == n ) { f = true ; break ; }
        if ( f ) break ;
    }
    puts ( f ? "Yes" : "No" ) ;
    return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;
#define MOD 1000000007
#define MSG(a) cout << #a << " " << a << endl;
#define print(a) cout << a << endl;
template <class T, class C>
void chmax(T &a, C b)
{
    a > b ?: a = b;
}
template <class T, class C>
void chmin(T &a, C b) { a < b ?: a = b; }

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

// vector の出力
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v)
{
    size_t last = v.size() - 1;
    for (size_t i = 0; i < v.size(); ++i)
    {
        out << v[i];
        if (i != last)
            out << " ";
    }
    return out;
}

int main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //////////////////////////////////////////

    int n, m;
    ll total = 0;

    cin >> n;
    vector<int> t(n);
    rep(i, n)
    {
        cin >> t[i];
        total += t[i];
    }
    cin >> m;

    rep(i, m)
    {
        int p, x;
        cin >> p >> x;
        print(total - t[p - 1] + x);
    }

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,k;
  int big;
  vector <int> ans;
  int count;
  cin >> a >> b >> k;
  if (a > b) big = a;
  else big = b;
  for(int i=1;i<=big;i++){
    if ((a%i==0) && (b%i==0)) ans.push_back(i);
  }
  if (ans.size() == 0) cout << 0 << endl;
  else cout << ans[ans.size()-k] << endl;
  return 0;
}

Measured memory_bytes: 256
//----------------------------templates
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("tune=native")
    #pragma GCC target ("avx")
    //----------------------------
    #include <bits/stdc++.h>
    using namespace std;

    typedef long long ll;
    typedef unsigned long long ull;
    #define int ll

    #define FOR(i,j,n) for (int i=(int)(j);i<(n);i++)
    #define REP(i,n) for (int i=0;i<(int)(n);i++)
    #define REPS(i,n) for (int i=1;i<=(int)(n);i++)
    #define REPN(i,n) for (int i=(int)(n)-1;i>=0;i--)
    #define REPNS(i,n) for (int i=(int)(n);i>0;i--)

    #define I(n) scanf("%lld", &(n))
    #define LL(n) scanf("%lld", &(n))
    #define pb(n) push_back((n))
    #define mp(i,j) make_pair((i),(j))
    #define eb(i,j) emplace_back((i),(j))
    #define y0 y3487465
    #define y1 y8687969
    #define j0 j1347829
    #define j1 j234892
    #define uniq(v) v.erase( unique(v.begin(), v.end()), v.end() )

    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())

    typedef vector<int> vi;
    typedef pair<int,int> pi;
    typedef vector<pi> vpi;
    typedef vector<vi> vvi;
    typedef vector<vpi> vvpi;
    typedef vector<vvi> vvvi;

    const int mod = 1000000007;

//--------------------------------------------

int x,y,a,b,c,tmp;
priority_queue<int> p,q,r;

signed main(){
    I(x); I(y); I(a); I(b); I(c);
    REP(i,a) { I(tmp); p.push(tmp); }
    REP(i,b) { I(tmp); q.push(tmp); }
    REP(i,c) { I(tmp); r.push(tmp); }
    int noc = 0;
    p.push(-114514);
    q.push(-114514);
    r.push(-114514);
    int ret = 0;
    while( x+y != noc ) {
        int pt = p.top();
        int qt = q.top();
        int rt = r.top();
        if (max({pt,qt,rt}) == rt){
            ret += rt;
            r.pop();
            noc++;
        } else if (max({pt,qt,rt}) == pt){
            if (x){
                ret += pt;
                p.pop();
                x--;
            } else if (qt > rt){
                ret += qt;
                q.pop();
                y--;
            } else {
                ret += rt;
                r.pop();
                noc++;
            }
        } else {
            if (y){
                ret += qt;
                q.pop();
                y--;
            } else if (pt > rt){
                ret += pt;
                p.pop();
                x--;
            } else {
                ret += rt;
                r.pop();
                noc++;
            }
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 3316
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
      
        if (b>=a){
            System.out.println(a);
        }else{
            System.out.println(a-1);
        }
    }
}

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

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef vector<pair<ll, ll>> vpll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int h, w;
    cin >> h >> w;
    vector<vector<bool>> a(h, vector<bool>(w));
    forn(i, h) {
        string s;
        cin >> s;
        forn(j, w) a[i][j] = (s[j] == '.');
    }
    int ans = -1;
    forn(is, h) {
        forn(js, w) {
            if (!a[is][js]) continue;
            map<pii, int> dist;
            queue<pii> q;
            dist[{is, js}] = 1;
            q.push({is, js});
            while (!q.empty()) {
                pii u = q.front();
                q.pop();
                ans = max(ans, dist[u]);
                if (u.fst + 1 < h && a[u.fst + 1][u.snd] && !dist[{u.fst + 1, u.snd}]) {
                    dist[{u.fst + 1, u.snd}] = dist[u] + 1;
                    q.push({u.fst + 1, u.snd});
                }
                if (u.fst - 1 >= 0 && a[u.fst - 1][u.snd] && !dist[{u.fst - 1, u.snd}]) {
                    dist[{u.fst - 1, u.snd}] = dist[u] + 1;
                    q.push({u.fst - 1, u.snd});
                }
                if (u.snd + 1 < w && a[u.fst][u.snd + 1] && !dist[{u.fst, u.snd + 1}]) {
                    dist[{u.fst, u.snd + 1}] = dist[u] + 1;
                    q.push({u.fst, u.snd + 1});
                }
                if (u.snd - 1 >= 0 && a[u.fst][u.snd - 1] && !dist[{u.fst, u.snd - 1}]) {
                    dist[{u.fst, u.snd - 1}] = dist[u] + 1;
                    q.push({u.fst, u.snd - 1});
                }
            }
        }
    }
    cout << ans - 1 << "\n";
    return 0;
}

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

using namespace std;
int main(void){
    int n, k;
    cin >> n >> k;
    
    vector<long long> a(n);
    for (int i = 0; i < n; i++)cin >> a[i];
    
    map<int,int> mp;
    for (int i = 0; i < n; i++) mp[a[i]]++;
    
    vector<int> v;
    for (auto p : mp){
        v.push_back(p.second);
    }
    
    sort(v.begin(),v.end());
    
    int l = (int)v.size();
    if (l <= k){
        cout << 0 << endl;
        return 0;
    }
    else{
        int ans = 0;
        for (int i = 0; i < l - k; i++) ans += v[i];
        cout << ans << endl;
    }
    
}


/*
ref: https://atcoder.jp/contests/arc086/submissions/1858142
*/

Measured memory_bytes: 15160
using System;
using System.Linq;

namespace _0316
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] h = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] k = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int hi = h[0] * x[0] + h[1] * x[1] + h[0] / 10 * x[2] + h[1] / 20 * x[3];
            int ke = k[0] * x[0] + k[1] * x[1] + k[0] / 10 * x[2] + k[1] / 20 * x[3];
            if (hi == ke) Console.WriteLine("even");
            else Console.WriteLine(hi > ke ? "hiroshi" : "kenjiro");
        }
    }
}

Measured memory_bytes: 9448
N,M,C=list(map(int,input().split()))
B=list(map(int,input().split()))

ans=0

for i in range(N):
    A=list(map(int,input().split()))
    S=0
    for j in range(M):
        S+=A[j]*B[j]
    if S>-C:
        ans+=1
            
        
print(ans)

Measured memory_bytes: 9168
#include<iostream>
using namespace std;
#define MAX 15
#define BLANK 0
#define BARRIER 1
#define JUMP 2
int main()
{
  int X,Y,field[MAX][MAX],dp[MAX][MAX],i,j,sum;
  while(cin>>X>>Y,X|Y){
    for(i=0;i<Y;i++)for(j=0;j<X;j++){cin>>field[i][j];dp[i][j]=(i==0);}
    for(i=1;i<Y;i++){
      for(j=0;j<X;j++){
	if(field[i][j]==BARRIER)continue;
	if(field[i-1][j]==BLANK)dp[i][j]+=dp[i-1][j];
	if(j+1<X && field[i-1][j+1]==BLANK && field[i][j]!=JUMP)dp[i][j]+=dp[i-1][j+1];
	if(j-1>=0 && field[i-1][j-1]==BLANK && field[i][j]!=JUMP)dp[i][j]+=dp[i-1][j-1];
	if(i-2>=0 && field[i-2][j]==JUMP)dp[i][j]+=dp[i-2][j];
      }
    }
    sum=0;
    for(j=0;j<X;j++){
      if(field[Y-1][j]==BLANK||field[Y-1][j]==JUMP)sum+=dp[Y-1][j];
      if(Y-2>=0 && field[Y-2][j]==JUMP)sum+=dp[Y-2][j];
    }
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 0
l, r = map(int, input().split())
ans = 2020

for i in range(l, min(r + 1, l + 4040)):
    for j in range(i + 1, min(r + 1, l + 4040)):
        if i * j % 2019 < ans:
            ans = i * j % 2019
print(ans)

Measured memory_bytes: 65100
import java.util.Scanner;
import java.util.Arrays;
import static java.util.stream.Collectors.joining;

class Main {
  final static int k = 10001;
  static int[] C = new int[k];

  public static void main(String... args) {
    Scanner sc = new Scanner(System.in);
    int size = sc.nextInt();
    int current = 0;
    int[] A = new int[size];
    int[] B = new int[size];

    for (int i = 0; i < size; i++) C[A[i] = Integer.parseInt(sc.next())]++;
    for (int i = 1; i < k; i++) C[i] += C[i - 1];
    for (int i = size - 1; i >= 0; i--) B[--C[A[i]]] = A[i];
    System.out.println(Arrays.stream(B).boxed().map(n -> n.toString()).collect(joining(" ")));
  }
}




Measured memory_bytes: 326044
#include<iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main()
{
    int a;
    cin >> a;
    string ans = "NO";

    if(a == 3 || a == 5 || a == 7) ans = "YES";
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define A 100000000
int main(){
 long long n;
 long long ans =0;
 cin >> n;
 static int a[A];
 for(int i=0;i<n;i++){
  cin >> a[i];
  if(i!=0&&a[i-1]>a[i]){
    ans = ans + a[i-1]-a[i];
    a[i]=a[i-1];
  }
 }
 
 cout << ans <<endl;
}


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

bool check(int n){
    string s = to_string(n);
    sort(s.begin(), s.end());
    return s[0] == s[s.length()-1];
}

int main(){
    int n;
    cin >> n;

    for(int i = n;; i++){
        if(check(i)){
            cout << i << endl;
            return 0;
        }
    }
}

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

typedef long long int ll;
typedef long double ld;

#define Pb push_back
#define Mp make_pair

#define ff first
#define ss second

#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))

#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN

#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define db1(x) cout<<#x<<" : "<<x<<endl;
#define db2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define db3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;

const int N = 105;
const int WW = 1e5+5;
ll dp[N][WW];
ll n,W;
ll w[N],v[N];

ll sol(int idx,int wt)
{
  if(idx == n)  return 0;
  ll &ans = dp[idx][wt];
  if(ans != -1) return ans;
  if(w[idx] > wt)
  {
    ans = sol(idx+1,wt);
  }
  else
  {
    ans = max(v[idx] + sol(idx+1,wt-w[idx]) , sol(idx+1,wt));
  }
  return ans;
}

void solve()
{
  cin >> n >> W;
  for(ll i=0;i<n;i++)
  {
    cin >> w[i] >> v[i];
  }
  memset(dp,-1,sizeof(dp));
  ll ans = sol(0,W);
  cout << ans;
}

signed main()
{
  IOS;
  //freopen("input.txt", "rt", stdin);
  //freopen("output.txt", "wt", stdout);
  int t=1;
  //cin >> t;
  while(t--)
  {
    solve();
  }
  return 0;
}
/*==============================================================================================================================================================*/


Measured memory_bytes: 82432
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	int h[20];
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int Ma = h[0];
	int count = 1;
	for (int i = 1; i < n; i++) {
		Ma = max(h[i], Ma);
		if (h[i] == Ma) {
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;i--)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);i--)
#define rep0(i,n) for(i=0;i<(n);++i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

struct Era{
	string name;
	int by,wy;
};

Era era[1010];

int main() {
	int n,m;
	IL{
		cin>>n>>m;
		if(n==0&&m==0)break;
		rep(i,n){
			cin>>era[i].name>>era[i].by>>era[i].wy;
		}
		rep(i,m){
			int year=in();
			int j;
			rep0(j,n){
				if(era[j].wy-era[j].by<year&&year<=era[j].wy){
					cout<<era[j].name<<" "<<year-era[j].wy+era[j].by<<endl;
					break;
				}
			}
			if(j==n)cout<<"Unknown"<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;

int main() {
    int n; cin >> n;

    vector<vector<int>> c(9, vector<int>(9));
    for (int i = 1; i <= n; i++) {
        ostringstream oss;
        oss << i;
        string s = oss.str();
        int h = s[0] - '0', t = s[s.size() - 1] - '0';
        if (h * t > 0) c[h - 1][t - 1]++;
    }

    long long out = 0;
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 9; j++) {
            out += c[i][j] * c[j][i];
        }
    }

    cout << out << endl;

    return 0;
}


Measured memory_bytes: 256
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define LL long long

# define eps 1e-8
# define MOD 1000000007
# define INF 0x3f3f3f3f
inline int Scan() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
const int MX=200005;
//Code begin....

int n;
int dat[MX];
int ans[MX];
int mn[MX];
int st[2][MX][40];
struct Qu
{
    int l,r;
    int dex; //zui xiao ,,biao hao
    bool operator < (const Qu b) const{
        return dat[dex]>dat[b.dex];
    }
};
void Init()
{
    mn[0]=-1;
    dat[0]=INF;
    for (int i=1;i<=n;i++)
    {
        if ((i&(i-1))==0) mn[i]=mn[i-1]+1;
        else mn[i]=mn[i-1];

        if (i&1) st[1][i][0]=i;
        else st[0][i][0]=i;
    }

    for (int j=1;(1<<j)<=n;j++)
    {
        for (int i=1;(i+(1<<j)-1)<=n;i++)
        {
            if (dat[st[0][i][j-1]]<=dat[st[0][i+(1<<(j-1))][j-1]])
                st[0][i][j] = st[0][i][j-1];
            else
                st[0][i][j] = st[0][i+(1<<(j-1))][j-1];

            if (dat[st[1][i][j-1]]<=dat[st[1][i+(1<<(j-1))][j-1]])
                st[1][i][j] = st[1][i][j-1];
            else
                st[1][i][j] = st[1][i+(1<<(j-1))][j-1];
        }
    }
}
int st_cal(int l,int r,int same)
{
    int k = mn[r-l+1];
    int c;
    if (same) c=l%2;
    else c=(l+1)%2;

    if (dat[st[c][l][k]]<=dat[st[c][r-(1<<k)+1][k]])
        return st[c][l][k];
    else
        return st[c][r-(1<<k)+1][k];
}

int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++)
        dat[i] = Scan();
    Init();
    priority_queue<Qu> Q;
    Q.push((Qu){1,n,st_cal(1,n,1)});
    int pp=0;
    for (int i=1;i<=n/2;i++)
    {
        Qu now = Q.top();Q.pop();
        int ml = now.dex;
        int mr = st_cal(ml+1,now.r,1);
        ans[pp++]=dat[ml];
        ans[pp++]=dat[mr];
        if (ml>now.l)
            Q.push( (Qu){now.l,ml-1,st_cal(now.l,ml-1,1)}  );
        if (mr-1>ml)
            Q.push( (Qu){ml+1,mr-1,st_cal(ml+1,mr-1,1)}  );
        if (mr<now.r)
            Q.push( (Qu){mr+1,now.r,st_cal(mr+1,now.r,1)}  );
    }
    for (int i=0;i<pp-1;i++)
        printf("%d ",ans[i]);
    printf("%d\n",ans[pp-1]);
    return 0;
}


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

using namespace std;

int main()
{
    int n;
    long long int a[100010];
    long long int ans = 1;
    map<long long int, long long int> mp;
    long long int w = 0, h = 0;

    cin >> n;

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

    sort(a,a+n);
    reverse(a,a+n);

    for(auto x: mp) {
        if (x.second >= 4) {
            if (w < x.first) {
                w = x.first;
            }
            if (h < x.first) {
                h = x.first;
            }
        }
        else if (x.second >= 2) {
            if (h < w) {
                if (h < x.first) {
                    h = x.first;
                }
            }
            else {
                if (w < x.first) {
                    w = x.first;
                }
            }
        }
    }

    cout << h*w << endl;
}


Measured memory_bytes: 7296
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  n <- readLn
  as <- map readInt . BC.words <$> BC.getLine
  print $ solve n as

solve :: Int -> [Int] -> Int
solve n as = maximum [abs (a1 - a2) | a1 <- as, a2 <- as]

readInt :: BC.ByteString -> Int
readInt = fst . fromJust . BC.readInt


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define rep(a,n) for (int a = 0; a < (n); ++a)
using namespace std;
using ll = long long;
typedef pair<int,int> P;
typedef pair<ll,P> PP;
//typedef vector<vector<int> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = numeric_limits<ll>::max();

ll n,k;
vector<P>zahyo;

int main(){
    cin >> n >> k;
    zahyo.resize(n);
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        zahyo[i]={x,y};
    }
    ll ans = INF;
    rep(i,n){
        rep(j,n){
            rep(ni,n){
                rep(nj,n){
                    ll x1,x2,y1,y2;
                    x1=zahyo[i].first;x2=zahyo[j].first;
                    y1=zahyo[ni].second;y2=zahyo[nj].second;
                    if(x1>x2)swap(x1,x2);
                    if(y1>y2)swap(y1,y2);
                    ll cnt = 0;
                    rep(l,n){
                        ll xnow=zahyo[l].first;
                        ll ynow=zahyo[l].second;
                        if(xnow<x1||xnow>x2)continue;
                        if(ynow<y1||ynow>y2)continue;
                        cnt++;
                    }
                    if(cnt>=k){
                        chmin(ans,(x2-x1)*(y2-y1));
                    }
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}



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

using namespace std;

const long long MOD = 1000000007;

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

int main(){
    string L; cin >> L;
    long long m = (long long)(L.length());
    long long mp = modpow(3, m - 1) - 1;
    long long dp[m + 1][2];
    dp[1][0] = 2; dp[1][1] = 0;
    for (int i = 2; i <= (int)m; i++){
        string l = L.substr(i - 1, 1);
        if (l == "0"){
            dp[i][0] = dp[i-1][0];
            dp[i][1] = (dp[i-1][1] * 3) % MOD;
        }
        else {
            dp[i][0] = (dp[i-1][0] * 2) % MOD;
            dp[i][1] = (dp[i-1][0] + (dp[i-1][1] * 3) % MOD) % MOD;
        }
    }

    long long ans = (mp + dp[m][0] + dp[m][1] + 1) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int n,m,k,a[100000],i;
int main(){
  cin>>n;
  for(i=0;i<n;i++){
    cin>>a[i];
    m=max(m,a[i]);
  }
  for(i=0;i<n;i++)if(abs(m/2-a[i])<abs(m/2-k))k=a[i];
  cout<<m<<" "<<k;
}


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

int main() {
  double n,m,sum = 0;
  cin >> n >> m;
  vector<double>a(n);
  for(int i = 0;i < n;i++){
    cin >> a[i];
    sum += a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  if(a[m-1]/sum >= 1/(4*m)) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let stdin = io::stdin();
    let mut line1 = String::new();
    let _ = stdin.read_line(&mut line1);
    let mut line1 = line1.trim_right().split_whitespace();

    let _ = line1.next().unwrap().parse::<usize>().unwrap();

    let mut line2 = String::new();
    let _ = stdin.read_line(&mut line2);
    let line2 = line2.trim_right().split_whitespace();

    let mut flowers = line2.map(|s| s.parse::<usize>().unwrap()).collect::<Vec<usize>>();

    let mut n = 0;
    loop {
        let mut now = false;
        let mut flag = false;
        for flower in flowers.iter_mut() {
            let degradable = is_degradable(*flower);
            if !now && degradable {
                n += 1;
            }

            if degradable {
                flag = true;
                *flower = *flower - 1;
            }

            now = degradable;
        }

        if !flag { break; }
    }
    println!("{}", n);
}



fn is_degradable(num: usize) -> bool {
    if num > 0 {
        true
    } else {
        false
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const int MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

ll n,ans=0;

void dfs(ll now,int bit) {
    if(now > n) return;
    if(bit == 7) ans++;
    dfs(now*10+3,bit|1);
    dfs(now*10+5,bit|2);
    dfs(now*10+7,bit|4);
}

int main () {
    cin>>n;
    dfs(0,0);
    cout<<ans<<endl;
}

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

int main() {
  int N,A;
  cin >> N;
  bool ans = true;
  for (int i =0 ; i<N ; i++ ){
    cin >> A;
    if ( A%2 ==0 && A%3 !=0  && A%5 !=0){
      ans = false;
    }
  }
  
  if (ans){
    cout << "APPROVED" << endl;
  }
  else {
    cout << "DENIED" << endl;
  }
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
using namespace std;
int main() {
	long long int n, k;
	cin >> n >> k;
	cout << min(n % k, abs(n % k - k)) << endl;
		return 0;
}


Measured memory_bytes: 3564
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[60];
int main(){
	scanf("%s",s+1);int n=strlen(s+1);
	for(int i=1;i<=(n-8);i++)printf("%c",s[i]);cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
using namespace std;
#define INF 1000000007
using P = pair<int, int>;
using ll = long long;
int main(){
    int n;
    cin>>n;
    int a,b;
    cin>>a>>b;
    cout<<min(a*n,b)<<endl;
    return 0;
}



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

using namespace std;

int main() {
    const int MAX_N = 100;
    int n, l[2 * MAX_N];

    cin >> n;

    for (int i = 0; i < 2 * n; i++) {
        cin >> l[i];
    }

    sort(l, l + 2 * n);

    int sum = 0;
    for (int i = 0; i < 2 * n; i += 2) {
        sum += l[i];
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <type_traits>
#include <map>

using namespace std;

int64_t n, a, b, c, d;
// int64_t low_limit;

vector<unordered_map<int64_t, int64_t>> dp(2);

// vector<int64_t> divs = {2, 3, 5};

int64_t GetAns(int64_t x, int state, int64_t limit = -1) {
    if (x <= 0) {
        return 0;
    }

    /*if (x < low_limit) {
        return x * d;
    }*/

    auto it = dp[state].find(x);
    if (it != dp[state].end()) {
        return it->second;
    }

    int64_t result = numeric_limits<int64_t>::max() / 2;
    if (result / x > d) {
        result = x * d;
    }
    
    if (state == 0) {
        for (int i = -4; i < 4; ++i) {
            if (x + i < limit) {
                result = min(result, d * abs(i) + GetAns(x + i, 1 - state));
            }
        }
    } else {
        if (x % 2 == 0) {
            result = min(result, a + GetAns(x / 2, 1 - state, x));
        }
        if (x % 3 == 0) {
            result = min(result, b + GetAns(x / 3, 1 - state, x));
        }
        if (x % 5 == 0) {
            result = min(result, c + GetAns(x / 5, 1 - state, x));
        }
    }

    dp[state][x] = result;
    return result;
}

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

#ifdef TEST
    std::freopen("../input.txt", "r", stdin);
    // std::freopen("../output.txt", "w", stdout);
#endif

    int t;
    cin >> t;
    for (int test = 0; test < t; ++test) {
        cin >> n >> a >> b >> c >> d;

        /*low_limit = numeric_limits<int64_t>::max();
        low_limit = min(low_limit, 2 * a / d);
        low_limit = min(low_limit, 3 * b / 2 / d);
        low_limit = min(low_limit, 5 * c / 4 / d);*/

        dp[0].clear();
        dp[1].clear();

        auto ans = GetAns(n, 0, n + 5);

        cout << ans << endl;
    }

    return 0;
}


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

const int INF = 1 << 30;

class State
{
public:
  int b, p, j;
  State(int _b, int _p, int _j)
    :b(_b), p(_p), j(_j) {}
};

int main()
{
  int n;
  while (cin >> n) {
    if (n == 0)
      break;

    vector<vector<int> > bill(2, vector<int>(n));
    for (int i = 0; i < 2; ++i) {
      for (int j = 0; j < n; ++j)
	cin >> bill[i][j];
    }

    int ans = INF;
    queue<State> que;
    que.push(State(0, 0, 0));
    que.push(State(1, 0, 0));
    vector<vector<int> > dp(2, vector<int>(n, INF));
    while (!que.empty()) {
      State st = que.front();
      que.pop();

      if (st.p == n-1 && bill[st.b][st.p] != 2) {
	ans = min(ans, st.j);
	continue;
      }

      if (dp[st.b][st.p] <= st.j)
	continue;
      dp[st.b][st.p] = st.j;

      if (bill[st.b][st.p] == 0) {
	for (int i = 0; i <= 2; ++i) {
	  if (st.p + i >= n)
	    continue;
	  if (dp[st.b^1][st.p+i] > st.j+1)
	    que.push(State(st.b^1, st.p+i, st.j+1));
	} 
      } else if (bill[st.b][st.p] == 1) {
	while (st.p+1 < n && bill[st.b][st.p+1] == 1)
	  ++st.p;

	if (st.p == n-1) {
	  ans = min(ans, st.j);
	  continue;
	}

	for (int i = 0; i <= 2; ++i) {
	  if (st.p + i >= n)
	    continue;

	  if (dp[st.b^1][st.p+i] > st.j+1)
	    que.push(State(st.b^1, st.p+i, st.j+1));
	} 
      } else {
	while (st.p >= 0 && bill[st.b][st.p] == 2)
	  --st.p;
	if (st.p < 0)
	  continue;
	for (int i = 0; i <= 2; ++i) {
	  if (st.p + i >= n)
	    continue;
	  if (dp[st.b^1][st.p+i] > st.j+1)
	    que.push(State(st.b^1, st.p+i, st.j+1));
	} 
      }
    }

    if (ans == INF)
      cout << "NA" << endl;
    else
      cout << ans << endl;

  }
  return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a[]=new int[5];
		for(int i=0;i<5;i++) {
			a[i]=scan.nextInt();
		}
		for(int i=0;i<5;i++) {
			if(a[i]==0)System.out.println(i+1);
		}
	}

}


Measured memory_bytes: 35596
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
 
void solve(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>> arr(h,vector<char>(w,0));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++)
            cin>>arr[i][j];
    }
    vector<vector<int>> dp(h,vector<int>(w,0));
    dp[0][0]=1;
    for(int i=1;i<h;i++)
        dp[i][0]=(arr[i-1][0]=='#')?0:dp[i-1][0];
    for(int i=1;i<w;i++)
        dp[0][i]=(arr[0][i-1]=='#')?0:dp[0][i-1];
    for(int i=1;i<h;i++){
        for(int j=1;j<w;j++){
            int x=(arr[i-1][j]=='#')?0:dp[i-1][j];
            int y=(arr[i][j-1]=='#')?0:dp[i][j-1];
            dp[i][j]=(x+y)%mod;
        }
    }
    cout<<dp[h-1][w-1];
}

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

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

int main(){
  int N;
  cin>>N;
  int line[N];
  int sum=0;
  
  for(int i=0;i<N;i++){
    cin>>line[i];
    sum+=line[i];
  }
  int hantei=0;
  
  for(int i=0;i<N;i++){
    if(sum-line[i]<=line[i]){
      hantei++;
    }
  }
  if(hantei==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256