akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

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

  int n, m;
  cin >> n >> m;
  vector<int> ans(n, -1);
  rep(i, m) {
    int s, c;
    cin >> s >> c;
    s--;
    if (ans[s] != c && ans[s] != -1) {
      puts("-1");
      return 0;
    }
    ans[s] = c;
  }

  if (n == 1 && ans[0] == 0) {
    puts("0");
    return 0;
  }
  if (n == 1 && ans[0] == -1) {
    puts("0");
    return 0;
  }

  if (ans[0] == 0) {
    puts("-1");
    return 0;
  }

  if (ans[0] == -1) ans[0] = 1;
  for (int i = 1; i < n; i++) {
    if (ans[i] == -1) ans[i] = 0;
  }

  for (auto& v : ans) {
    printf("%d", v);
  }
  printf("\n");

  return 0;
}


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

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int N, S;
	static int[] c = new int[101];

	static int solve() {
		int ret = 0;
		for (int i = 1; i <= 100; ++i) {
			for (int j = i; j <= 100; ++j) {
				if (i + j <= S) continue;
				if (i == j) {
					ret += c[i] * (c[i] - 1) / 2;
				} else {
					ret += c[i] * c[j];
				}
			}
		}
		return ret;
	}

	public static void main(String[] args) throws Exception {
		while (true) {
			N = sc.nextInt();
			if (N == 0) break;
			S = sc.nextInt();
			Arrays.fill(c, 0);
			for (int i = 0; i < N; ++i) {
				c[sc.nextInt()]++;
			}
			System.out.println(solve());
		}
	}

}

Measured memory_bytes: 12000
// ボール: 区別なし, 箱：区別あり, 入れ方: 1 つ以下
#include <iostream>
using namespace std;
const int MOD = 1000000007;
const long long MAXN = 1001024;
long long fac[MAXN], finv[MAXN], inv[MAXN];

// 前処理 O(n)
void comb_init(){
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(long long i = 2; i < MAXN; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算 O(1)
// 定義できない奴は 0 を返すようにしている
long long COM(long long n, long long k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  
  comb_init();
  int n, k; cin >> n >> k;
  cout << COM(k, n) << endl;
  return 0;
}



Measured memory_bytes: 26568
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
#include <random>
#include <future>
#include <thread>
#include <utility>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define INF_L (LLONG_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
#define int long long


// booooooooooooost
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)


signed main() {

	int H, W, N;
	vector<int> a;
	vector<vector<int>> ans;
	cin >> H >> W >> N;
	for (int i = 0; i < N; ++i) {
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	ans.resize(H);
	for (int i = 0; i < H; ++i) {
		ans[i].assign(W, 0);
	}


	int currentPos = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < a[i]; ++j) {
			ans[currentPos / W][currentPos % W] = i + 1;
			++currentPos;
		}
	}
	for (int i = 0; i < H; ++i) {
		if (i % 2 == 1) {
			reverse(ans[i].begin(), ans[i].end());
		}
	}

	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cout << ans[i][j];
			if (j != W - 1) cout << " ";
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using ll = long long;
using namespace std;

void a(){
    string s,t;
    cin >> s >> t;
    cout << t << s;
}

void b(){
    ll a,b,k;
    cin >> a >> b >> k;

    if(a<=k){
        cout << 0 << " ";
        if(b>= k-a){
            cout << b-(k-a);
        }else{
            cout << 0;
        }
    }else{
        cout << a-k << " " << b;
    }
}

void c(){
    ll x;
    cin >> x;
    vector<int> so;
    so.push_back(2);
    for (int i=3;i<x*x;i++) {
        auto it = so.begin();
        bool f = true;
        while(it!=so.end()){
            if(i%*it++==0){
                f=false;
                break;
            }
        }
      	if(*--it<x){
        	if(f) so.push_back(i);
        }else{
          	cout << *it;
        	break;
        } 
    }
}
int main()
{
    c();
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int inf = 1000000000;

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

    vector< vector<int> > b(h, vector<int>(5));
    for(int i=0; i<h; i++){
      for(int j=0; j<5; j++) cin >> b[i][j];
    }
    vector< vector<int> > x = b;

    int score = 0;
    while(true){
      for(int i=0; i<h; i++){
        vector<bool> a(5, false);
        for(int j=0; j<3; j++){
          if( b[i][j] == -1 ) continue;
          if( b[i][j] == b[i][j+1] && b[i][j+1] == b[i][j+2] ){
            a[j] = true;
            a[j+1] = true;
            a[j+2] = true;
          }
        }
        for(int j=0; j<5; j++){
          if( a[j] ){
            score += b[i][j];
            b[i][j] = -1;
          }
        }
      }

      for(int j=0; j<5; j++){
        for(int i=0; i<h; i++){
          if(b[i][j] == -1){
            for(int k=i; k>=1; k--){
              b[k][j] = b[k-1][j];
            }
            b[0][j] = -1;
          }
        }
      }
      // cerr << score << endl;
      // for(int i=0; i<h; i++){
      //   for(int j=0; j<5; j++){
      //     cerr << b[i][j] << " ";
      //   }
      //   cerr << endl;
      // }

      if( x == b ) break;
      x = b;
    }
    cout << score << endl;
  }

  return 0;
}

// EOF

Measured memory_bytes: 3152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;

int main(){
  ll a,b,q;
  cin >> a >> b >> q;
  vector<ll>s(a),t(b),x(q);
  for(int i=0; i<a; i++) cin >> s[i];
  for(int i=0; i<b; i++) cin >> t[i];
  for(int i=0; i<q; i++) cin >> x[i];
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  
  for(int i=0; i<q; i++){
    ll Iter1 = lower_bound(s.begin(),s.end(),x[i])-s.begin();
    ll Iter2 = lower_bound(t.begin(),t.end(),x[i])-t.begin();
    
    double ans;
    ans = pow(pow(t[Iter2] - s[Iter1],2),0.5) + pow(pow(s[Iter1] - x[i],2),0.5);
    ans = min(ans,pow(pow(t[Iter2] - s[Iter1],2),0.5) + pow(pow(t[Iter2] - x[i],2),0.5));
    if(Iter1 >0 && Iter2>0) ans = min(ans,pow(pow(t[Iter2-1] - s[Iter1-1],2),0.5) + pow(pow(t[Iter2-1] - x[i],2),0.5));
    if(Iter1 >0 && Iter2>0) ans = min(ans,pow(pow(t[Iter2-1] - s[Iter1-1],2),0.5) + pow(pow(s[Iter1-1] - x[i],2),0.5));
    if(Iter1 >0) ans = min(ans,pow(pow(t[Iter2] - s[Iter1-1],2),0.5) + pow(pow(s[Iter1-1] - x[i],2),0.5));
    if(Iter1 >0) ans = min(ans,pow(pow(t[Iter2] - s[Iter1-1],2),0.5) + pow(pow(t[Iter2] - x[i],2),0.5));
    if(Iter2 >0) ans = min(ans,pow(pow(t[Iter2-1] - s[Iter1],2),0.5) + pow(pow(t[Iter2-1] - x[i],2),0.5));
    if(Iter2 >0) ans = min(ans,pow(pow(t[Iter2-1] - s[Iter1],2),0.5) + pow(pow(s[Iter1] - x[i],2),0.5));
    ll Ans = ans;
    cout << Ans << endl;
  }
  
}
  


Measured memory_bytes: 5704
n, m = map(int, input().split())
n -= 1
dat = list(map(int, input().split()))
iseven = True
for i in range(len(dat)):
    if dat[i] %2 == 1:
        iseven = False
if iseven:
    if m == 0:
        print(2**(n+1))
    else:
        print(0)
else:
    if n == 0:
        print(0)
    else:
        print(pow(2, n))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
using namespace std;

int main(void){
    ll N;
    cin >> N;
    ll A;
    map<ll,ll> nums;
    rep(i,N) {
      cin >> A;
      ++nums[A];
    }
    ll side = 0;
    ll side2 = 0;
    ll ans = 0;
    for(auto itr = nums.begin(); itr != nums.end(); ++itr){
        if(side != 0 && itr->second >= 2){
          side2 = itr->first;
          chmax(ans, side * side2);
          side = max(side, side2);
          if(itr->second >= 4) chmax(ans, side2 * side2);
          side2 = 0;
        }
        else if(itr->second >= 2){
           side = itr->first;
           if(itr->second >= 4) chmax(ans, side * side);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6528
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long

char s[300000];
int d[300000];
int ne[300000][26];

int main()
{
  int i,j,n,tmp,b1,now;
  scanf("%s",s);
  n=strlen(s);
  memset(ne[n],-1,sizeof(ne[n]));
  for (i=n-1;i>=0;i--)
  {
    memcpy(ne[i],ne[i+1],sizeof(ne[i]));
    ne[i][s[i]-'a']=i;
  }
  d[n]=1;
  for (i=n-1;i>=0;i--)
  {
    d[i]=2000000000;
    for (j=0;j<26;j++)
      if (ne[i][j]==-1)
      {
        d[i]=1;
      }
      else
      {
        tmp=d[ne[i][j]+1]+1;
        if (tmp<d[i]) d[i]=tmp;
      }
  }
  now=0;
  while (1)
  {
    b1=0;
    for (j=0;j<26;j++)
    {
      tmp=ne[now][j];
      if (tmp==-1)
      {
        printf("%c",'a'+j);
        b1=1;break;
      }
      else
      {
        if (d[tmp+1]+1==d[now])
        {
          printf("%c",'a'+j);
          now=tmp+1;
          break;
        }
      }
    }
    if (b1==1) break;
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 23552
while 1:
    n, r = map(int, input().split())
    if n == 0:
        break

    card = list(range(n, 0, -1))
    for _ in range(r):
        p, c = map(int, input().split())
        tmp = card[p-1:p-1+c]
        del card[p-1:p-1+c]
        card[0:0] = tmp

    print(card[0])


Measured memory_bytes: 5612
#pragma warning(disable:4996)
#include "bits/stdc++.h"
using namespace std;

using ll = long long;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define pb push_back
#define mp make_pair
#define fill(x,y) memset(x,y,sizeof(x))
#define even(x) x % 2 == 0
#define odd(x) x % 2 != 0
#define all(x) x.begin(), x.end()
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define F first
#define S second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

int qp(int a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, size_t b, Ts... ts) {
	return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}
// auto dp = make_v<int>(4, h, w);
// fill_v(dp, 0);

const ll INF_LL = (1ll << 60);
const int INF_INT = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

inline tuple<ll, ll> rotate45(tuple<ll, ll> p)
{
	ll x = get<0>(p), y = get<1>(p);
	return tuple<ll, ll>(x + y, x - y);
}

int main(void)
{
	cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);

	int N; cin >> N;
	int max_n = 0, nidx = 0;
	vector<int> as(N);
	REP(i, N) {
		int a; cin >> a;
		if (max_n < a) {
			max_n = a;
			nidx = i;
		}
		as[i] = a;
	}

	int max_r = max_n / 2;
	int ans;
	if (max_n % 2 == 0) {
		int bestabs = INT32_MAX;
		REP(i, N) {
			if (i == nidx) continue;
			int newabs = abs(max_r - as[i]);
			if (bestabs > newabs) {
				bestabs = newabs;
				ans = as[i];
			}
		}
	}
	else {
		int bestabs = INT32_MAX;
		REP(i, N) {
			if (i == nidx) continue;
			int o = as[i];
			int a = o;
			if (a > max_r) a = max_n - a;
			int newabs = abs(max_r - a);
			if (bestabs > newabs) {
				bestabs = newabs;
				ans = o;
			}
		}
	}
	cout << max_n << " " << ans << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#define rep(i,beg,end) for(int i=(beg);i<(end);i++)
using namespace std;

int dp[100004][3],gain[100004][3];
int main(){
	int n;
	cin>>n;
	rep(i,0,n){
		rep(j,0,3){
			cin>>gain[i][j];
		}
	}
	rep(i,0,3)
		dp[0][i]=gain[0][i];
	rep(i,1,n){
		dp[i][0]=max(dp[i-1][1],dp[i-1][2])+gain[i][0];
		dp[i][1]=max(dp[i-1][0],dp[i-1][2])+gain[i][1];
		dp[i][2]=max(dp[i-1][0],dp[i-1][1])+gain[i][2];
	}
	cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2])<<endl;
	return 0;
}

Measured memory_bytes: 2560
from collections import deque



n,m = map(int,input().split())
ab = [[] for _ in range(m)]
kr = [[] for _ in range(n)]
dist = [-1 for _ in range(n)]
dist[0] = 0
ans = [-1 for _ in range(n)]
qn = deque([1])
for i in range(m):
    a,b = map(int,input().split())
    a,b = min(a,b),max(a,b)
    ab[i] = [a,b]
    kr[a-1].append(b)
    kr[b-1].append(a)

dis = 1
while len(qn) > 0:
    v = qn.popleft()
    d = dist[v-1]
    for w in kr[v-1]:
        if dist[w-1] > -1:
            continue
        dist[w-1] = d + 1
        qn.append(w)
        ans[w-1] = v


#print(dist)

#ab.sort()
#print(ab)
#print(kr)

print('Yes')
for i in range(1,n):
    print(ans[i])

Measured memory_bytes: 52092
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;
int main()
{
    char s[100][100];
    char s1[100][100];
    int a,b;
   while(~scanf("%d %d",&a,&b))
   {
       for(int i = 0; i<a ;i ++)
       {
           scanf("%s",s[i]);
       }
       for(int i=0 ; i<a; i++)
        for(int j=0 ; j<b; j++)
        {
            if(s[i][j]=='.')
            {
                int cnt=0;
                if(i-1>=0&&s[i-1][j]=='#')
                    cnt++;
                if(i+1<a&&s[i+1][j]=='#')
                    cnt++;
                if(j-1>=0&&s[i][j-1]=='#')
                    cnt++;
                if(j+1<b&&s[i][j+1]=='#')
                    cnt++;
                if(i-1>=0&&j-1>=0&&s[i-1][j-1]=='#')
                    cnt++;
                if(i+1<a&&j-1>=0&&s[i+1][j-1]=='#')
                    cnt++;
                if(i-1>=0&&j+1<b&&s[i-1][j+1]=='#')
                    cnt++;
                if(i+1<a&&j+1<b&&s[i+1][j+1]=='#')
                    cnt++;
                s1[i][j]='0'+cnt;
            }
            else
                s1[i][j]='#';

        }
        for(int i=0 ; i<a; i++)
            printf("%s\n",s1[i]);


   }
}




Measured memory_bytes: 256
function main(input) {
  const tmp = input.trim().split('\n')
  const tmp2 = tmp[0].split(' ').map((n) => parseInt(n, 10))
  const h = tmp2[0]
  const n = tmp2[1]
  const a = tmp[1].split(' ').map((n) => parseInt(n, 10))

  const s = a.reduce((i, j) => i + j)

  if (s >= h) {
    console.log('Yes')
  } else {
    console.log('No')
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 37544
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll n;
  cin >> n;
  vector <ll> v(n, 0);
  rep(i, n-1) {
    ll a;
    cin >> a;
    v.at(a-1)++;
  }
  rep(i, n) cout << v.at(i) << endl;
}

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

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

    double p = 0.0;

    for(int i=1;i<n+1;++i)
    {
        int m = i;
        double pi = 1.0;
        while(m<k)
        {
            m *= 2;
            pi *= 0.5;
        }

        p += pi/n;
    }

    cout << fixed << setprecision(12);
    cout << p << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cctype>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

	string str;//1行目
	int q;//2行目、命令の数
	string command;//各命令を入れる
	int a, b;
	string p;
	string temporary_str;//文字列を一時的に入れておくため

	cin >> str;//1行目
	cin >> q;//2行目

	rep(i, q){
		cin >> command;//命令を代入

		if (command == "print"){
			cin >> a >> b;
			cout << str.substr(a, b - a + 1) << '\n';//a番目からb-a+1要素を抜き出して出力
		}
		else if (command == "reverse"){
			cin >> a >> b;
			temporary_str = str;
			for (int j = a; j < b + 1; j++){
				str[j] = temporary_str[a + b - j];//逆順にしていく
			}
		}
		else{
			cin >> a >> b >> p;
			str.erase(a, b - a + 1);//まず削除
			str.insert(a, p);//a番目の位置にstring pを挿入
		}
	}

	return 0;
}


Measured memory_bytes: 3256
#include <iostream>
#include <string.h>
#include <cstdlib>
#include <cmath>

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

using namespace std;

int main(void){
    int S, W;
    cin >> S >> W;

    if(S > W){
        cout << "safe";
    }else{
        cout << "unsafe";
    }
    
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <sstream>
#include <math.h>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;
const long long INF = 1LL<<29;
//for (int i = 0; i < N; i++){}

string s, t;

int main() {
    cin >> s >> t;
    
    int dp[s.size()+1][t.size()+1];
    memset(dp, 0, sizeof(dp));
    for(int i=0; i < s.size(); i++){
        for(int j=0; j < t.size(); j++){
            if(s[i] == t[j]){
                dp[i+1][j+1] = dp[i][j] + 1;
//                cout << i << ":" << j << " " << dp[i+1][j+1] << "Accord!" << endl;
            }else{
                dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j+1]);
                dp[i+1][j+1] = max(dp[i+1][j+1], dp[i+1][j]);
            }
        }
    }
    /*
    for(int i=0; i <= s.size(); i++){
        for(int j=0; j <= t.size(); j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */

//    cout << dp[s.size()][t.size()] << endl;

    string ans = "";
    int x = s.size();
    int y = t.size();
    while(x>0 && y>0){
        if(dp[x][y] == dp[x-1][y]){
            x--;
        }else if(dp[x][y] == dp[x][y-1]){
            y--;
        }else{
            x--;
            y--;
            ans.push_back(s[x]);
        }
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

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

using namespace std;

int main() {
    
    size_t N, K, C;
    cin >> N >> K >> C;
    string day;
    cin >> day;

    size_t k = 0;
    vector<size_t> l(K);
    for (size_t i = 0; i < N && k < K; ++i) {
        if (day[i] == 'o') {
            l[k] = i;
            ++k;
            i += C;
        }
        if (k == K) break;
    }
    
    k = 0;
    vector<size_t> r(K);
    for (int i = N - 1; i >= 0 && k < K; --i) {
        if (day[i] == 'o') {
            r[k] = i;
            ++k;
            i -= C;
        }
        if (k == K) break;
    }
    reverse(r.begin(), r.end());
    for (size_t i = 0; i < K; ++i) {
        if (l[i] == r[i]) {
            cout << l[i] + 1 << "\n";
        }
    }

    return 0;
}

Measured memory_bytes: 4996
a,b,c=map(int,input().split())
d,e,f=map(int,input().split())
g,h,i=map(int,input().split())
if b-a==e-d==h-g and c-b==f-e==i-h and\
d-a==e-b==f-c and g-d==h-e==i-f:
	print("Yes")
else:
	print("No")

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

int main() {
  int n; cin >> n;
  for (int i = 0; i <= n / 4; i++) {
    for (int j = 0; j <= n / 7; j++) {
      int m = 4 * i + 7 * j;
      if (m == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if ( abs(a-c)<=d ) {
    cout << "Yes" << '\n';
  } else if ( abs(a-b)<=d && abs(b-c)<=d ) {
    cout << "Yes" << '\n';
  } else {
    cout << "No" << '\n';
  }
  return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, f, n) for (int i = (f); i < (n); i++)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
ll const INF = 1LL << 60;

int main() {
    ll N;
    string S;
    cin >> N >> S;

    vector<ll> Ws(N, 0);
    vector<ll> Er(N, 0);

    for (int i = 0; i < N; i++) {
        if (S[i] == 'W') {
            if (i == 0)
                Ws[i] = 1;
            else {
                Ws[i] = Ws[i - 1] + 1;
            }
        } else {
            if (i == 0)
                Ws[i] = 0;
            else {
                Ws[i] = Ws[i - 1];
            }
        }
    }

    for (int i = N - 1; i >= 0; i--) {
        if (S[i] == 'E') {
            if (i == N - 1)
                Er[i] = 1;
            else {
                Er[i] = Er[i + 1] + 1;
            }
        } else {
            if (i == N - 1)
                Er[i] = 0;
            else {
                Er[i] = Er[i + 1];
            }
        }
    }

    ll ans = INF;
    for (int i = 0; i < N; i++) {
        ans = min(ans, Ws[i] + Er[i] - 1);
        // cout << Ws[i] + Er[i] - 1 << " ";
    }
    // cout << endl;
    cout << ans << endl;

    // repv(Ws) { cout << *it << " "; }
    // cout << endl;

    // repv(Er) { cout << *it << " "; }
    // cout << endl;

    return 0;
}

Measured memory_bytes: 5380
n = int(input())
s = input()
way = [0]*(n+1)
for i in range(n):
    if s[i] == "E":
        way[i+1] = way[i]+1
    else:
        way[i+1] = way[i]
key = way[-1]
ans = 10000000
for j in range(n):
    sub = j - way[j]-way[j+1] + key
    if sub < ans:
        ans = sub
print(ans)

Measured memory_bytes: 15240
def main(a: list, n: int, b: list):
    res = [[False, False, False], [False, False, False], [False, False, False]]
    for b in b:
        for i, a_row in enumerate(a):
            for j, a_col in enumerate(a_row):
                if b == a_col:
                    res[i][j] = True

    for i in range(3):
        # row
        if False not in res[i]:
            print("Yes")
            return

        # col
        if False not in [res[0][i], res[1][i], res[2][i]]:
            print("Yes")
            return

    # cross
    # ->
    if False not in [res[0][0], res[1][1], res[2][2]]:
        print("Yes")
        return

    # <-
    if False not in [res[0][2], res[1][1], res[2][0]]:
        print("Yes")
        return

    print("No")


if __name__ == "__main__":
    a = [list(map(int, input().split())) for _ in range(3)]
    n = int(input())
    b = [int(input()) for _ in range(n)]

    main(a, n, b)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 1e5 + 5;
const ll LINF = 1e18 + 5;
vector <int> G[N]; 
int n, u, v, dis[2][N];
bool vis[N];
void bfs(int u,int type)
{
	queue <int> q;
	q.push(u);
	memset(vis+1,0,n*sizeof(bool));
	vis[u] = 1;
	dis[type][u] = 0;
	while(sz(q))
	{
		int cur = q.front(); q.pop();
		for(int v : G[cur])
		{
			if(vis[v]) continue;
			vis[v] = 1;
			dis[type][v] = dis[type][cur] + 1;
			q.push(v);
		}
	}
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> u >> v;
 	for(int i=1;i<n;i++)
 	{
 		int a, b;
 		cin >> a >> b;
 		G[a].pb(b); G[b].pb(a);
 	}
 	bfs(u,0); bfs(v,1);
 	int maxn = 0;
 	for(int i=1;i<=n;i++)
 	{
 		if(dis[0][i] < dis[1][i] && dis[1][i] > maxn) maxn = dis[1][i];
 	}
 	cout << maxn-1;		
	return 0;
}


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

void solveA(){
  int a,b,c;
  cin >> a >> b >> c;

  cout << min(b/a,c) << endl;
}
void solveB(){

}
void solveC(){

}

void solveD(){
}

int main(){
  solveA();
}


Measured memory_bytes: 256
from collections import deque

n = int(input())
a = list(map(int, input().split()))

if n % 2 == 0:
    flg = True
else:
    flg = False

na = deque()
for i in range(n):
    if i % 2 == 0:
        na.append(a[i])
    else:
        na.appendleft(a[i])

na = list(na)
if flg:
    for el in na:
        print(el, end=" ")
else:
    for el in reversed(na):
        print(el, end=" ")

Measured memory_bytes: 25412
# Union-Find木（サイズ付き）
class UnionFind():
    # 初めは全ての頂点が別々の木の根
    def __init__(self, n):  # n要素で初期化
        self.parent = list(range(n)) # 親
        self.rank = [0] * n   # 木の深さ
        self._size = [1] * n # 要素が属する集合の大きさ（根の要素のみ参照すること）
        self._nsets = n  # 集合の数

    def root_of(self, x):
        children = [x]
        while self.parent[x] != x:
            x = self.parent[x]
            children.append(x)

        for ch in children:
            self.parent[ch] = x
        return x

    # xとyの属する集合を併合
    def union(self, x, y):
        rx = self.root_of(x)
        ry = self.root_of(y)
        if rx == ry:
            return
        if self.rank[rx] < self.rank[ry]: # ランクの小さい木から大きい木の根に辺を張る
            self.parent[rx] = ry  # rxをryの子とする
            self._size[ry] += self._size[rx]
        else:
            self.parent[ry] = rx
            self._size[rx] += self._size[ry]
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1
        self._nsets -= 1

    # 同じ集合に属するかどうか
    def same(self, x, y):
        return self.root_of(x) == self.root_of(y)

    # 頂点xが属する集合のサイズ
    def get_size(self, x):
        return self._size[self.root_of(x)]

    # 集合の数
    def get_nsets(self):
        return self._nsets


n, m = [int(x) for x in input().split()]
uf = UnionFind(n)
for i in range(m):
    a, b = [int(x) - 1 for x in input().split()]
    uf.union(a, b)

ans = 0
for j in range(n):
    ans = max(ans, uf.get_size(j))

print(ans)

Measured memory_bytes: 20088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MAX = 5100000;
ll gcd(ll a, ll b) {
    return (b==0) ? a : gcd(b, a%b);
}

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 以下から
const int MAX_N = 100000;
struct Edge {
    int to;
    int id;
};


vector<int> to[100005];
int n;
vector<int> dist;
void dfs(int v, int d=0, int p=-1) {
    dist[v] = d;
    for (int u: to[v]) {
        if (u == p) continue;
        dfs(u, d+1, v);
    }
}

vector<int> calcDist(int s){
    dist = vector<int>(n);
    dfs(s);
    return dist;
}
int main() {
    cin >> n;
    int s,t; cin >> s >> t;
    --s; --t;
    rep(i,n-1) {
        int a, b; cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }

    vector<int> distS = calcDist(s);
    vector<int> distT = calcDist(t);

    int mx = 0;
    rep(i,n){
        if (distS[i] < distT[i]) {
            mx = max(mx, distT[i]);
        }
    }
    int ans = mx-1;
    cout << ans << endl;
    return 0;
}


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

int main() {
    int N, K; scanf("%d%d", &N, &K);
    int A[100000]; rep(i, N) scanf("%d", &A[i]);
    sort(A, A + N);
    int ans = 1000000000;
    rep(i, N - K + 1) ans = min(ans, A[i + K - 1] - A[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4032
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    else:
        r = min(r, n-r)
        return g1[n] * g2[r] * g2[n-r] % mod
 
 
mod = 10**9+7 #出力の制限
N = 200000
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
 
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

H,W,A,B = map(int,input().split())

ans = 0
#print(x)

for i in range(0,H-A):
    ans += cmb(B+i-1,i,mod) * cmb(W+H-B-i-2,H-i-1,mod)
    ans %= mod
    #print(x)

print(ans)

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

long long mod_pow(long long x, long long n, int p)
{
	if (n == 0)return 1;
	if (n == 1)return x % p;

	long long y = mod_pow(x, n / 2, p);

	if (n % 2 == 0)return (y * y) % p;
	else return (x * ((y * y) % p)) % p;
}

int main() {
	int N;
	cin>>N;
	vector<vector<int>>D(N);
	int max_d = 0;
	for(int i=0;i<N;i++)
	{
		int d;cin>>d;
		D[d].push_back(i);
		max_d = max(max_d, d);
	}
	if (D[0].size() != 1)
	{
		cout<<0<<endl;
		return 0;
	}
	if (D[0][0] != 0)
	{
		cout << 0 << endl;
		return 0;
	}

	long long ans = 1;
	for (int i = 1; i <= max_d; i++)
	{
		ans *= mod_pow(D[i-1].size(), D[i].size(), 998244353);
		ans %= 998244353;
	}
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 5760
n=int(input())
p=list(map(int,input().split()))

ans=0
for i in range(1,n-1):
    if max(p[i-1],p[i],p[i+1])!=p[i]:
        if min(p[i-1],p[i],p[i+1])!=p[i]:
            ans += 1

print(ans)

Measured memory_bytes: 3060
def main():
    a, b = map(int, input().split())
    s = ''
    s2 = ''

    for i in range(b):
        s += str(a)
    for i in range(a):
        s2 += str(b)

    if a <= b:
        print(s)
    else:
        print(s2)
if __name__ == '__main__':
    main()

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

const double Pi = 3.1415926;

int main()
{
    long long n;
    cin >> n;
    n = n % 10;
    if (n == 3)
        cout << "bon";
    else if (n == 0 || n == 1 || n == 6 || n == 8)
        cout << "pon";
    else
        cout << "hon";

    return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (true)
		{
			int n = sc.nextInt();
			if (n == 0) break;
			int x = n / 2;
			int y = n / 2 + 1;
			int map[][] = new int[n][n];
			for (int i = 1; i <= n * n; i++)
			{
				while (map[y][x] != 0)
				{
					x -= 1;
					if (x < 0)
					{
						x = n - 1;
					}
					y = (y + 1) % n;
				}
				map[y][x] = i;
				x = (x + 1) % n;
				y = (y + 1) % n;
			}
			for (int i = 0; i < n; i++)
			{
				for (int j = 0; j < n; j++)
				{
					System.out.printf("%4d", map[i][j]);
				}
				System.out.println();
			}
		}
	}
}

Measured memory_bytes: 12000
S = list(input())
k = int(input())

alp = "abcdefghijklmnopqrstuvwxyza"
to_a = {alp[i]: 26 - i for i in range(1, len(alp))}

for i, s in enumerate(S):
    if to_a[s] > k:
        continue
    else:
        S[i] = "a"
        k -= to_a[s]
    if k == 0:
        break

k %= 26
i = alp.index(S[-1]) + k
S[-1] = alp[i]

ans = "".join(S)
print(ans)


Measured memory_bytes: 4156
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s1=scan.next();
		String s2=scan.next();
		String s3=scan.next();
		if(s1.charAt(s1.length()-1)==s2.charAt(0) && s2.charAt(s2.length()-1)==s3.charAt(0)) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 26864
#include <iostream>
#include <vector>
#include <utility>
#include <tuple>
using namespace std;

int main() {
	vector<int> order(5);
	pair<int, int> max_order = make_pair(0, -1);
	for (int i = 0; i < 5; i++) {
		int tmp;
		cin >> tmp;
		order.at(i) = tmp;
		if ((tmp % 10) != 0) {
			int dif = 10 - (tmp % 10);
			if (dif > max_order.first) {
				max_order.first = dif;
				max_order.second = i;
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < 5; i++) {
		if (i == max_order.second) {
			ans += order.at(i);
		} else {
			if (order.at(i) % 10 == 0) {
				ans += order.at(i);
			} else {
				int tmp = order.at(i);
				tmp /= 10;
				tmp *= 10;
				tmp += 10;
				ans += tmp;
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  long N, M;
  cin >> N >> M;
  long lcm = 2, a, ans;
  vector<long> data(N);
  for(int i = 0; i < N; i++){
    cin >> data.at(i);
  }
  lcm = data.at(0);
  lcm /= 2;
  for(int i = 1; i < N; i++){
    a = data.at(i);
    a /= 2;
    lcm = lcm / __gcd(lcm, a);
    lcm *= a;
  }
  for(int i = 0; i < N; i++){
    if((lcm / (data.at(i) / 2)) % 2 == 0){
      cout << 0 << endl;
      return 0;
    }
  }
  ans = M / lcm;
  if(ans % 2 == 0)ans /= 2;
  else {
    ans /= 2;
    ans += 1;
  }
  cout << ans << endl;
  return 0;
}

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


int main(){
    string W,T;
    cin >> W;
    cin >> T;

    int count=0;
    while(T!="END_OF_TEXT"){
        for(int i=0; i<T.size(); i++){
            if(T[i]>='A' && T[i]<='Z'){
                T[i]+='a'-'A';
            }
        }
        if(W==T){
            count++;
        }
        cin >> T;
    }
    cout << count << endl;


}


Measured memory_bytes: 3164
/*	[]__________[][][][]____[][][][][]__{}__[][][][]____[][][][][]__[][][][]
    []__________[]______________[]__________[]__________[]__________[]____[]
    []__________[][][][]________[]__________[][][][]____[]__________[]____[]
    []__________[]______________[]________________[]____[]__[][][]__[]____[]
    []__________[]______________[]________________[]____[]______[]__[]____[]
    [][][][]____[][][][]________[]__________[][][][]____[][][][][]__[][][][]
*/
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define endl '\n'
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define decimal(x) cout<<fixed<<setprecision(x);
bool prime[100005]; 
void Sieve(int n) {
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
} 
vector<int>grapj[100005];
bool vis[100005];
void solve()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*c,max(b*d,max(a*d,b*c)));
}	
signed main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
      // cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 5996
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class t>
using table = vector<vector<t>>;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"
  

int main() {
	while (1) {

		int K; cin >> K;
		if (!K)break;
		int sum = 0;
		for (int i = 0; i < K*(K - 1) / 2; ++i) {
			int c; cin >> c; sum += c;
		}
		cout << sum /(K-1) << endl;
	}
	return 0;
}

Measured memory_bytes: 2996
#include <stdio.h>


int main(void) {
  int x,y;
  scanf("%d%d",&x,&y);
  if((x >= 0 && x <= 8) && (y >= 0 && y <= 8)){
    printf("Yay!\n");
  }else{
    printf(":(\n");
  }

  return 0;
}


Measured memory_bytes: 128
def main():
    X, N = map(int, input().split())
    if N == 0:
        print(X)
        return

    A = [int(i) for i in input().split()]
    C = [False] * 102
    for v in A:
        C[v] = True

    d = 1000000
    ans = 0
    for i in range(102):
        if C[i] == False:
            if d > abs(X - i):
                d = abs(X - i)
                ans = i

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 61944
#include <iostream>
#include <queue>
#include <string>

using namespace std;

int main()
{
    int n, q, time;
    string name;
    cin >> n >> q;

    queue<int> T;
    queue<string> N;

    for(int i = 0; i < n; i++)
    {
        cin >> name >> time;
        N.push(name);
        T.push(time);
    }

    int process_time = 0;
    int tmp;

    while(!T.empty())
    {
        if((tmp = T.front()) > q)
        {
            T.pop(); T.push(tmp - q);
            string str = N.front();
            N.pop(); N.push(str);
            process_time += q;
        }
        else
        {
            process_time += tmp;
            cout << N.front() << " " << process_time << endl;
            T.pop(); N.pop();
        }
    }
    


    return 0;
}


Measured memory_bytes: 6088
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef _DEBUG

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 300005
#define MAX_M 55
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

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

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	// WF("output.txt");
	DF("err.txt");

	int N, A, B;
	scanf("%d %d %d", &N, &A, &B);
	printf("%d\n", min(N*A, B));
	return 0;
}

Measured memory_bytes: 256
use std::io;
use std::str::FromStr;
use std::cmp::max;

fn input_tuple() -> (usize, usize) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<usize> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input_vec() -> Vec<u64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let (n, k) = input_tuple();
    let p_vec = input_vec();
    let mut sum = 0f64;
    for i in 0..k {
        sum += (1+p_vec[i]) as f64 / 2.0;
    }
    let mut max_val = sum;
    for i in 0..(n-k) {
        sum += (1+p_vec[k+i]) as f64 / 2.0;
        sum -= (1+p_vec[i]) as f64 / 2.0;

        // println!("{}", sum);
        if sum > max_val {
            max_val = sum;
        }
    }
    println!("{}", max_val);

}


Measured memory_bytes: 8444
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
struct edge{
	int t,next;
}g[400001];
ll ans,t1,t2,t3;
int tmp,c[200001],i,j,k,n,m,tot,h[200001],flag;
void addedge(int x,int y){
	g[++tot].t=y;g[tot].next=h[x];h[x]=tot;
	g[++tot].t=x;g[tot].next=h[y];h[y]=tot;
}
void dfs(int x){
	int i;
	tmp++;
	for (i=h[x];i;i=g[i].next)
	 if (!c[g[i].t]) c[g[i].t]=3-c[x],dfs(g[i].t);
	 else if (c[g[i].t]==c[x]) flag=0;
}
int main(){
	//freopen("data.in","r",stdin);freopen("data1.out","w",stdout);
//	while (1){
		scanf("%d%d",&n,&m);
	//	if (!n) break;
		memset(h,0,sizeof(h));memset(c,0,sizeof(c));tot=0;
		for (i=1;i<=m;i++) scanf("%d%d",&j,&k),addedge(j,k);
		for (i=1,t1=t2=t3=0;i<=n;i++)
		 if (!c[i]){
		 	c[i]=flag=1;tmp=0;dfs(i);
		 	if (tmp==1) t3++;
		 	else if (flag) t2++;else t1++;
		 }
		//ans=t1*t1+2LL*t1*t2+2LL*t2*t2;
	//	ans+=(ll)n*(ll)n-(ll)(n-t3)*(ll)(n-t3);
		ans=2*t3*(ll)n-t3*t3+t1*t1+2LL*t1*t2+2LL*t2*t2;
		printf("%lld\n",ans);
//	}
	return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int maxn=2e5+5;
const int maxm=5e2+5;
const int maxq=55;
const int INF=0x3f3f3f3f;
ll sum[maxn];
ll gs(ll l,ll r)
{
    return sum[r]-sum[l-1];
}
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int x;
        for(int i=1;i<=n;i++)
        {
            scanf("%d",&x);
            sum[i]=sum[i-1]+x;
        }
        ll l=1;ll r=3;
        ll ans=-1;
        for(int i=2;i<=n-2;i++)
        {
            while(l+1<i&&abs(gs(1,l)-gs(l+1,i))>=abs(gs(1,l+1)-gs(l+2,i))) l++;
            while(r+1<n&&abs(gs(i+1,r)-gs(r+1,n))>=abs(gs(i+1,r+1)-gs(r+2,n))) r++;

            ll mx=max(gs(1,l),max(gs(l+1,i),max(gs(i+1,r),gs(r+1,n))));
            ll mn=min(gs(1,l),min(gs(l+1,i),min(gs(i+1,r),gs(r+1,n))));
            if(ans==-1) ans=mx-mn;
            else ans=min(ans,mx-mn);
        }
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> ab(n);
    rep(i,n){
        ll a, b;
        cin >> a >> b;
        ab[i] = make_pair(a, b);
    }
    sort(ab.begin(), ab.end());
    ll ans = 0;
    rep(i, n){
        ll ai = ab[i].first;
        ll bi = ab[i].second;
        ans += ai * min(bi, m);
        m -= min(bi, m);
        if (m == 0) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    int n, m; cin >> n >> m;
    vector<int> a(m), b(m);
    vector<vector<int>> c(m);

    REP(i, m) {
        cin >> a[i] >> b[i];
        REP(j, b[i]) {
            int x; cin >> x;
            --x;
            c[i].push_back(x);
        }
    }

    constexpr ll inf = 1e12;
    auto dp = make_v(m + 1, 1 << n, inf);

    dp[0][0] = 0;
    
    REP(i, m)REP(bit, 1 << n) {
        if (dp[i][bit] < inf) {
            dp[i + 1][bit] = min(dp[i + 1][bit], dp[i][bit]);

            int nbit = bit;
            REP(j, b[i]) nbit |= (1 << c[i][j]);

            dp[i + 1][nbit] = min(dp[i + 1][nbit], dp[i][bit] + a[i]);
        }
    }

    if (dp[m][(1 << n) - 1] < inf) {
        cout << dp[m][(1 << n) - 1] << endl;
    } else {
        cout << -1 << endl;
    }

    return 0;
}


Measured memory_bytes: 32512
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

/*!
@fn gcd
@brief gcd(x, y)
*/
template<class T>
T gcd(T x, T y)
{
    if (x < y) {
        swap(x, y);
    }

    if (y == 0) {
        return x;
    }

    do
    {
        T r = x % y;
        x = y;
        y = r;
    } while (y);

    return x;
}

/*!
@fn lcm
@brief lcm(x, y)
*/
template<class T>
T lcm(T x, T y)
{
    return x / gcd(x, y) * y;
}

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

    vector<ll> T(N);
    for (int i = 0; i < N; ++i) {
        cin >> T[i];
    }

    ll ans = 1;
    for (int i = 0; i < N; ++i) {
        ans = lcm(ans , T[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

template <typename Tp> inline void getint(Tp &num){
	register int ch, neg = 0;
	while(!isdigit(ch = getchar())) if(ch == '-') neg = 1;
	num = ch & 15;
	while(isdigit(ch = getchar())) num = num * 10 + (ch & 15);
	if(neg) num = -num;
}

int N, Q, k;
char S[1000005];

int main(){
	getint(N), scanf("%s", S), getint(Q);
	while(Q--){
		getint(k); ll D = 0, M = 0, DM = 0, ans = 0;
		for(register int i = 0; i < N; i++){
			if(i >= k){
				if(S[i - k] == 'D') D--, DM -= M;
				else if(S[i - k] == 'M') M--;
			}
			if(S[i] == 'D') D++;
			else if(S[i] == 'M') M++, DM += D;
			else if(S[i] == 'C') ans += DM;
		}
		printf("%lld\n", ans);
	}
	return 0;
}


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

int DFS(int n, int t) {
    int tmp = 100000;
    if (t<=5) {
        rep(i, 9) {
            int nxt = n-i*(pow(9, 6-t));
            if (nxt<0) continue;
            tmp = min(tmp, DFS(nxt, t+1)+i);
        }
        return tmp;
    }
    else if (t<=11) {
        rep(i, 6) {
            int nxt = n-i*pow(6, 12-t);
            if (nxt<0) continue;
            tmp = min(tmp, DFS(nxt, t+1)+i);
        }
        return tmp;
    }
    else {
        if (n<6) return n;
        else return 100000;
    }
}

int main() {
    int n;
    cin >> n;
    cout << DFS(n, 1) << endl;
}

Measured memory_bytes: 256