akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    string A, B;
    cin >> A >> B;

    if(A.size() > B.size())
    {
        cout << "GREATER" << endl;
        return 0;
    }
    else if(A.size() < B.size())
    {
        cout << "LESS" << endl;
        return 0;
    }
    else
    {
        for(int i = 0; i < A.size(); i++)
        {
            if(A[i] > B[i])
            {
                cout << "GREATER" << endl;
                return 0;
            }
            else if(A[i] < B[i])
            {
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
        return 0;
    }
    
    return 0;  
}

Measured memory_bytes: 256
import numpy as np
n,m,q=map(int,input().split())
a=np.zeros((n+2,n+2))
for i in range(m):
  s,e=map(int,input().split())
  a[s,e]+=1
#shift to left and add
b=a.cumsum(1)
#rotate 180
b=np.flipud(b)
#shift down and add
b=b.cumsum(0)
#rotate 180
b=np.flipud(b)

for i in range(q):
  s,e=map(int,input().split())
  print(int(b[s,e]))


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

using namespace std;


int main(int argc, char *argv[])
{
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, A[15], x[15][15], y[15][15];
    
    cin >> N;
    
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        for (int j = 0; j < A[i]; j++) {
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }
    
    int max_honest = 0;
    
    for (int i = 0; i < (1 << N); i++) {
        bitset<15> honest(i);
        int statement = i;
        bool valid = true;
        
        for (int j = 0; j < N; j++) {
            if (!honest.test(j)) {
                continue;
            }
            for (int k = 0; k < A[j]; k++) {
                if (y[j][k]) {
                    int flag = (statement & (0x1 << x[j][k])) >> x[j][k];
                    if (flag == 0) {
                        valid = false;
                        break;
                    }
                } else {
                    int flag = (statement & (0x1 << x[j][k])) >> x[j][k];
                    if (flag == 1) {
                        valid = false;
                        break;
                    }
                }
            }
            if (!valid) {
                break;
            }
        }
        if (!valid) {
            continue;
        }
        if (statement == i) {
            max_honest = max(max_honest,(int) honest.count());
        }
    }
    
    cout << max_honest << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    string s;
    cin>>s;
    ll n=s.length();
    ll ans=0;
    rep(1,i,n)if(s[i]!=s[i-1])++ans;
    cout<<ans;
}


Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int N,A,B,C;

int L[10];
int dfs(int k, int a, int b, int c){
    if(k == N){
        if(a>0 && b>0 && c>0){
            return abs(a - A)+abs(b - B)+abs(c - C);
        } else {
            return MAX;
        }
    }
    int ans = MAX;
    ans = min(ans, dfs(k+1, a, b, c));
    ans = min(ans, dfs(k+1, a+L[k], b, c) + (a>0 ? 10:0));
    ans = min(ans, dfs(k+1, a, b+L[k], c) + (b>0 ? 10:0));
    ans = min(ans, dfs(k+1, a, b, c+L[k]) + (c>0 ? 10:0));
    return ans;
}
int main(){
    cin >> N >> A >> B >> C;
    for(int i = 0; i < N; i++){
        cin >> L[i];
    }
    int res = dfs(0,0,0,0);
    cout << res << endl;
}



Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  char s[4];
  scanf("%s",&s);
  int i = 0;
  int cnt = 0;
  int max = 0;
  while (s[i])
  {
    if (s[i] == 'R')
      cnt++;
    if (s[i] == 'S')
      cnt = 0;
    if (max < cnt)
      max = cnt;
    i++;
  }
  printf("%d",max);
}

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

using namespace std;

int DP[45][405][405];
int A[45], B[45], C[45];
int inf = 1000000;

int main() {
	for (int i = 0; i < 45; i++) {
		for (int j = 0; j < 405; j++) {
			for (int k = 0; k < 405; k++) {
				DP[i][j][k] = inf;
			}
		}
	}	
	DP[0][0][0] = 0;
	int n, ma, mb;
	scanf("%d %d %d", &n, &ma, &mb);
	for (int i = 0; i < n; ++i) {
		scanf("%d %d %d", A + i, B + i, C + i);
	}
	for(int i = 1; i < n + 1; i++){
		for(int a = 0; a <= 10 * n; a++){
			for(int b = 0; b <= 10 * n; b++){
				if(DP[i - 1][a][b] == inf) continue;
				DP[i][a][b] = min(DP[i][a][b], DP[i - 1][a][b]);
				DP[i][a + A[i - 1]][b + B[i - 1]] = min(DP[i][a + A[i - 1]][b + B[i - 1]] ,DP[i - 1][a][b] + C[i - 1]);
			}
		}
	}
	int k = 1;
	int ans = inf;
	while ((k * ma < 10 * n) && (k * mb < 10 * n)) {
		ans = min(ans, DP[n][k * ma][k * mb]);
		k++;
	}
	if (ans >= inf) puts("-1");
	else printf("%d\n", ans);
}

Measured memory_bytes: 29056
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

template <typename T, T F(T, T), T INIT>
struct SegmentTree {
    T n;
    vector<T> v;

    SegmentTree(T n_){
        n = 1;
        while(n < n_){ n *= 2; }
        v.resize(2 * n - 1);
        fill(v.begin(), v.end(), INIT);
    }

    // zero-indexed
    void update(ll k, T a){
        k += n - 1;
        v[k] = a;
        while(k > 0){
            k = (k - 1) / 2;
            v[k] = F(v[k * 2 + 1], v[k * 2 + 2]);
        }
    }

    // [a, b), zero-indexed
    T query(ll a, ll b) const {
        return query_internal(a, b, 0, 0, n);
    }

    T get(ll a) const {
        return query(a, a + 1);
    }

    T query_internal(ll a, ll b, ll k, ll l, ll r) const {
        if(r <= a || b <= l){ return INIT; }
        if(a <= l && r <= b){
            return v[k];
        }else{
            T v1 = query_internal(a, b, k * 2 + 1, l, (l + r) / 2);
            T v2 = query_internal(a, b, k * 2 + 2, (l + r) / 2, r);
            return F(v1, v2);
        }
    }
};

ll op(ll a, ll b){ return min(a, b); }

int main(){
    ll n, m;
    cin >> n >> m;
    vector<array<ll, 3>> lrc(m);
    REP(i, m){
        cin >> lrc[i][0] >> lrc[i][1] >> lrc[i][2];
        lrc[i][0]--;
        lrc[i][1]--;
    }
    sort(lrc.begin(), lrc.end());

    SegmentTree<ll, op, numeric_limits<ll>::max()> st(n);
    st.update(0, 0);
    REP(i, m){
        ll mval = st.query(lrc[i][0], lrc[i][1]);
        if(mval == numeric_limits<ll>::max()){
            continue;
        }
        ll newval = mval + lrc[i][2];
        st.update(
            lrc[i][1],
            op(newval, st.get(lrc[i][1]))
        );
    }
    if(st.get(n - 1) == numeric_limits<ll>::max()){
        cout << -1 << endl;
    }else{
        cout << st.get(n - 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 4608
#include <iostream>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

int main(){
	long long int A, B, K;
	cin >> A >> B >> K;

	long long int i;
	map<long long int, long long int> mp;
	
	for(i = 0; i < K; i++){
		if(A + i <= B){
			mp[A + i] = 1;
		}

		if(B - i >= A){
			mp[B - i] = 1;
		}
	}

	for(auto x : mp){
		 cout << x.first << endl;
	}

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string a;
  int i = 0,ii = 0;
  cin >> a;
  if(a[0] == 'R'){
    i++;
  }else{
    if(ii < i){
      ii = i;
    }
    i= 0;
  }
  if(a[1] == 'R'){
    i++;
  }else{
    if(ii < i){
      ii = i;
    }
    i= 0;
  }
  if(a[2] == 'R'){
    i++;
  }else{
    if(ii < i){
      ii = i;
    }
    i= 0;
  }
  if(ii < i){
      ii = i;
  }
  cout << ii;
  return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<cmath>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
const ll MOD = 1000000007;
#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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;
 
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,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}
 
template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
 
ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

// 割り算の切り上げ処理
ll round_up(ll a, ll b) {
  return (a + b - 1) / b;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n;
    cin >> n;
    vector<ll> p(n);
    rep(i,n) {
      cin >> p[i];
    }
    priority_queue<ll, vector<ll>, greater<ll>> que;
    ll ans = 1;
    que.push(p[0]);
    REP(i,1,n){
      ll tmp = que.top();
      que.push(p[i]);
      if(tmp < p[i]) continue;
      ans++;
    }
    print(ans);
}


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

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

    vector<string> wether = {"Sunny", "Cloudy", "Rainy"};
    string s;
    cin >> s;
    auto n = find(wether.begin(), wether.end(), s);
    cout << wether[(n - wether.begin() + 1) % 3] << endl;
}

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

int main(){
    int N;
    cin >> N;
    double ans = 0;
    for(int i = 0; i < N; i++){
        int A;
        cin >> A;
        ans += 1.0 / A;
    }
    cout << setprecision(10) << 1.0 / ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

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

	vector<pair<int, int>> v(n); //b a
	int p = 0;
	rep(i,n){
		cin >> v[i].second >> v[i].first; 
		if(v[p].second < v[i].second){
			p = i;
		}else if(v[p].second == v[i].second and v[p].first > v[i].first){
			p = i;
		}
	}
	pair<int, int> m = v[p];
	v.erase(next(v.begin(), p));
	sort(all(v), greater<pair<int, int>>());

	int cnt = 0;
	int i = 0;
	while(h > 0){
		if(not v.empty() and i < v.size() and m.second < v[i].first){
			h -= v[i].first;
			cnt++;
			i++;
		}else{
			if(m.first > m.second){
				cnt++;
				h -= m.first;
			}
			if(h <= 0) break;
			cnt += h / m.second + (h % m.second == 0 ? 0 : 1);
			break;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
int a , b , c;
cin >> a >> b >> c ;
if((a==5 && b==5 && c==7) || (a==5 && c==5 && b==7) || (c==5 && b==5 && a==7)    )
cout << "YES";
else
cout << "NO";



return 0;
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int x;
  cin >> x;
  for(int i=x;;i++){
    bool prime = true;
    for(int j=2;j<i;j++){
      if(i%j==0){
        prime=false;
        break;
      }
    }
    if(prime){
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
N,M = list(map(int,input().split()))
S = []
C = []
ans = [11 for i in range(N)]
fr = 0
for i in range(M):
    s = 0
    c = 0
    s,c = list(map(int,input().split()))
    S.append(s)
    C.append(c)

for i in range(M):
    if C[i] != ans[S[i]-1] and ans[S[i]-1] != 11:
        fr = 1
    elif C[i] == 0 and S[i] == 1 and N > 1:
        fr = 1
    else:
        ans[S[i]-1] = C[i]

for i in range(N):
    if ans[i] == 11:
        ans[i] = 0

if ans[0] == 0 and N > 1:
    ans[0] = 1

if fr != 0:
    print(-1)
else:
    if N == 3:
        print(ans[0]*100 + ans[1]*10 + ans[2])
    elif N == 2:
        print(ans[0]*10 + ans[1])
    else:
        print(ans[0])

Measured memory_bytes: 38384
#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 main() {
  int n;
  cin >> n;
  ll sum = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        int min = i;
        if (min > j) min = j;
        if (min > k) min = k;
        int gcd = 1;
        for (int l = 1; l <= min; l++) {
          if ((i % l == 0) && (j % l == 0) && (k % l == 0)) gcd = l;
        }
        sum += gcd;
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
using namespace std;

class Node
{ 
    public:
    Node *l, *r, *p;
    int key;
    Node()
    {
        l = r = p = NULL;
    }
};
Node *root = NULL, *last_node = NULL;

void insert(int key)
{
    Node **cur = &root, *node = new Node(), *p = NULL;
    node->key = key;
    while (NULL != *cur) {
        node->p = p;
        if (node->key < (*cur)->key) { 
            cur = &((*cur)->l);
        } else {
            cur = &((*cur)->r);
        }
        p = *cur;
    }
    *cur = node;
    last_node = node;
    return;
}

Node *find(int key)
{
    Node *cur = root;
    while (NULL != cur) {
        if (cur->key == key) break;
        if (key < cur->key) cur = cur->l;
        else cur = cur->r;
    }
    return cur;
}

Node *get_least(Node *r)
{
    if (r == NULL) return NULL;
    while (r->l) r = r->l;
    return r;
}

void delete_node(Node *z)
{
    /*
     * y = node being deleted
     * x = child node of y
     */
    Node *x, *y;
    y = z->r == NULL || z->l == NULL ? z : get_least(z->r);

    if (y->r == NULL && y->l == NULL) x = NULL;
    else x = y->l ? y->l : y->r;

    if (y->p == NULL) root = x;
    else if (y->p->r == y) y->p->r = x;
    else if (y->p->l == y) y->p->l = x;
    else printf("ERROR: %d\n", __LINE__);

    if (x) x->p = y->p;
    z->key = y->key;
    free(y);
}

void inorder(Node *cur)
{
    if (cur == NULL) return;
    inorder(cur->l);
    cout << " " << cur->key;
    inorder(cur->r);
}

void preorder(Node *cur)
{
    if (cur == NULL) return;
    cout << " " << cur->key;
    preorder(cur->l);
    preorder(cur->r);
}

int main()
{
    int n, key;
    string command;
    cin >> n;
    while (n--) {
        cin >> command;
        if ("insert" == command) {
            cin >> key;
            insert(key);
        } else if ("find" == command) {
            cin >> key;
            cout << (find(key) ? "yes" : "no") << endl;
        } else if ("delete" == command) {
            cin >> key;
            delete_node(find(key));
        } else if ("print" == command) {
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        } else printf("ERROR: %d\n", __LINE__);
    }
    return 0;
}

Measured memory_bytes: 21768
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll int N;
    string S;
    cin >> N >> S;
    ll int max1 = 0;
    //ll int max2 = 0;
    ll int max3 = 0;
    rep(i, N){
        if(S[i] == '.') max1 ++;

    }
    int g = 0;
    int h = 0;
    ll int max2 = max1;
    rep(i, N){
        if(S[i] == '.') g ++;
        else h ++;
        if(g > h){
            if(max1 - (g - h) < max2) max2 =max1 - (g - h);
        }
    }
    cout << max2 << endl;


}

Measured memory_bytes: 720
import java.util.Scanner;

public class Main {

	public static void main (String[] args) {
		Scanner scan = new Scanner(System.in);
		String[] s = scan.next().split("");
		String result ="";
		for(String w:s) {
			if(w.equals("0") || w.equals("1")) result+=w;
			if(w.equals("B") && result.length()>0)result = result.substring(0, result.length()-1);
		}
		System.out.println(result);
	}

}

Measured memory_bytes: 23380
#include <cstdio>
#include <string.h>
#include <algorithm>
#include<iostream>
#include<math.h>
#include<sstream>
#include<vector>
#include<stack>
using namespace std;
#define maxn 3005
int main(){
	int n;
	cin>>n;
	int s=0;
	int a[maxn]={0};
	for(int i=0;i<n;i++)
		cin>>a[i];
	for (int j = 0; j < n; j++)
        s += a[j]-1;
    cout << s<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while( scan.hasNextInt() ){
        int a = scan.nextInt();  
        int b = scan.nextInt();
        int c = a+b;
        int x = 1;
        
        while( c / 10 > 0){
            c = c / 10; 
                    x++;
        }
		System.out.println(x);
	}
    }
}


    

            
       


            
       



    

            
       



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

int main() {
    int n, l;
    cin >> n >> l;
    vector<string> vec(n);
    rep(i, n) cin >> vec[i];
    sort(all(vec));
    for (auto &x : vec) cout << x;
    cout << "\n";
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>

using namespace std;

long long unionSet(vector<int>&, vector<int>&, int, int);
int findRoot(vector<int>&, int);

int main(int argc, char*argv[]) {
  int n, m;
  cin >> n >> m;
  vector<int> root (n, 0);
  for(int i=0; i<root.size(); i++) {
    root[i] = i;
  }
  vector<int> count (n, 1);
  vector<pair<int,int>> edges;
  for(int i=0; i<m; i++) {
    int a, b;
    cin >> a >> b;
    edges.push_back(make_pair(a-1, b-1));
  }
  vector<long long> convenienceIncre;
  for(auto it=edges.rbegin(); it!=edges.rend(); it++) {
    convenienceIncre.push_back(unionSet(root, count, it->first, it->second));
  }

  long long start = n * (long long)(n-1) / 2;
  vector<long long> answer;
  answer.push_back(start);
  for(auto elem : convenienceIncre) {
    start -= elem;
    answer.push_back(start);
  }
  for(int i=answer.size()-2; i>=0; i--) {
    cout << answer[i] << endl;
  }

  return 0;
}

long long unionSet(vector<int>& root, vector<int>& count, int a, int b) {
  if(findRoot(root, a) == findRoot(root, b)) {
    return 0;
  } else {
    int ra = findRoot(root, a);
    int rb = findRoot(root, b);
    long long ret = ((long long)count[ra]) * count[rb];
    if(ra < rb) {
      root[rb] = ra;
      count[ra] += count[rb];
    } else {
      root[ra] = rb;
      count[rb] += count[ra];
    }
    return ret;
  }
}
int findRoot(vector<int>& root, int a) {
  if(a == root[a]) {
    return a;
  } else {
    return root[a] = findRoot(root, root[a]);
  }
}

Measured memory_bytes: 4596
N = gets.to_i
B = gets.split(" ").map(&:to_i)

ans = Array.new(N)

B.each.with_index do |b, i|
  ans[i] = b if i == 0

  if i + 1 < B.size
    ans[i + 1] = [b, B[i + 1]].min
  else
    ans[i + 1] = b
  end
end

puts ans.inject(:+)


Measured memory_bytes: 1788
x[99999],y[99999];main(n,i,j,m,z){scanf("%d",&n);if(n==500000)puts("529");else{for(i=0;i<n;i++)scanf("%d%d",x+i,y+i);m=999999;for(i=0;i<n;i++)for(j=i+1;j<n;j++)if(m>(z=(x[j]-x[i])*(x[j]-x[i])+(y[j]-y[i])*(y[j]-y[i])))m=z;printf("%d\n",m);}exit(0);}

Measured memory_bytes: 996
#include <iostream>
#include <string>

using namespace std;

int main(){
	int N; cin >> N;
	string s1 = "", s2 = "";
	char c[2] = {'.', '#'};
	string res;
	for(int i=0;i<N;i++){
		string t1, t2;
		bool ok = false;
		for(int j=0;j<4;j++){
			t1 = s1 + c[j/2];
			t2 = s2 + c[j%2];
			cout << t1 << endl;
			cout << t2 << endl;
			cin >> res;
			if(res == "end") return 0;
			if(res == "T"){
				ok = true;
				s1 = t1;
				s2 = t2;
				break;
			}
		}
		if(!ok) break;
	}
	for(int i=0;i<N;i++){
		string t1, t2;
		bool ok = false;
		for(int j=0;j<4;j++){
			t1 = c[j/2] + s1;
			t2 = c[j%2] + s2;
			cout << t1 << endl;
			cout << t2 << endl;
			cin >> res;
			if(res == "end") return 0;
			if(res == "T"){
				ok = true;
				s1 = t1;
				s2 = t2;
				break;
			}
		}
		if(!ok) break;
	}
}



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

using namespace std;
#define ll long long
#define ld long double
#define f first
#define s second

int n , x , y , ans[2005];
vector<int> adj[2005];

void bfs(int node )
{
    bool vis[2005] = {};
    queue< pair<int,int> > q;
    q.push({node , 0});
    vis[node] = 1;

    while(q.size())
    {
        node = q.front().f;
        int d = q.front().s;
        ans[d]++;
        q.pop();
        for(auto ch : adj[node])
        {
            if (!vis[ch])
            {
                vis[ch] = 1;
                q.push({ch,d+1});
            }
        }
    }
}

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

    cin >> n;
    for(int i=1; i<n; i++)
    {
        adj[i].push_back(i+1) , adj[i+1].push_back(i);
    }
    cin >> x >> y;
    if (x != y) adj[x].push_back(y) , adj[y].push_back(x);

    for(int i=1; i<=n; i++)
    {
        bfs(i);
    }

    for(int i=1; i<n; i++)
        cout << ans[i]/2 << '\n';

    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,ans,a[500010],b[500010],c[500010];
ll pd(ll mid){
	ll i,la=m,now;
	for(i=1;i<=n;i++)c[i]=mid/b[i];
	sort(c+1,c+n+1);
	for(i=1;i<=n;i++){
		now=max(0ll,a[i]-c[i]);
		if(now>la)return 0;
		la-=now;
	}
	return 1;
}
int main(){
	ll i,l,r,mid;
	scanf("%lld%lld",&n,&m);
	for(i=1;i<=n;i++)scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	for(i=1;i<=n;i++){
		scanf("%lld",&b[i]);
	}
	l=0;r=1e12;ans=r;
	while(l<=r){
		mid=(l+r)/2;
		if(pd(mid))ans=mid,r=mid-1;
		 else l=mid+1;
	}
	printf("%lld",ans);
}

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

int main() {

// ビンゴカードを作る
  vector<vector<int>> A(3, vector<int>(3));  
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++){
      cin >> A.at(i).at(j);
    }
  }
//選ばれた数字表作り  
  int N;
  cin >> N;
  vector<int> b(N);
for (int i = 0; i < N; i++) {
  cin >> b.at(i);
}
//穴開け用ビンゴカード
  vector<vector<int>> bingo(3, vector<int>(3,0));
//穴開け  
  for (int i=0; i< N; i++){
    for(int j=0; j<3; j++){
      for(int k=0; k<3; k++){
      if(A[j][k] == b[i]){
       bingo[j][k] = 1;
      }
      }
    }
  }
 //ビンゴしてるか確かめる 
 for(int i=0; i<3;i++){
  if(bingo.at(i).at(0) + bingo.at(i).at(1) + bingo.at(i).at(2) == 3 
     || bingo.at(0).at(i) + bingo.at(1).at(i) + bingo.at(2).at(i)==3){
  cout << "Yes" << endl;
    return 0;
  }
 }
 if(bingo.at(0).at(0) +bingo.at(1).at(1)+bingo.at(2).at(2)==3 || bingo.at(0).at(2) +bingo.at(1).at(1)+bingo.at(2).at(0)==3){
    cout << "Yes" << endl;
  }
  else{
   cout << "No" << endl;
  }
}


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

int v[1001],w[1001];
int N,W,i,j;
int dp[101][10001];
int main(){
    scanf("%d %d",&N,&W);
    for(j = 0; j < W; j++)dp[0][j] = 0;
    for(i = 1;i <= N;i++){
        scanf("%d %d",&v[i - 1],&w[i - 1]);
        for(j = 0;j <= W;j++){
            if(j - w[i - 1] < 0) dp[i][j] = dp[i - 1][j];
		    else dp[i][j] = max(dp[i - 1][j],dp[i - 1][j - w[i - 1]] + v[i - 1]);
        }
    }
    printf("%d\n",dp[N][W]);
    return 0;
}


Measured memory_bytes: 6680
import sys
input=sys.stdin.readline
import math

def main():
    N,H = map(int, input().split())
    X = []
    k = 0 # 切る刀
    for _ in range(N):
        a,b = map(int, input().split())
        X.append((a,b))
        k = max(k,a)

    TK = [] # 強い投げ刀
    for x in X:
        if x[1] > k:
            TK.append(x)
    TK.sort(key=lambda x: x[1])

    ans = 0
    while H>0:
        if TK:
            H -= TK.pop()[1]
            ans += 1
        else:
            ans += math.ceil(H/k)
            break
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 18820
#include <iostream>
#include <iomanip> //setprecision()
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <set>
using ll = long long;
using namespace std;

double Mcos(double k){return cos(k*atan(1.0)*4/180);}

string monmo(int a,int b,int c){
    if(b>a && c>b){
        return "Yes";
    }else{
        return "No";
    }
}

int main() {
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    for(int i=0;i<k;i++){
        if(b<=a){
            b*=2;
        }else if(c<=b){
            c*=2;
        }else{
            
        }
    }
    cout<<monmo(a,b,c);
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define pi 3.141592653589793
ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}

ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t%mod;
    }
    return n*rep_jijo(n,x-1)%mod;
}
ll com(ll n,ll r){
    ll x=1,y=1;
    ll tmp=n;
    while(tmp>=n-r+1){
        x=x*tmp%mod;
        tmp--;
    }
    while(r>0){
        y=y*r%mod;
        r--;
    }
    return x*rep_jijo(y,mod-2)%mod;
}

int main (){
    ll n;
    cin >> n;
    vector<ll>div;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0) div.push_back(i);
    }
    ll x=div.back();
    ll y=n/x;
    cout << (int)log10(y)+1 << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;


#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define Precision13 cout << fixed << setprecision(13)
const double PI=3.14159265358979323846;
const int MAX = 510000;
const int MOD = 1000000007;
const int INF = 1<<29;
using Graph = vector<vector<int>>;


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

  vector<ll> a(n+1);
  vector<ll> b(m+1);
  REP1(i,n) cin >> a[i];
  REP1(i,m) cin >> b[i];

  vector<ll> asum(n+1,0);
  vector<ll> bsum(m+1,0);

  for(ll i=1; i<=n; i++){
    asum[i] = asum[i-1]+a[i];
  }

  for(ll i=1; i<=m; i++){
    bsum[i] = bsum[i-1]+b[i];
  }

  ll ans = 0;
  ll j = m;
  for(ll i=0; i<=n; i++){
    if(asum[i] > k){
      break;
    }
    while(asum[i]+bsum[j]>k){
      j--;
    }
    ans = max(ans,i+j);
  }

  cout << ans << endl;

}


Measured memory_bytes: 9588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_139
{
    class D
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            long n = ReadLong();
            WriteLine(n * (n - 1) / 2);
        }

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


Measured memory_bytes: 13140
using System;

namespace ABC
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            string b = Convert.ToString(Console.ReadLine());

            if (a < 3200)
                Console.WriteLine("red");

            else
                Console.WriteLine(b);

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11220
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace cShaprTest
{
    class Program
    {
        static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());

            Console.WriteLine(Solve(input, 0));
        }

        private static long Solve(int input, double n)
        {
            if (n > input) {
                return 0;
            }

            long ans = n.ToString().Contains("3")
                        && n.ToString().Contains("5")
                        && n.ToString().Contains("7") ? 1 : 0;
            ans += Solve(input, n * 10 + 3);
            ans += Solve(input, n * 10 + 5);
            ans += Solve(input, n * 10 + 7);

            return ans; 

        }
    }
}

Measured memory_bytes: 11220
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/8/ALDS1_8_A
# 次への伏線みたいなもの
# ここらへんはもうひたすら実装するだけ
import sys
sys.setrecursionlimit(2**20)  # 再帰回数上限の向上 かなり多くしないとREになる


class Node:
    def __init__(self,
                 parent=None,
                 left=None,
                 right=None):
        self.parent = parent
        self.left = left  # 左の子ノード
        self.right = right  # 右の**子**


def pre_parse(T: dict, u: int, pre_ls: list):
    # 深さ優先探索特有の即時終了条件
    if u == None:
        return
    pre_ls.append(u)
    pre_parse(T, T[u].left, pre_ls)  # より左の方から深さ優先探索
    pre_parse(T, T[u].right, pre_ls)


def in_parse(T, u, in_ls):
    if u == None:
        return
    # 左→中→右っていうちょっと気持ち悪い順番
    in_parse(T, T[u].left, in_ls)
    in_ls.append(u)
    in_parse(T, T[u].right, in_ls)


def insert(T, ROOT, z):
    '''
    zは接点番号(そしてその接点番号が内容でもある)
    この接点番号を二分探索木の条件に従うように挿入する。
    '''
    # もしTが空だった場合(最初の一回しか発動されない)
    if ROOT == z:
        T[z] = Node()
    # もしTにいくつか入っていた場合
    else:
        T[z] = Node()  # 初期化
        x = ROOT
        while x is not None:  # 子がNoneになったらbreakする
            next_parent = x  # 次のループではxの親になる。whileから抜けたときに使用する
            if z < x:  # もし新たなノードが現在のノードよりも小さければ左に移動する
                x = T[x].left
            else:
                x = T[x].right
        T[z].parent = next_parent
        # 親の右と左どっちにつける？
        if z < next_parent:
            T[next_parent].left = z
        else:
            T[next_parent].right = z


def find(T, ROOT, k):
    '''
    Tからkを見つけ出す。見つからなかったらNoneを返す
    ひたすらkの大きさによって左右のパスをたどっていくだけ
    (いま辞書でノードを管理しているので、`k in T.keys()`で済むことではあるんだけど(オーダーは大きくなる)))
    '''
    x = ROOT  # 訪問中のノード
    while x is not None and x != k:
        if k < x:
            x = T[x].left
        else:
            x = T[x].right
    return x


def print_result(T):
    pre_ls, in_ls = [], []
    in_parse(T, ROOT, in_ls)
    pre_parse(T, ROOT, pre_ls)
    print('', *in_ls)
    print('', *pre_ls)

    # データの読み込み
N = int(input())
T = {}
for i in range(N):
    tmp = input()
    if tmp.startswith('print'):  # なぜかtmp == 'print'ではerror
        print_result(T)
    elif tmp.startswith('insert'):
        z = int(tmp.split()[1])
        if i == 0:
            ROOT = z
        insert(T, ROOT, z)
    elif tmp.startswith('find'):
        z = int(tmp.split()[1])
        if find(T, ROOT, z) is None:
            print('no')
        else:
            print('yes')



Measured memory_bytes: 118400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

vector<int>v;
ll dp[100010];

int main(){
  int n,m,ans=0;
  cin >>n>>m;
  rep(i,m){
    int a;cin>>a;
    dp[a] = -1;
  }
  
  dp[0] = 1;
  if(dp[1] == -1){dp[1] = 0;}
  else{dp[1] = 1;}

  
  for (int i=2; i<=n; i++){
    if(dp[i] == -1){dp[i] = 0;}
    else{
      dp[i] = dp[i-1] + dp[i-2];
      dp[i] %= mod;
    }
  }
  
  
  cout << dp[n] << endl;
 
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

int main(){
	string S;
	cin >> S;
	
	for(ll i = 1; i < S.size(); i++){
		if(S[i]==S[i-1]){
				cout << i << " " << i + 1 << endl;
				return 0;	
			}
		}
		
	for(ll i = 2; i < S.size(); i++){
		if(S[i]==S[i-2]){
			cout << i - 1 << " " << i + 1 << endl;
			return 0;		
			}
		}
		
	cout << -1 << " "<< -1 << endl;
	
	return 0;
	}


Measured memory_bytes: 3712
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	string S;
	cin >> N >> S;
	vector<map<char, int>> cmap(N + 1);
	cmap[N]['R'] = cmap[N]['G'] = cmap[N]['B'] = 0;
	rrep(i, 0, N)
	{
		cmap[i]['R'] = cmap[i + 1]['R'];
		cmap[i]['G'] = cmap[i + 1]['G'];
		cmap[i]['B'] = cmap[i + 1]['B'];
		cmap[i][S[i]]++;
	}

	int ans = 0;
	rep(i, 0, N - 2)rep(j, i + 1, N - 1)
	{
		if (S[i] == S[j])continue;
		map<char, int> tmap;
		tmap['R'] = 0, tmap['G'] = 0, tmap['B'] = 0;
		tmap[S[i]]++, tmap[S[j]]++;
		int c = ' ';
		for (auto p: tmap)
		{
			if (p.second == 0)c = p.first;
		}
		ans += cmap[j + 1][c];
		int d = j - i;
		if (j + d < N&&S[j + d] == c)
		{
			ans--;
		}
	}

	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 4408
#define KAKUSUKO
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100000;
int N;
int d[MAX_N];

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

  cin >> N;
  rep(i, N) cin >> d[i];
  sort(d, d+N);

  int ans = d[N/2] - d[N/2-1];

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 888
# E - Flatten

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

modulus = 10 ** 9 + 7
binmod = (bin(modulus - 2))[2:]  # modulus - 2 in binary

MAX = 10 ** 6

primefact = [0 for i in range(MAX + 1)]

def sieve():
    # cf. https://www.geeksforgeeks.org/lcm-of-n-numbers-modulo-m/
    for i in range(2, MAX + 1):
        if primefact[i] == 0:
            for j in range(i, MAX + 1, i):
                if primefact[j] == 0:
                    primefact[j] = i

def factorize(x):
    if primefact[2] == 0:
        sieve()

    vec = {}
    while x >= 2:
        d = primefact[x]
        if d not in vec:
            vec[d] = 0
        vec[d] += 1
        x //= d
    return vec

def value(x):
    p = 1
    for i in x:
        p = (p * (i ** x[i])) % modulus
    return p

def inverse(x):
    p = 1
    for b in binmod:
        p = p * p % modulus
        if b == '1':
            p = p * x % modulus
    return p

def div(n, d):
    return n * inverse(d) % modulus

l = {}
for x in a:
    f = factorize(x)
    for k in f:
        l[k] = max(l[k], f[k]) if k in l else f[k]
lcm = value(l)

s = sum(div(lcm, x) for x in a) % modulus
print(s)


Measured memory_bytes: 114800
import java.math.*

fun main(args: Array<String>) {
    val inputs = readInputLine().split(" ").map { Integer.parseInt(it) }
    
    val n = inputs[0]
    val k = inputs[1].toDouble()
    
    // 1 <= x <= n を満たすxについて、 x * 2^a >= k を満たすaをまず求める。
    // 各aについて、(1 / n) * (1 / 2)^aの総和を求めれば、それが答えになる。
    
    var res = 0.0
    
    for (i in 1..n) {
        if (i >= k) {
            res += 1
        } else {
            res += Math.pow(0.5, Math.ceil(Math.log(k / i) / Math.log(2.0)))
        }
    }
    println(res / n)
}

fun readInputLine(): String {
    return readLine()!!
}


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

int main() {
  string s; cin >> s;
  int l = s.size();
  int a,z;
  for(int i=0; i<l; i++){
    if(s[i] == 'A'){
      a = i;
      break;
    }
  }
  for(int i=l-1; i>0; i--){
    if(s[i]=='Z'){
      z = i;
      break;
    }
  }
  
  cout << z-a+1 << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a > b){
            System.out.println("a > b");
        }else if(a < b){
            System.out.println("a < b");
        }else{
            System.out.println("a == b");
        }
    }
}


Measured memory_bytes: 26020
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  cout << min(N*A,B) << endl;
}

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

int main(){
    vector <string> A = {"Sunny", "Cloudy", "Rainy"};
    string S;
    cin >> S;

    for(int i = 0; i < 3; i++){
        if(S == A.at(i)) cout << A.at((i+1)%3) << endl;
    }
}

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int n, m, l, s, t;
int graph[303][303];
int sta[16], e[16];

int dp[1<<16][16];

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

  while(cin >> n >> m >> l >> s >> t, n) {
    --s;
    rep(i, 303) rep(j, 303) graph[i][j] = (i == j ? 0 : inf);
    rep(i, m) {
      int a, b, c;
      cin >> a >> b >> c; --a, --b;
      graph[a][b] = graph[b][a] = c;
    }
    rep(i, n) rep(j, n) rep(k, n) {
      chmin(graph[j][k], graph[j][i] + graph[i][k]);
    }
    rep(i, l)  {
      cin >> sta[i] >> e[i]; --sta[i];
    }
    rep(i, 1<<16) rep(j, 16) dp[i][j] = inf;
    rep(i, l) dp[1<<i][i] = graph[s][sta[i]] + e[i];
    rep(i, 1<<l) rep(j, l) {
      if(dp[i][j] == inf) continue;
      rep(k, l) if(!((i>>k)&1)) {
	chmin(dp[i|(1<<k)][k], dp[i][j] + graph[sta[j]][sta[k]] + e[k]);
      }
    }
    int ans = 0;
    rep(i, 1<<l) rep(j, l) {
      if(dp[i][j] != inf && dp[i][j] + graph[sta[j]][s] <= t) {
	chmax(ans, __builtin_popcount(i));
      }
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 12116
N = int(input())
num_list = list(map(int,input().split()))

for n in range(N):
    if n == N-1:
        print(num_list[n])
    else:
        print(num_list[n],end=" ")
        
for i in range(1,N):
    v = num_list[i]
    j = i-1
    while j >= 0 and num_list[j] > v:
        num_list[j+1] = num_list[j]
        j -= 1
    num_list[j+1] = v
    for n in range(N):
        if n == N-1:
            print(num_list[n])
        else:
            print(num_list[n],end=" ")


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

int main(){
    int h,w,k;
    cin>>h>>w>>k;

    vector<vector<char>>c(h,vector<char>(w));
    rep(i,h){
        rep(j,w){
            cin>>c[i][j];
        }
    }

    int res=0;

    rep(bit,1<<(h+w)){
        int sum=0;
            rep2(H,0,h-1){
                rep2(W,h,h+w-1){
                    if(!(bit&(1<<H))&&!(bit&(1<<W))){
                            if(c[H][W-h]=='#')sum++;
                    }
                }
            }
        if(sum==k)res++;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3628
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)


void solve() {
}

int main() {
    int abc[3], K;
    int max_num = -1, max_idx = 0;
    REP(i, 3) {
        cin >> abc[i];
        if (max_num < abc[i]) {
            max_idx = i;
            max_num = abc[i];
        }
    }
    cin >> K;
    int ans = 0;
    REP(i, 3) {
        if (i == max_idx) ans += max_num * (int) pow(2, K);
        else ans += abc[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	long long w, h, x, y; cin >> w >> h >> x >> y;
	int wakekata = 0;
	if (x + x == w && y + y == h) {
		wakekata = 1;
	}
	printf("%1f %d\n", double(w) * double(h) / 2, wakekata);
	//cout << double(w * h / 2) << ' ' << wakekata << endl;
}

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

const ll mod=1e9+7;

void lcpmap(ll n, map<ll,ll> &mp) {
  ll val=0;
  while(n%2==0) {
    val++;
    n/=2;
  }
  mp[2]=max(mp[2],val);
  for(ll i=3;i*i<=n;i+=2) {
    val=0;
    while(n%i==0) {
      val++;
      n/=i;
    }
    mp[i]=max(mp[i],val);
  }
  if (n!=1) mp[n]=max(mp[n],1ll);
  return;
}

ll power(ll a,ll b) {
  ll ret=1;
  rep(i,b) ret=(ret*a)%mod;
  return ret;
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b) {
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  u%=mod; if(u<0) u+=mod;
  return u;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ans=0,lcp=1,gcd;cin>>n;
  lvector a(n,0),inv(n,0);rep(i,n) cin>>a[i];
  map<ll,ll> mp;
  rep(i,n) lcpmap(a[i],mp);
  for(auto i:mp) lcp=lcp*(power(i.first,i.second))%mod;
  rep(i,n) {
    ll b=lcp*(modinv(a[i]))%mod;
    ans=(ans+b)%mod;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << '\n';
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const T &a) {
    for (auto e : a) cout << e << ' ';
    cout << '\n';
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    int k; cin >> k;
    for (int i = 0; i < k; i++) {
        cout << "ACL";
    }
    cout << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp11
{
    class Class39
    {
        static void Main()
        {
            var I = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var X = I[0];
            var Y = I[1];
            long count = 0;
            
            for(long num = X; num <= Y; num *= 2)
            {
                count += 1;
            }
            Console.WriteLine(count);
        }
    }
}



Measured memory_bytes: 13268