akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
using namespace std;
int N, p[5000], t[4][5000], r[4];
int main() {
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < 4; i++) {
    t[i][0] = i;
    r[i] = i;
    for (int j = 1; j <= N; j++) {
      t[i][j] = p[j - 1] - t[i][j - 1];
      if (t[i][j] < 0) {
        t[i][j] = 0;
      }
      if (j < N) {
        r[i] += t[i][j] * 2;
      } else {
        r[i] += t[i][j];
      }
    }
  }
  cout << min(r[0], min(r[1], min(r[2], r[3]))) << endl;
  return 0;
}


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

int main() {
  int N,M;
  cin >> N >> M;
  ll A[N];
  priority_queue<ll, vector<ll>, less<ll>> Q;
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    ans += A[i];
  }
  for (int i = 0; i < N; i++) {
    while (A[i] != 0) {
      Q.push(A[i] - (A[i] / 2));
      A[i] /= 2;
    }
  }
  for (int i = 0; i < M; i++) {
    ll a = Q.top();
    Q.pop();
    ans -= a;
    if (Q.empty()) {
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 35684
#include <bits/stdc++.h>
#define rep(i, x, y) for (int i = x; i <= y; i++)
#define per(i, x, y) for (int i = x; i >= y; i--)
#define lowbit(x) ((x) & (-(x)))
using namespace std;

const int N = 2e5 + 10, mod = 998244353;
int n, R[N], Mx[N], f[N];
struct node {
    int x, r;
    bool operator < (const node &t) const {
        return x < t.x;
    }
}p[N];

int get_pos(int lim) {
    int l = 1, r = n, ret;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (p[mid].x <= lim) ret = mid, l = mid + 1;
        else r = mid - 1;
    } return ret;
}

void add(int x, int val) {
    for (; x <= n; x += lowbit(x)) Mx[x] = max(Mx[x], val);
}

int query(int x) {
    int ret = 0;
    for (; x; x -= lowbit(x)) ret = max(ret, Mx[x]);
    return ret;
}

int main() {
    cin >> n;
    rep(i, 1, n) cin >> p[i].x >> p[i].r;
    sort(p + 1, p + n + 1);
    per(i, n, 1) {
        R[i] = i;
        int pos = get_pos(p[i].x + p[i].r - 1);  // 变相离散
        R[i] = max(R[i], query(pos));
        add(i, R[i]);
    }
    f[1] = 1;
    rep(i, 1, n) {
        f[R[i] + 1] = (f[R[i] + 1] + f[i]) % mod;
        f[i + 1] = (f[i + 1] + f[i]) % mod;
    }
    printf("%d\n", f[n + 1]);
    return 0;
}


Measured memory_bytes: 4096
import sys
from itertools import product,combinations
from functools import reduce,lru_cache
import heapq

def vfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:f(*x,**kwargs),*lst))

def rvfunc(f): return lambda *lst, **kwargs: list(map(lambda *x:rvfunc(f)(*x,**kwargs) if all(vfunc(lambda y:isinstance(y,list))(x)) else f(*x,**kwargs),*lst))

def reader():return vfunc(lambda l:l.split())(sys.stdin.readlines())

s=reader()
n,l=int(s[0][0]),vfunc(int)(s[1])
print(sum(vfunc(lambda args:((args[0]+args[1])>args[2]) and ((args[0]+args[2])>args[1]) and ((args[1]+args[2])>args[0]))(list(filter(lambda a:a[0]!=a[1] and a[2]!=a[1] and a[0]!=a[2],combinations(l,3))))))


Measured memory_bytes: 98624
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<=b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::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>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n, a;
    cin >> n >> a;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    rep(i, n) x[i] -= a;
    vector<ll> dp(10000);
    dp[5000] = 1;
    rep(i, n) {
        vector<ll> pre(10000);
        swap(pre, dp);
        rep(j, 10000) {
            dp[j] += pre[j];
            int nj = j + x[i];
            if (0 <= nj && nj < 10000) dp[nj] += pre[j];
        }
    }
    cout << dp[5000] - 1 << endl;
}


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

#define nl '\n'
#define F fisrt
#define S second
#define pb push_back
#define mp make_pair
#define REP(i,a,b) for(int i = a; i < b; i++)
#define ForeachTC int t; cin >> t; while(t--)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef stack<int> si;
typedef deque<int> di;
typedef pair<int,int> pi;

class Solution {
public:
    int climbStairs(int n) {
		if(n <= 2)
			return n;
		else{
			return climbStairs(n-1) + climbStairs(n-2);
		}
    }
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	//code here
	float r; cin >> r;
	cout << 2*M_PI*r;
}


Measured memory_bytes: 3796
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
using namespace std;
int main(){
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    int price=0;
    
    c*=2;

    int buy[]={a,b,c};

    if(a>c && b>c){
        // printf("a");
        while(x>0 || y>0){
            price+=c;
            x--;
            y--;
        }
    }else if((a+b)>c){
        // printf("b");
        while(x>0 && y>0){
            price+=c;
            x--;
            y--;
        }
        if(a>c){
            while(x>0){
                price+=c;
                x--;
                y--;
            }
            while(y>0){
                price+=b;
                y--;
            }
        } else if(b>c){
            while(y>0){
                price+=c;
                x--;
                y--;
            }
            while(x>0){
                price+=a;
                x--;
            }
        }else{
            while(x>0){
                price+=a;
                x--;
            }
            while(y>0){
                price+=b;
                y--;
            }
        }
    } else if(a>c){
        // printf("c");
        while(x>0){
            price+=c;
            x--;
            y--;
        }
        while(y>0){
            price+=b;
            y--;
        }
    } else if(b>c){
        while(y>0){
            price+=c;
            x--;
            y--;
        }
        while(x>0){
            price+=a;
            x--;
        }
    } else {
        // printf("d");
        while(x>0){
            price+=a;
            x--;
        }
        while(y>0){
            price+=b;
            y--;
        }
    }

    cout<<price<<endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            out.println(Math.max(a + Math.abs(b), a * b));
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufLength == -1)
                throw new InputMismatchException();
            if (bufPointer >= bufLength) {
                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (bufLength == -1)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

        public long nextLong() {
            long n = 0;

            boolean minus = false;
            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9')
                throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (isSpaceChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 21460
fun main(arr: Array<String>) {
    val a = readLine()!!.toInt()
    val b = readLine()!!.toInt()
    val c = readLine()!!.toInt()
    val x = readLine()!!.toInt()

    val ans = (0..Math.min(x/500, a)).map { c500-> (0..Math.min(x/100, b)).map { x-c500*500-it*100 }.count { it >= 0 && it % 50 == 0 && it <= 50*c } }.sum()
    println(ans)
}

Measured memory_bytes: 35496
#include <cstdio>
#include <cstring>

using llint = long long;

const int MAXN = 52;
const int MOD = 1e9+7;

int a[MAXN][MAXN];
int res[MAXN][MAXN];
int n;
llint k;

int t[MAXN][MAXN];
void mul(int a[][MAXN], int b[][MAXN], int n) {
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      t[i][j] = 0;
    }
  }

  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        t[i][j] = (t[i][j] + (llint(a[i][k]) * b[k][j]) % MOD) % MOD;
      }
    }
  }

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      a[i][j] = t[i][j];
    }
  }
}

int main() {
  scanf("%d%lld", &n, &k);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      scanf("%d", &a[i][j]);
    }
  }

  for (int i = 0; i < n; ++i) res[i][i] = 1;

  while (k > 0) {
    if (k & 1) mul(res, a, n);
    mul(a, a, n);
    k >>= 1;
  }

  llint sol = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      sol = (sol + res[i][j]) % MOD;
    }
  }

  printf("%lld\n", sol);
  return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,lis[111][111]={},d[111];
  for(int i=0;i<111;i++)d[i]=-1;
  cin>>n;
  for(int c=0;c<n;c++){
    int u,k,v;
    cin>>u>>k;
    for(int i=0;i<k;i++){
      cin>>v;
      lis[u][v]=1;
    }
  }
  queue< pair<int,int> > q;
  q.push(make_pair(1,0));
  while(!q.empty()){
    int from=q.front().first;
    int m=q.front().second;
    q.pop();
    if(d[from]==-1){
      d[from]=m;
      for(int i=1;i<=n;i++){
	if(lis[from][i])q.push(make_pair(i,m+1));
      }
    }
  }
  for(int i=1;i<=n;i++)cout<<i<<" "<<d[i]<<endl;
  return 0;
}

Measured memory_bytes: 3144
s=input()
l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
if len(set(s))==26:
    print('None')
else:
    for i in range(26):
        if l[i] not in s:
            print(l[i])
            break

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

int main() {
int a,b,c;
while (1){
cin >> a >> b;
if (a == 0 && b == 0) {break;};
if (a > b) {
c = a;
a = b;
b = c;
};
cout << a << " " << b << endl;
}
	return 0;
}

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

const int N = 25010;
const int M = 410;
const int mod = 1e9 + 7;

typedef long long LL;

inline int Pow(int x, int y) {
    int res = 1;
    for (; y; y >>= 1, x = (LL)x * x % mod) if (y & 1) res = (LL)res * x % mod;
    return res;
}

int n, k, f[N][M], g[N][M], p1[M], p2[M], frac[M], inv[M];

inline void Just_DOIT(int len = 1) {
    f[0][0] = 1;
    for (int i = 1; i <= n; i++) {
        p1[0] = f[i - 1][0], p2[0] = g[i - 1][0];
        for (int j = 1; j <= min(i - 1, k - 1); j++) {
            p1[j] = (p1[j - 1] + f[i - 1][j]) % mod;
            p2[j] = (p2[j - 1] + g[i - 1][j]) % mod;
        }
        int A = p1[min(i - 1, k - 1)], B = p2[min(i - 1, k - 1)];
        for (int j = 1; j <= min(i, k - 1); j++) {
            f[i][j] = (LL)f[i - 1][j - 1] * (k - j + 1) % mod;
            g[i][j] = (LL)g[i - 1][j - 1] * (k - j + 1) % mod;
            f[i][j] = ((LL)f[i][j] + A - p1[j - 1] + mod) % mod, g[i][j] = ((LL)g[i][j] + B - p2[j - 1] + mod) % mod;
            if (j >= len) g[i][j] = (g[i][j] + f[i][j]) % mod;
        }
    }
}

inline int Make_Your_Dream_COMETRUE(int left, int len) {
    int res = 0, t = (LL)inv[k] * frac[k - len] % mod;
    for (int i = len; i < k; i++) {
        res = (res + (LL)f[left + len][i] * t) % mod;
    }
        
    return res;
}

int A[N], lst[M], hh[N];

int main() {
    int m; scanf("%d%d%d", &n, &k, &m), frac[0] = inv[0] = 1;
    for (int i = 1; i <= k; i++) frac[i] = (LL)frac[i - 1] * i % mod, inv[i] = Pow(frac[i], mod - 2);
    for (int i = 1; i <= m; i++) scanf("%d", &A[i]);
    int tmp = 0, mx = 0;
    for (int i = 1; i <= m; i++) {
        if (lst[A[i]]) tmp = max(tmp, lst[A[i]]);
        lst[A[i]] = i, mx = max(mx, i - tmp);
    }
    int all = (LL)(n - m + 1) * Pow(k, n - m) % mod;
    if (mx >= k) {
        printf("%d\n", all);
        return 0;
    }
    if (mx == m) {
        Just_DOIT(mx); int res = 0;
        for (int i = 1; i < k; i++) res = (res + g[n][i]) % mod;
        int tmp = (LL)frac[k] * inv[k - mx] % mod;
        res = (LL)res * Pow(tmp, mod - 2) % mod;
        printf("%d\n", (all - res + mod) % mod);
        return 0;
    }
    Just_DOIT(); int left = 0, right = 0;
    for (int i = 1; i <= m; i++) {
        bool flag = true;
        for (int j = 1; j < i; j++) 
            if (A[j] == A[i]) {
                flag = false; break;
            }
        if (!flag) {
            left = i - 1; break;
        }
    } 
    for (int i = 0; i + m <= n; i++) 
        hh[i] = Make_Your_Dream_COMETRUE(i, left);
    for (int i = 1; i <= m; i++) {
        bool flag = true;
        for (int j = m - i + 2; j <= m; j++)
            if (A[m - i + 1] == A[j]) {
                flag = false; break;
            }
        if (!flag) {
            right = i - 1; break; 
        }
    }
    int res = all;
    for (int i = 0; i + m <= n; i++) 
        res = (res - (LL)hh[i] * Make_Your_Dream_COMETRUE(n - i - m, right) % mod + mod) % mod;
    printf("%d\n", res);
    return 0;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

void solve() {
  int N, K;
  cin >> N >> K;
  ll ans = 0;
  for(int b = K + 1; b <= N; b++) {
    ans += (N / b) * (b - K);
    ans += N % b < K ? 0 : (N % b - K + 1);
    if (K == 0) ans--;
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
int ans,a[35],i,n;
a[1]=1,a[2]=2,a[3]=4;
for(i=4;i<=30;i++){
a[i]=a[i-1]+a[i-2]+a[i-3];
}
while(1){
scanf("%d\n",&n);
if(n==0){
break;
}
if(a[n]%10==0){
ans=a[n]/10;
}
else{
ans=a[n]/10+1;
}
if(ans%365==0){
ans=ans/365;
}
else{
ans=ans/365+1;
}
printf("%d\n",ans);
}
return 0;
}


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

using namespace std;
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define mp make_pair
#define ld long double
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
const int N = 1e6 + 100;
int T;
ll a[N], r[N], l[N];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i <= n; i++)scanf("%d", &a[i]);
    if (n == 0) {
        if (a[0] == 1)puts("1");
        else puts("-1");
        return 0;
    }
    for (int i = n; i >= 0; i--) {
        l[i] = a[i] + (l[i + 1] + 1) / 2;
        r[i] = a[i] + r[i + 1];
    }
    if (l[0] != 1) {
        puts("-1");
        return 0;
    }
    ll ans = 1, cur = 1;
    for (int i = 1; i <= n; i++) {
        cur -= a[i - 1];
        cur = min(cur * 2, r[i]);
        ans += cur;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 6120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
string s;
cin >> s;
REP(i,s.size()){
  if ((i+1) % 2 == 1) cout << s[i];
}
cout << endl;
return 0;
}


Measured memory_bytes: 3720
H, W, M = [int(n) for n in input().split()]
H_freq = [0] * H
W_freq = [0] * W

table = []
for m in range(M):
    h, w = [int(n)-1 for n in input().split()]
    H_freq[h] += 1
    W_freq[w] += 1
    table.append((h, w))

max_h = max(H_freq)
max_w = max(W_freq)
most_freqent_h = [i for i, h in enumerate(H_freq) if h == max_h]
most_freqent_w = [i for i, w in enumerate(W_freq) if w == max_w]

count = 0
for (h, w) in table:
    if H_freq[h] == max_h and W_freq[w] == max_w:
        count += 1

if count < len(most_freqent_h) * len(most_freqent_w):
    print(max_h + max_w)
else:
    print(max_h + max_w - 1)


Measured memory_bytes: 77664
N = gets.to_i
K = gets.to_i
x = gets.split.map(&:to_i)

a, b = x.partition { |n| n <= K - n }

distance = 0
distance += a.map { |n| n * 2 }.inject(&:+) unless a.empty?
distance += b.map { |n| (K - n) * 2 }.inject(&:+) unless b.empty?

puts distance

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


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

    cout << A * B << endl;
}

Measured memory_bytes: 3632
n = int(input())

p = list(map(int,input().split()))

ideal = list(range(1,n+1))

count = 0
for x in range(n):
  if p[x] != ideal[x]:
    count += 1

if count == 0 or count == 2:
  print("YES")
  
else:
  print("NO")
    

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

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int []p = new int[n];
		for(int i = 0; i < n; i++) {
			int out = 0;
			int []runner = new int[3];
			while(true) {
				String s = sc.next();
				if(s.equals("OUT")) {
					out++;
					if(out == 3) {
						Arrays.fill(runner, 0);
						break;
					}
				}else if(s.equals("HIT")) {
					if(runner[2] == 1) {
						p[i]++;
						runner[2] = 0;
					}
					if(runner[1] == 1) {
						runner[2] = 1;
						runner[1] = 0;
					}
					if(runner[0] == 1) {
						runner[1] = 1;
					}
					runner[0] = 1;
				}else {
					for(int j = 0; j < 3; j++) {
						if(runner[j] == 1) {
							p[i]++;
						}
					}
					p[i]++;
					Arrays.fill(runner, 0);
				}
			}
		}
		sc.close();
		for(int i : p) {
			System.out.println(i);
		}
	}
}


Measured memory_bytes: 26360
#include<iostream>

using namespace std;
int main()
{
    int n,m;
    cin >> n >> m;
    int nb = n-1;
    int mb = m-1;
    if( n == 0 )
        nb = 0;
    if( m == 0 )
        mb = 0;
    int ans = n*nb/2 + m*mb/2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n
    self.min_y = [N]*n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
    return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)

    if x == y:
      return

    if self.parents[x] > self.parents[y]:
      x, y = y, x

    self.parents[x] += self.parents[y]
    self.min_y[x] = min(self.min_y[x],self.min_y[y])
    self.parents[y] = x

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def num_roots(self):
    return len([i for i, x in enumerate(self.parents) if x < 0])

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def num_members(self,x):
    return abs(self.parents[self.find(x)])

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

import sys,os,io
input = sys.stdin.readline
# input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
N = int(input())
A = [list(map(int, input().split()))+[i] for i in range(N)]
uf = UnionFind(N)
uf.min_y = [y for x,y,i in A]
ans = [1]*N
A.sort()
Y = [(i,y) for x,y,i in A]
from heapq import *
heap = []
for u,y in Y:
  atode = []
  for _ in range(len(heap)):
    y1,v = heappop(heap)
    if y<y1:
      heappush(heap,(y1,v))
      break
    uf.union(u,v)
    if uf.parents[v]<0:
      atode.append((uf.min_y[v],v))
  if uf.parents[u]<0:
    heappush(heap,(uf.min_y[u],u))
  for y1,v in atode:
    heappush(heap,(y1,v))
for i in range(N):
  ans[i] = uf.num_members(i)
print(*ans, sep='\n')



Measured memory_bytes: 133836
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

class Combination {
   public:
    Combination(int n) {
        fac = new ll[n];
        inv = new ll[n];
        finv = new ll[n];
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        REP(i, 2, n) {
            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 cnr(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;
    }

   private:
    ll *fac, *inv, *finv;
};

Combination comb(2 * pow(10, 6) + 2);

ll f(int r, int c) {
    ll ret = 0;
    REP(i, 1, c + 2) {
        ret = (ret + comb.cnr(r + i, i)) % MOD;
    }
    return ret;
}

int main() {
    int sr, sc, tr, tc; cin >> sr >> sc >> tr >> tc;
    
    cout << (((f(tr, tc) + (MOD - f(tr, sc - 1))) % MOD + (MOD - f(sr - 1, tc))) % MOD + f(sr - 1, sc - 1)) % MOD << endl;
    return 0;
}

Measured memory_bytes: 47104
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;


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

	int N;
	cin >> N;
	int A[N];
	int W{};
	int ans = 0;
	rep(i,N){
		cin >> A[i];
		if(W == 0){
			W = 1;
		}
		else if(W == 1){
			if(A[i-1] > A[i]) W = 2;
			else if(A[i-1] < A[i]) W = 3;
		}
		else if(W == 2){
			if(A[i-1] < A[i]){
				++ans;
				W = 1;
			}
		}
		else if(W == 3){
			if(A[i-1] > A[i]){
				++ans;
				W = 1;
			}
		}
	}
	cout << ans+1 << endl;
}

Measured memory_bytes: 1024
fun main(args:Array<String>):Unit {
    while(true){
        val a = readLine()!!.trim().toInt()
        if (a == 0) return
        val b = Array(4){readLine()!!.trim().toInt()}
        val arg = Array(4){0}
        arg[a]++
        b.forEach{arg[it]++}
        if (arg.count{it != 0}.let{it == 1 || it == 3}) {
            repeat(5){println(3)}
        }else{
            val first = arg.indexOfFirst { it != 0 }
            val last = arg.indexOfLast { it != 0 }
            if (last - first == 1) {
                arg[first] = 1
                arg[last] = 2
            }else{
                arg[first] = 2
                arg[last] = 1
            }
            println(arg[a])
            b.forEach{println(arg[it])}
        }
    }
}


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

int main() {
    string s;
    cin >> s;
    s += '0';
    long long int a = 0, ans = 0;
    for(int i = 0; i < s.size(); ++i) {
        if(s[i] == 'A') {
            a++;
        } else if(s[i] == 'B' && s[i+1] == 'C') {
            ans += a;
            ++i;
        } else {
            a = 0;
        }
    }
    cout << ans << '\n';
    
    return 0;
}


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

struct Vector2D {
	// 平面ベクトル
	double x, y;

	Vector2D(double x, double y) : x(x), y(y) {}

	// ベクトルの和
	Vector2D operator+(const Vector2D p) { return Vector2D(x + p.x, y + p.y); }
	// ベクトルの差
	Vector2D operator-(const Vector2D p) { return Vector2D(x - p.x, y - p.y); }

	// ベクトルのスカラー倍
	Vector2D operator*(const double d) { return Vector2D(d * x, d * y); }
	Vector2D operator/(const double d) { return Vector2D(x / d, y / d); }

	// ベクトルの長さ
	double norm() { return sqrt(x * x + y * y); }

	// ベクトルの回転
	Vector2D rotate(double theta) {
		return Vector2D(x * cos(theta) - y * sin(theta), x * sin(theta) + y * cos(theta));
	}
};

struct Circle {
	// 中心
	Vector2D center;
	// 半径
	double radius;

	Circle(Vector2D center, double radius) : center(center), radius(radius) {}
};

vector<Vector2D> getIntersections(Circle C1, Circle C2) {
	double d = (C2.center - C1.center).norm();
	double rc = (C1.radius * C1.radius + d * d - C2.radius * C2.radius) / (2 * d);
	double rs = sqrt(C1.radius * C1.radius - rc * rc);

	Vector2D e1 = (C2.center - C1.center) / d;
	Vector2D e2 = e1.rotate(M_PI / 2);
	Vector2D e3 = e1.rotate(-M_PI / 2);
	Vector2D A = C1.center + e1 * rc + e2 * rs;
	Vector2D B = C1.center + e1 * rc + e3 * rs;

	return { A, B };
}


int N;
vector<double>X(100);
vector<double > Y(100);

//交点を持つか
bool dist(int n, int m, double x) {
	if ((2.0 * x)*(2.0 * x) < double((X[n]-X[m])*(X[n] - X[m])+ (Y[n] - Y[m])*(Y[n] - Y[m]))) {
		return false;
	}
	return true;
}
bool dist2(pair<double, double>S,double r,int n,int m) {
	for (int l = 0; l < N; ++l) {
		if (l != m && l !=n) {
			if (r*r < (S.first - X[l])*(S.first - X[l]) + (S.second - Y[l])*(S.second - Y[l])) {
				//cout << r * r << endl;
				//cout << (S.first - X[l])*(S.first - X[l]) + (S.second - Y[l])*(S.second - Y[l]) << endl;
				return false;
			}
		}	
	}
	return true;
}
//円と円の交点(交点は持つ前提
bool Cross(int n,int m,double x) {
	//交点を２つ求める。
	Vector2D V1(X[n],Y[n]);
	Vector2D V2(X[m],Y[m]);
	Circle C1(V1,x);
	Circle C2(V2, x);
	vector<Vector2D> vec = getIntersections(C1,C2);	
	pair<double, double>X1 = make_pair(vec[0].x,vec[0].y);
	pair<double, double>X2 = make_pair(vec[1].x, vec[1].y);
	bool ret1 = dist2(X1, x,n,m);
	bool ret2 = dist2(X2, x,n,m);

	//求めた頂点から各点の距離が収まっているかを確認するCross
	if (!ret1 && !ret2) {
		//cout << x<<endl;
		//cout << vec[0].x << vec[0].y << endl;
		//cout << vec[1].x << vec[1].y << endl;
		return false;
	}
	return true;
}
bool check(int n,int m,double x) {
	if (dist( n , m , x)) {
		if (!Cross(n,m,x)) {
			return false;
		}
	}
	else {
		return false;
	}
	return true;
}

bool f(double x) {
	for (int n = 0;n<N;++n) {
		for (int m = n + 1;m < N;++m) {
			if (check(n,m,x)) {
				return true;
			}
		}
	}
	return false;
}

int main() {
	cin >> N;
	for (int n = 0;n<N;++n) {
		int x, y;
		cin >> x >> y;
		X[n] = (double)x;
		Y[n] = (double)y;
	}
	double l = 0.0;
	double r = 1000.0;
	for (int n = 0;n < 100; ++n) {//100
		double x = (l + r) / 2;
		if (f(x)) {
			r = x;
		}
		else {
			l = x;
		}
	}
	printf("%.10f\n", l);
	return 0;
}

Measured memory_bytes: 3764
#include <stdio.h>

int main(void){
  int x, y, tmp;
  
  while(1){
    scanf("%d %d", &x, &y);
    
    if(x == 0 && y == 0){
      break;
    }
    
    if(x > y){
      tmp = x;
      x = y;
      y = tmp;
      printf("%d %d\n", x, y);
    }else{
      printf("%d %d\n", x, y);
    }
  }
  
  return 0;
}


Measured memory_bytes: 2052
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <cctype>
#include <climits> // INT_MAX ...
#include <cstring> // 

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<vector<int>> pr(10, vector<int>(10));
	for (int i = 1; i <= n; ++i) {
		pr[to_string(i)[0] - '0'][i % 10]++; // first digit i, last digit j (1, 11, 101, 111, ...) --> pr[1][1]
	}

	int ans = 0;
	for (int i = 0; i < 10; ++i) {
		for (int j = 0; j < 10; ++j) {
			ans += pr[i][j] * pr[j][i];
		}
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(in);
String s=sc.next();
int ans;
int c=0;
for(int j=1;j<s.length();j++){
if(s.charAt(j)=='9')c++;
}
if(c==s.length()-1){
    ans=9*(s.length()-1)+Character.getNumericValue(s.charAt(0));
}else{
    ans=Character.getNumericValue(s.charAt(0))+9*(s.length()-1)-1;
}
    out.println(ans);
}}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define CCC (ll)1e9+7
ll fact(int x)
{
    ll res = 1;
    for(int i=1;i<=x;i++){
        res *= i;
        res %= CCC;
    }
    return res;
}


int main()
{
    int x;
    cin>>x;
    cout<<fact(x)<<endl;
    return 0;
}

Measured memory_bytes: 256
S=input()
s=int(S[:2])
t=int(S[2:])
if (s>12 or s==0) and (t>12 or t==0):
    print("NA")
elif s>=1 and s<=12 and (t>12 or t==0):
    print("MMYY")
elif t>=1 and t<=12 and (s>12 or s==0):
    print("YYMM")
else:
    print("AMBIGUOUS")

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int n;
	int i;
	int sum;
	while(scanf("%d",&n) != EOF)
	{
		sum = 0;
		for (i = 0; i < (600/n); i += 1)
		{
			sum += n*n*n*i*i;
		}
		printf("%d\n",sum);
	}
	return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<set>
// #define Kongxiangzhouye
#define sd(x) scanf("%d",&x)
#define ss(x) scanf("%s",x)
#define sc(x) scanf("%c",&x)
#define sf(x) scanf("%f",&x)
#define slf(x) scanf("%lf",&x)
#define slld(x) scanf("%lld",&x)
#define me(x,b) memset(x,b,sizeof(x))
#define pd(d) printf("%d\n",d);
#define plld(d) printf("%lld\n",d)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAX_N=100000;
const int INF = 0x3f3f3f3f;

bool vis(int a){
	int len=sqrt(a+0.5);
	for(int i=2;i<len;i++){
		if(a%i==0)
			return 0;
	}
	return 1;
}
int main()
{
	#ifdef Kongxiangzhouye
		freopen("in.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	cout<<n<<":";
	int flag;
	while(n!=1){
		flag=1;	
		for(int i=2;i<sqrt(n+0.5);i++){
			if(vis(i)&&n%i==0){
				flag=0;
				n=n/i;
				cout<<" "<<i;
				break;
			}
		}
		if(flag==1)
			break;
	}
	cout<<" "<<n<<endl;


	return 0;
}



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

typedef long long ll;

ll n, ans, sum, fac = 1;

int main() {
	cin>>n;
	while(sum*10 + 9 <= n) {
		ans += 9;
		sum = sum*10 + 9;
		fac *= 10;
	}	
	for(int i = 9; i; i--)
		if(i*fac + sum <= n) {
			ans += i;
			break;
		}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i > (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define IN(x) cin >> x
#define DE(x) cerr << (x) << " "
#define BR cerr << "\n"
#define OUT(x) cout << (x) << endl
#define FIX cout << fixed << setprecision(10)

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;

int main(void){
  string stone;
  IN(N);
  IN(stone);

  ll r=0, w=0;
  REP(i, N) {
    if (stone[i] == 'R') r++;
    else w++;
  }

  ll left_w=0;
  REP(i, r) {
    if (stone[i] == 'W') left_w++;
  }

  OUT(left_w);

}


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

int main() {
  char c;
  cin >> c;

  string answer;
  if ((c == 'a') || (c == 'e') || (c == 'i') || (c == 'o') || (c == 'u')) {
    answer = "vowel";
  } else {
    answer = "consonant";
  }
  cout << answer << endl;
}


Measured memory_bytes: 3600
import sys
input = sys.stdin.readline

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

grid_array = [[0] * C for _ in range(3)]

D_array = [list(map(int, input().split())) for _ in range(C)]

for i in range(N):
    C_array = map(int, input().split())
    for j, c in enumerate(C_array):
        grid_array[(i+j) % 3][c-1] += 1

# print(D_array)

cost_array = [[0] * C for _ in range(3)]
for i in range(3):
    for j in range(C):
        cost = 0
        for k in range(C):
            cost += grid_array[i][k] * D_array[k][j]
        cost_array[i][j] = cost

ans = 10 ** 20

for i in range(C):
    for j in range(C):
        if j == i:
            continue
        for k in range(C):
            if k == i or k == j:
                continue
            ans = min(ans, cost_array[0][i] +
                      cost_array[1][j] + cost_array[2][k])
print(ans)


Measured memory_bytes: 42076
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

string s;
int n1=0,n0=0;

int main()
{
	cin>>s;
	rep(i,s.size())
	{
		if(s[i]=='1') n1++;
		else n0++;
	}
	cout<<min(n1,n0)*2<<endl;
	rt0;
}

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

int main() {
  ll a,b,c,k; cin >> a >>b >> c >> k;
  
  if(a>=k) cout << k <<endl;
  if(a<k && k<= a+b) cout << a <<endl;
  if(a+b<k) cout << 2*a + b-k <<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define maxn 1005
using namespace std;
int n,a[maxn<<1];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++) scanf("%d",&a[i]);
	sort(a+1,a+2*n+1);
	int ans=0;
	for(int i=1;i<=2*n;i+=2) ans+=a[i];
	printf("%d",ans);
	
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
while True:
    n,x=map(int,input().split())
    
    if n+x==0:
        break
    else:
        ans=0
        for i in range(1,n+1):
            for j in range(1,i):
                for k in range(1,j):
                    if i+j+k==x:
                        ans+=1
    
        print(ans)


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

using namespace std;
long long x[10000010], y[10000010],z[10000010];
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,n) for(int i=1; i<(n) i++)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int>
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9+7;

signed main()
{

   cin.tie(0);
   ios::sync_with_stdio(false);

   int a,b,c,d,n,cnt=0,ans=0;
   string s,w;

   cin>>n;
   if(n<10) cout<<"ABC00"<<n<<'\n';
   else if(n<100) cout<<"ABC0"<<n<<'\n';
   else cout<<"ABC"<<n<<'\n';
}

Measured memory_bytes: 256
X,Y,A,B,C = list(map(int,input().split()))
p = sorted(list(map(int,input().split())),reverse=True)
q = sorted(list(map(int,input().split())),reverse=True)
r = sorted(list(map(int,input().split())),reverse=True)

taberu = p[0:X] + q[0:Y] + r
taberu.sort(reverse=True)

print(sum(taberu[0:X+Y]))

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
// #define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int n, a, b; cin >> n >> a >> b;
    cout << min(a*n, b) << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 7684
#include<cstdio>
#include<string.h>
using namespace std;
int main()
{
  while(1)
    {
  char buf[115][2];
  char str[128];
  buf['A']['0']='X';
  buf['A']['1']='Y';
  buf['X']['1']='Z';
  //buf['X']['0']='n';
  buf['Y']['0']='X';
  //buf['Y']['1']='n';
  buf['Z']['0']='W';
  buf['Z']['1']='B';
  buf['W']['0']='B';
  buf['W']['1']='Y';
  buf['B']['0']='Y';
  buf['B']['1']='X';
  scanf("%s",str);
  if(str[0]=='#')break;
  int ans=strlen(str);
  
  char now='A';
  for(int i=0;i<ans;i++)
    {
      
      now=buf[now][str[i]];
      //if(now=='n')break;

    }
  if(now=='B')printf("Yes\n");
  else printf("No\n");
    }
  return 0;
}

Measured memory_bytes: 944
module Main where

import Data.Maybe
import qualified Data.ByteString.Lazy.Char8 as B
import Control.Monad
    

readLine:: B.ByteString -> [Int]
readLine s = map (fst . fromJust . B.readInt) (B.words s)

readLines :: [B.ByteString] -> [[Int]]
readLines [] = []
readLines (s:ss) = readLine s : readLines ss

main :: IO() 
main = do
    contents <- B.getContents
    let lines = B.lines contents
        [n] = readLine (head lines)
        (q, s) = divMod n 60
        (h, m) = divMod q 60
        ans = show h ++ ":" ++ show m ++ ":" ++ show s
    putStrLn ans



Measured memory_bytes: 3576
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
using namespace std;


typedef long long ll;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)

const int mod = 1000000007;



int main(){
  ll n, m;
  cin >> n >> m;
  vector<ll> problem(n + 1, 0);
  ll correct = 0, penalty = 0;

  vector<bool> ac(n + 1, false);
  rep(i, m){
    ll p;
    string s;
    cin >> p >> s;

    if(s == "AC"){
      if(ac[p] == false) {
        correct++;
        ac[p] = true;
        penalty += problem[p];
      }
    } else if(s == "WA") {
      problem[p]++;
    }

  }

  cout << correct << endl;
  cout << penalty << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	int a;
	int max = 0; 
	int min = 999999;
	for(int i=0;i<n;i++){
		cin >> a;
		if(a > max){
			max = a;
		}
		if(a < min){
			min = a;
		}
	}
	cout << (max-min) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,q,a,v,i,j,amm=0,wmx=0,w[1000001];

  scanf("%d%d",&n,&q);
  for(i=1;i<=n;i++) w[i]=0;
  for(i=0;i<q;i++){
    scanf("%d%d",&a,&v);
    w[a]+=v;
    if(v<0 && a==amm){
      wmx=0;
      for(j=n;j>=1;j--){
        if(w[j]>=wmx){ wmx=w[j]; amm=j;}
      } 
    } else if(w[a]>wmx || (w[a]==wmx && amm>a)){ wmx=w[a]; amm=a;}
    printf("%d %d\n",amm,w[amm]);
  }
  return 0;
}

Measured memory_bytes: 4504
#include<cstdio>
#include<iostream>
#include<stack>
using namespace std;

int main(){
  char ch;
  while(1){
    stack<char> S;
    scanf("%c",&ch);
    if(ch=='.')break;
    int i=0;
    bool flag=0;

    while(1){
      if(i!=0)scanf("%c",&ch);
      if(ch=='.')break;
      
      if(ch=='[') S.push('[');
      else if(ch==']'&&S.size()==0)flag=1;
      else if(ch==']'&&S.top()=='[') S.pop();
      else if(ch==']') S.push(']');
      
      if(ch=='(')S.push('(');
      else if(ch==')'&&S.size()==0)flag=1;
      else if(ch==')'&&S.top()=='(') S.pop();
      else if(ch==')')S.push(')');

      i++;
    }

    if(S.size()==0&&flag!=1) cout<<"yes"<<endl;
    else cout<<"no"<<endl;

    scanf("%c",&ch);
  }
  return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int S = (1 << 17);
ll k, tab[S], min_p, max_p;

int main(){
	
	cin >> k;
	for (int i = 1; i <= k; i ++)
		cin >> tab[i];
	min_p = max_p = 2;
	
	for (int i = k; i >= 1; i --){
		min_p = ((min_p - 1) / tab[i] + 1) * tab[i];
		max_p = max_p / tab[i] * tab[i] + tab[i] - 1;
	}
	if (max_p < min_p)
		cout << -1 << endl;
	else 
		cout << min_p << " " << max_p << endl;
	
	return 0;
}

Measured memory_bytes: 1024
al = [int(input()) for i in range(5)]

alhoge = [0 if x % 10 == 0 else (10 - (x % 10)) for x in al]
# print(alhoge)
alsorted = sorted(al, key=lambda x: 0 if x % 10 == 0 else (10 - (x % 10)))
# print(alsorted)

ans = 0
for i in range(len(alsorted)):
    if i == len(alsorted) - 1:
        ans += alsorted[i]
    else:
        ans += alsorted[i] if alsorted[i] % 10 == 0 else alsorted[i] + (10 - alsorted[i] % 10)

print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
int main(){
	int x,y;
	scanf("%x%x",&x,&y);
		
		if(x>y)
		{
			printf(">\n");
		}
	else
	{
		if(x==y)
		{
			printf("=\n");
		}
		else 
		{
			printf("<\n");
		}
	}
	
	
	return 0;
}

Measured memory_bytes: 128
import sys

sys.setrecursionlimit(10 ** 7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(input())
A = list(map(int, input().split()))

CNT = [0] * (10 ** 7)

ans = 0
for i in range(N):
    a = A[i]
    p = i - a

    if 0 <= p <= (10 ** 7):
        ans += CNT[p]

    if 0 <= i + a <= (10 ** 7):
        CNT[i + a] += 1

print(ans)


Measured memory_bytes: 97788
#include <iostream>

using namespace std;

int main(){
   int a,b,n,sum;
   while(cin >> a >> b >> n){
      sum = 0;
      for(int i=0; i<n; i++){
	 a *= 10;
	 sum += (a/b)%10;
	 a = a%b;
      }
      cout << sum << endl;
   }
   return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int left,right,up,down,w,h,n,x,y,a;
	cin>>w>>h>>n;
	left=0;down=0;up=h;right=w;
	for(int i=1;i<=n;i++)
	{
		cin>>x>>y>>a;
		if(a==1)
			left=max(left,x);	
		if(a==2)
			right=min(right,x);
		if(a==3)
			down=max(down,y);
		if(a==4)
			up=min(up,y);
	} 
	if(down>up||left>right)	cout<<0;
	else
		cout<<(up-down)*(right-left);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int a, b;
	while(1){
		scanf("%d%d", &a, &b);
		if(a == 0 && b == 0){
			break;
		}
		if(a>b){
			printf("%d %d\n", b, a);
		}else{
			printf("%d %d\n",a ,b);
		}
	}
}


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

int main(){
	int n,d;
	cin>>n>>d;
	int x,y;int c=0;
	for(int i=0;i<n;i++)
	{
		cin>>x>>y;
		if(sqrt(pow(x,2)+pow(y,2))<=d)
			c++;
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
char c[310][310];
ll dp[310][310];
int main() {
	ll h,w;
	cin>>h>>w;
	for(int i=0;i<h;i++)for(int j=0;j<w;j++)cin>>c[i][j];
	if(c[0][0]=='#')dp[0][0]=1;
	for(int i=1;i<h;i++){
		dp[i][0]=dp[i-1][0];
		if(c[i-1][0]=='.'&&c[i][0]=='#')dp[i][0]++;
	}
	for(int i=1;i<w;i++){
		dp[0][i]=dp[0][i-1];
		if(c[0][i-1]=='.'&&c[0][i]=='#')dp[0][i]++;
	}
	for(int i=1;i<h;i++){
		for(int j=1;j<w;j++){
			ll u=dp[i-1][j],l=dp[i][j-1];
			if(c[i-1][j]=='.'&&c[i][j]=='#')u++;
			if(c[i][j-1]=='.'&&c[i][j]=='#')l++;
			dp[i][j]=min(u,l);
		}
	}
	cout<<dp[h-1][w-1];
	return 0;
}

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

using namespace std;

void dfs(int d, long long cur, vector<long long> & A) {
	// 現在の値を格納
	A.push_back(cur);

	// 10桁になったら打ち切り
	if (d == 10) return;

	// 再帰
	for (int i = -1; i <= 1; i++) {
		int add = (cur % 10) + i;
		if (add >= 0 && add <= 9) {
			dfs(d + 1, cur * 10 + add, A);
		}
	}
}

int main(void) {
	int K;  cin >> K;
	vector<long long> A;
	for (int i = 1; i < 10; i++) {
		dfs(1, i, A);
	}

	sort(A.begin(), A.end());

	cout << A[K - 1] << endl;
}

Measured memory_bytes: 2420