akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())
 
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18


int main() {
    LL N;
    cin>>N;
    vector<LL> a(N);
    vector<LL> b(N,0);
    vector<LL> s(N,0);
    REP(i,N){
        LL c;
        cin >>c;
        a[i]=c;
        b[c-1]+=1;
    }

    LL sum = 0;
    REP(i,N){
        s[i] = b[i]*(b[i]-1)/2;
        sum += s[i];
    }

    REP(i,N){
        LL ans = sum - b[a[i]-1]+1;
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 9216
import collections

N = int(input())
S = []
for _ in range(N):
    S.append(input())

C = collections.Counter(S).most_common()
M = C[0][1]

ans = []
for c in C:
    if c[1] == M:
        ans.append(c[0])
    else:
        break

ans.sort()
for a in ans:
    print(a)

Measured memory_bytes: 45040
#include <bits/stdc++.h>
using namespace std;
int S[3][7] = {
    {1,3,5,7,8,10,12},
    {4,6,9,11},
    {2}
};
int a(int x) {
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 7; j++) {
            if (S[i][j] == x) return i;
        }
    }
}
int main () {
    int x, y;
    cin >> x >> y;
    if (a(x) == a(y)) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <math.h>
#include <cstdlib>
#include <cctype>
#include <random>

using namespace std;

int main() {
    int N, K, point, coin;
    cin >> N >> K;
    double prob = 0;
    double invT = 1.0 / (double)N;

    for (int i=1; i<=N; i++) {
        int point = i;
        int count = 0;
        while(true) {
            if(point > K-1) break;
            else point *= 2;
            count++;
        }
        //cout << pow(0.5, (double)count)*invT << endl;

        prob += pow(0.5, (double)count) * invT;
    }

    printf("%.12f\n", prob);

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int par[114514], siz[114514];
void init(int n) {
	rep(i, n) {
		par[i] = i;
		siz[i] = 1;
	}
}
int find(int x) {
	if (par[x] == x)return x;
	return par[x] = find(par[x]);
}
bool same(int x, int y) {
	return find(x) == find(y);
}
void unite(int x, int y) {
	x = find(x), y = find(y);
	if (x == y)return;
	if (siz[x] < siz[y]) {
		par[x] = y;
		siz[y] += siz[x];
	}
	else {
		par[y] = x;
		siz[x] += siz[y];
	}
}
int n, m;
signed main() {
	cin >> n >> m;
	init(n);
	rep(i, m) {
		int a, b, c; cin >> a >> b >> c; unite(a - 1, b - 1);
	}
	map<int, int>mp;
	rep(i, n) {
		mp[find(i)]++;
	}
	int ans = 0;
	rep(i, n) {
		if (mp[i])ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

int main()
{
  int N; cin >> N;
  vector<int> V(N), C(N);
  REP(i, N) cin >> V[i];
  REP(i, N) cin >> C[i];

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    ans += max(0, V[i]-C[i]);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

fn main() {
    input! {
        n: String
    };

    let last_char = n.chars().last().unwrap();

    if last_char == '2'
        || last_char == '4'
        || last_char == '5'
        || last_char == '7'
        || last_char == '9'
    {
        println!("hon");
    } else if last_char == '0' || last_char == '1' || last_char == '6' || last_char == '8' {
        println!("pon");
    } else {
        println!("bon");
    }
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
  int w,a,b,ans;
  cin>>w>>a>>b;

  if(abs(a-b)<=w) ans=0;
  else ans=abs(a-b)-w;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <sstream>

#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>

#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

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

int main(){
    int n;
    cin >> n;
    cout << (n-2) * 180 << endl;
    return 0;
}


Measured memory_bytes: 256
#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)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

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

    ll N, M;
    cin >> N >> M;
    vector<ll> A(M);
    rep(i,M){
        cin>>A[i];
        N -= A[i];
    }
    if(N < 0){
        cout << -1 << endl;
    }
    else {
        cout << N << endl;
    }

}

Measured memory_bytes: 3696
#include "bits/stdc++.h"
using namespace std;
 
int main(void) {
	int n, m;
	cin >> n >> m;

	vector<int> f(n,300000000);
	int a[n], b[n], c[m], d[m], ans[n];

	for(int i=0;i<n;i++) cin >> a[i] >> b[i];
	for(int i=0;i<m;i++) cin >> c[i] >> d[i];

	int dif;

	for(int i=0;i<n;i++) {
		for(int j=0;j<m;j++) {
			dif = abs(a[i]-c[j])+abs(b[i]-d[j]);
			if(dif < f[i]) {
				f[i] = dif;
				ans[i] = j+1;
			}
		}
	}

	for(int i=0;i<n;i++) cout << ans[i] << endl;

}


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

int main() {
  int x, n;
  cin >> x >> n;
  
  vector<int> v(n);
  for(int i=0; i<n; i++) cin >> v[i];
  
  int ans;
  int min = 1000;
  for(int i=-100; i<=200; i++) {
    bool skip = false;
    for(int j=0; j<n; j++) if(i==v[j]) skip = true;
    if(skip) continue;
      
    if(abs(i-x)<min) {
      min = abs(i-x);
      ans = i;
    }
    
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
  ll n;
  cin >> n;
  vector<ll> l;
  FOR(i,0,n-1) {
    ll input;
    cin >> input;
    l.PB(input);
  }

  ll ans = 0;

  SORT(l);

  FOR(i,0,n-3){
    // if(i!=0 && l[i]==l[i-1]) continue;
    FOR(j,i+1,n-2){
      // 例外条件必要？
      
      auto iter_lower = lower_bound(l.begin(),l.end(),l[i]+l[j]);
      auto iter_upper = upper_bound(l.begin(),l.end(),l[j]);
      ll idx_lower = distance(l.begin(),iter_lower);
      ll idx_upper = distance(l.begin(),iter_upper);
      // cout << idx_lower-idx_upper << endl;

      // ll idx_upper = disupper[j];

      // if(idx_lower-idx_upper==0) break;

      // ans += idx_lower-idx_upper;
      ans += idx_lower-j-1;
      // cout << idx_lower << " " << j+1 << endl;
      // flash = idx_lower-idx_upper;

      

    }
  }

  cout << ans << endl;

}



Measured memory_bytes: 256
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def popcnt(n):
    return bin(n).count("1")

def main():
    n = int(ipt())
    card = [[int(i) for i in ipt().split()] for _ in range(2)]
#    n = 18
#    card = [[j*500-i*3+400 for j in range(18)] for i in range(2)]
    dp = [[10**18]*n for i in range(2**n)]

    for i in range(1,2**n):
        pi = popcnt(i)
        if pi == 1:
            for j in range(n):
                if (i>>j)&1:
                    dp[i][j] = 0
        else:
            pp = 0
            for j in range(n-1,-1,-1):
                if (i>>j)&1:
                    nn = card[(pi-j+1)%2][j]
                    pn = i-2**j
                    dpn = dp[pn]
                    for k in range(n):
                        if dp[i][j] > dpn[k]+pp:
                            if card[(pi-k)%2][k] <= nn:
                                dp[i][j] = dpn[k]+pp
                    pp += 1
    ans = min(dp[2**n-1])
    if ans == 10**18:
        ans = -1
    print(ans)
    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 137620
//#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;
	cin >> N;

	int ans = 0;

	rep(i, 0, N)
	{
		ans += (i + 1)*(N - i);
	}

	int x, y;
	rep(i, 0, N - 1)
	{
		cin >> x >> y;
		if (x > y)swap(x, y);
		ans -= x * (N - y + 1);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNextInt()) {
			int n = sc.nextInt();
			if (n == 0) break;
			int[] s = new int[n];
			double m = 0;
			for (int i = 0; i < n; ++i) {
				m += s[i] = sc.nextInt();
			}
			m /= n;
			double a = 0;
			for (int i = 0; i < n; ++i) {
				a += Math.pow(s[i] - m, 2);
			}
			System.out.println(Math.sqrt(a / n));
		}
	}
}

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



int main(){
    string S;

    cin >> S;
    int N;
    N = S.size();

    std::vector<int> seq(N, 0);
    std::vector<int> res(N, 0);
    int r,l;
    r = l = 0;
    for(int i=0; i < N; i++){
        if(S.at(i)=='R'){
            r++;
        }else{
            if(r > 0){
                seq.at(i-1) = r;
                r = 0;
            }
        }
    }
    
    for(int i=N-1; i >=0; i--){
        if(S.at(i)=='L'){
            l++;
        }else{
            if(l > 0){
                r = seq.at(i);
                if((l-r)%2==0){
                    seq.at(i) = (l+r)/2;
                    seq.at(i+1) = (l+r)/2;
                }else if(l%2==0){
                    seq.at(i) = (l+r)/2 + 1;
                    seq.at(i+1) = (l+r)/2;
                }else{
                    seq.at(i) = (l+r)/2;
                    seq.at(i+1) = (l+r)/2 + 1;
                }
            }
            l = 0;
        }
    }
    for (int var : seq)
    {
        cout << var << " ";
    }
    cout << endl;

}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        Integer[] v = new Integer[n];
        Integer[] c = new Integer[n];
        for (int i = 0; i < n; i++) {
            v[i] = Integer.parseInt(sc.next());
        }
        for (int i = 0; i < n; i++) {
            c[i] = Integer.parseInt(sc.next());
        }

        int result = 0;
        for (int i = 0; i < n; i++) {
            int value = v[i] - c[i];
            if (value > 0) {
                result += value;
            }
        }

        System.out.println(result);
    }
}

Measured memory_bytes: 23380
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

void dijkstra() {
    int minv;
    int d[MAX], color[MAX];
    
    for (int i = 0; i < n; i++) {
        d[i] =INFTY;
        color[i] = WHITE;
    }
    
    d[0] = 0;
    color[0] = GRAY;
    while(1) {
        minv = INFTY;
        int u = -1;
        for (int i = 0; i < n; i++) {
            if ( minv > d[i] && color[i] != BLACK) {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1) break;
        color[u] = BLACK;
        for (int v = 0; v < n; v++) {
            if (color[v] != BLACK && M[u][v] != INFTY ) {
                if (d[v] > d[u] + M[u][v]) {
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    
    for (int i = 0; i < n; i++) {
        cout << i << " " << ( d[i] == INFTY ? -1 : d[i] ) << endl;
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            M[i][j] = INFTY;
        }
    }
    
    int k, c, u, v;
    for (int i = 0; i < n; i++) {
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            cin >> v >> c;
            M[u][v] = c;
        }
    }
    
    dijkstra();
    
    return 0;
}


Measured memory_bytes: 3148
#!/usr/bin/env python3
import sys
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(N: str):
    S = 0
    for c in N:
        S += int(c)
    N = int(N)

    if N % S == 0:
        yes()
    else:
        no()

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = str(next(tokens))  # type: str
    solve(N)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
l, r = gets.chomp.split().map(&:to_i)

if r - l >= 2019
  print(0)
  exit
end

res = 10000
[*l..r].each do |i|
  [*(i+1)..r].each do |j|
    res = [res, (i*j)%2019].min
  end
end

puts res


Measured memory_bytes: 46968
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define ll long long
#define endl '\n'
#define pi 3.14159265
ll n,k;
ll v[3][500001];
ll dp[500001][4];
ll f(ll i,ll ch)
{
    if(i==n)
        return 0;
    if(dp[i][ch]!=-1)
        return dp[i][ch];
    ll ans=-1e16;
    for(ll j=0;j<3;j++)
    {
        if(j==ch)
            continue;
        ans=max(ans,f(i+1,j)+v[j][i]);
    }
    return dp[i][ch]=ans;
}
int main()
{
    IOS;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<3;j++)
        cin>>v[j][i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<f(0,3);
}

Measured memory_bytes: 29056
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000

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

int H, W, S;
int board[40][40];
pair<int, int> memo[40][40][40][40];
int dp[40][40];
int sum;

void makeDP() {
    for (int i = 0; i < 40; i++) {
        for (int j = 0; j < 40; j++) {
            dp[i][j] = 0;
        }
    }
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            dp[i][j] = dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1] + board[i][j];
        }
    }
}

int sumRec(int lx, int ly, int hx, int hy) {
    return dp[hy][hx] - dp[hy][lx-1] - dp[ly-1][hx] + dp[ly-1][lx-1];
}

// first:グループ数 second:予備力
pair<int, int> dfs(int lx, int ly, int hx, int hy) {
    if (memo[lx][ly][hx][hy].first >= 0) return memo[lx][ly][hx][hy];
    pair<int, int> ans = make_pair(1, S - (sum - sumRec(lx, ly, hx, hy)));
    // 横に分ける
    for (int y = ly; y < hy; y++) {
        if (sum - sumRec(lx, ly, hx, y) > S) continue;
        if (sum - sumRec(lx, y+1, hx, hy) > S) continue;
        auto a = dfs(lx, ly, hx, y);
        auto b = dfs(lx, y+1, hx, hy);
        ans = max(ans, make_pair(a.first+b.first, min(a.second, b.second)));
    }
    // 縦に分ける
    for (int x = lx; x < hx; x++) {
        if (sum - sumRec(lx, ly, x, hy) > S) continue;
        if (sum - sumRec(x+1, ly, hx, hy) > S) continue;
        auto a = dfs(lx, ly, x, hy);
        auto b = dfs(x+1, ly, hx, hy);
        ans = max(ans, make_pair(a.first+b.first, min(a.second, b.second)));
    }
    return memo[lx][ly][hx][hy] = ans;
}

int main(void) {
    while (cin >> H >> W >> S) {
        if (H == 0 && W == 0 && S == 0) break;
        sum = 0;
        for (int h = 1; h <= H; h++) {
            for (int w = 1; w <= W; w++) {
                cin >> board[h][w];
                sum += board[h][w];
            }
        }
        for (int i = 0; i < 40; i++) {
            for (int j = 0; j < 40; j++) {
                for (int k = 0; k < 40; k++) {
                    for (int l = 0; l < 40; l++) memo[i][j][k][l] = make_pair(-1, -1);
                }
            }
        }
        makeDP();
        auto ans = dfs(1, 1, W, H);
        cout << ans.first << " " << ans.second << endl;
    }
    return 0;
}

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

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

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

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll n, k; cin >> n >> k;
    vector<ll> x(n); cin >> x;
    ll inf = 1000000000, ans = inf;
    rep(i, n-k+1){
        ll a = x[i], b = x[i+k-1];
        if(a < 0 && b < 0) ans = min(ans, abs(a));
        else if(a > 0 && b > 0) ans = min(ans, b);
        else{
            if(abs(a) < abs(b)) ans = min(ans, abs(a)*2 + abs(b));
            else ans = min(ans, abs(a) + abs(b)*2);
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 4044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <cmath>
#include <numeric>
#include <functional>
#include <stack>
#include <iomanip>
#include <map>
#include <cstdio>

int main() {
	long long ans = 0, n;

	std::cin >> n;

	long long count = 0, min = 10000000000;

	for (long long i = 0; i < n; i++)
	{
		long long num;
		std::cin >> num;
		if (num <= min) {
			if (i != 0) {
				count++;
			}
			min = num;
		}
		else {
			ans = std::max(ans, count);
			count = 0;
			min = num;
		}
	}

	ans = std::max(ans, count);

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

const int maxn = 405;
const int md = 1e9+7;
const int lim = 400;

void add(int &a, int b)
{
	a += b;
	if(a>= md) a -= md;
}

void sub(int &a, int b)
{
	 a -= b;
	 if(a< 0) a += md;
}

int mul(int a, int b)
{
	return (1LL*a*b)%md;
}

int dp[maxn][maxn];

int n, C;

int a[maxn], b[maxn];

int foo[maxn][maxn];

int ask(int i1, int j1, int i2, int j2)
{
	int res = foo[i2][j2];
	if(j1) sub(res, foo[i2][j1-1]);
	if(i1) sub(res, foo[i1-1][j2]);
	if(i1 && j1) add(res, foo[i1-1][j1-1]);
	return res;
}

int solve(int u, int rem)
{
	if(u == n+1 && rem == 0) return 1;
	if(u == n+1) return 0;
	if(dp[u][rem] != -1) return dp[u][rem];
	int tot = 0;
	for(int ind = 0; ind<= rem; ind++)
	{
		add(tot, mul(ask(a[u], ind, b[u], ind), solve(u+1, rem-ind)));
	}
	return dp[u][rem] = tot;
}

int main()
{
	scanf("%d %d", &n, &C);
	for(int i = 1; i<= n; i++) scanf("%d", a+i);
	for(int i = 1; i<= n; i++) scanf("%d", b+i);
	for(int i = 1; i<= lim; i++)
	{
		foo[i][0] = 1;
		for(int j = 1; j<= lim; j++)
		{
			foo[i][j] = mul(i, foo[i][j-1]);
		}
	}
	for(int i = 1; i<= lim; i++)
	{
		for(int j = 0; j<= lim; j++)
		{
			if(i) add(foo[i][j], foo[i-1][j]);
			if(j) add(foo[i][j], foo[i][j-1]);
			if(i && j) sub(foo[i][j], foo[i-1][j-1]);
		}
	}
	memset(dp, -1, sizeof dp);
	printf("%d\n", solve(1, C));
}

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

signed main(){
    int n,m;
    cin >> n >> m;
    priority_queue<int> que;
    rep(i,n){
        int a;
        cin >> a;
        que.push(-a);
    }
    vector<P> v;
    rep(i,m){
        int b,c;
        cin >> b >> c;
        v.push_back(make_pair(c,b));
    }
    sort(v.begin(),v.end(),greater<P>());

    bool flag=false;
    rep(i,m){
        P p=v[i];
        rep(j,p.second){
            int v=que.top();
            v=-v;
            que.pop();
            if(v<p.first) que.push(-p.first);
            else{
                que.push(-v);
                flag=true;
                break;
            }
        }
        if(flag) break;
    }
    int ans=0;
    while(!que.empty()){
        int v=que.top();
        v=-v;
        que.pop();
        //cout << v << endl;
        ans+=v;
    }
    cout << ans << endl;

}

Measured memory_bytes: 3188
N,M,Q = map(int,input().split())
ls_rq = [list(map(int, input().split())) for i in range(Q)]

#深さ優先探索により各数列を生成する
As=[]
from queue import LifoQueue as lq
S=lq()
S.put([])
while not S.empty():
  a=S.get()
  if len(a)==N:
    As.append(a)
  else:
    if len(a)==0:
      b=1
    else:
      b=a[-1]
    for  i in range(b,M+1):
      S.put(a+[i])

#各数列のスコアを求める
ls_score=[]
for ls in As:
  score=0
  for j in range(Q):
    if ls[ls_rq[j][1]-1]-ls[ls_rq[j][0]-1]==ls_rq[j][2]:
      score+=ls_rq[j][3]
  ls_score.append(score)    
  score=0

#スコアの最大値を求める  
ans=max(ls_score+[0])  
print(ans)  

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k;
	string s;
	cin >>n >>k >>s;
	s += "Z";
	VI rz;
	int sm = 1;
	rep2(i, 1, n+1){
		if(s[i-1] != s[i]){
			rz.push_back(sm); sm=1;
		}else sm++;
	}
	int m=sz(rz);
	VL as(m+1);
	rep(i, m) as[i+1] = as[i] + rz[i];
	
	ll ans = 0; int gk = s[0]=='1'? 0: 1;
	rep(i, m){
		if(i%2==gk) ans = max<ll>(ans, as[min(m,i+k*2+1)] - as[i]);
		else ans = max<ll>(ans, as[min(m,i+k*2)] - as[i]);
	}
	cout << ans <<"\n";
	return 0;
}


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

using namespace std;

long long n, w, x, y, a, b, sol, w0, w1, w2, w3, b0, b1, b2, b3;
vector <long long> v[4];

int main(){
    cin >> n >> w;
    cin >> a >> b;
    v[0].push_back(b);
    for (int i=0; i<n-1; i++){
        cin >> x >> y;
        x -= a;
        v[x].push_back(y);
    }
    sort(v[0].begin(), v[0].end());
    sort(v[1].begin(), v[1].end());
    sort(v[2].begin(), v[2].end());
    sort(v[3].begin(), v[3].end());
    w0 = 0;
    b0 = 0;
    for (int i=v[0].size()-1; i>=-10; i--){
        w1 = 0;
        b1 = 0;
        for (int j=v[1].size()-1; j>=-10; j--){
            w2 = 0;
            b2 = 0;
            for (int k=v[2].size()-1; k>=-10; k--){
                w3 = 0;
                b3 = 0;
                for (int h=v[3].size()-1; h>=-10; h--){
                    if ((a*b0+(a+1)*b1+(a+2)*b2+(a+3)*b3) > w){
                        break;
                    }
                    else{
                        if (sol < (w0+w1+w2+w3)){
                            sol = w0+w1+w2+w3;
                        }
                    }
                    if (h==-1){
                        break;
                    }
                    else{
                        w3 += v[3][h];
                        b3++;
                    }

                }
                if (k==-1){
                    break;
                }
                else{
                    w2 += v[2][k];
                    b2++;
                }
            }
            if (j==-1){
                break;
            }
            else{
                w1 += v[1][j];
                b1++;
            }
        }
        if (i==-1){
            break;
        }
        else{
            w0 += v[0][i];
            b0++;
        }
    }
    cout << sol;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		String str = sc.next();
		
		String[] ss = str.split("/");
		
		if(Integer.parseInt(ss[0])<2019) {
			System.out.println("Heisei");
		}else if(Integer.parseInt(ss[0]) == 2019){
			if(Integer.parseInt(ss[1])<4) {
				System.out.println("Heisei");
			}else if(Integer.parseInt(ss[1])==4) {
				if(Integer.parseInt(ss[2])<30) {
					System.out.println("Heisei");
				}else if (Integer.parseInt(ss[2])==30) {
					System.out.println("Heisei");
				}else {
					System.out.println("TBD");
				}
			}else {
				System.out.println("TBD");
			}
		}else {
			System.out.println("TBD");
		}
	}
}


Measured memory_bytes: 22868
fn main() {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let mut n: i32 = s.trim().parse().unwrap();
	if n == 0 {
		println!("0");
	} else {
		let mut ans = vec![];
		while n != 0 {
			ans.push(if n & 1 != 0 { '1' } else { '0' });
			n = (n & !1) / -2;
		}
		println!("{}", ans.into_iter().rev().collect::<String>());
	}
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(void)
{
  int n,a,b,i,ans=0,sum=0,temp;
  scanf("%d %d %d",&n,&a,&b);
  for(i=a;i<=n;i++)
    {
      temp = i; sum = 0;
      while(temp != 0)
	{
	  sum = sum + temp % 10;
	  temp = temp / 10;
	}
      if(sum >= a && sum <= b)
	{
	  ans = ans + i;
	}
    }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>
#include <iomanip>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1ll << 60;

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

ll f(ll n) {
    if(n == 0) return 0;
    if(n % 2) {
        ll tmp = (n + 1) / 2;
        if(tmp % 2) return 1;
        else return 0;
    } else {
        if(n % 4) return n + 1;
        return n;
    }
}

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

    ll A, B;
    cin >> A >> B;
    if(A == B) {
        cout << A << endl;
        return 0;
    }

    ll tmp_a = f(A - 1), tmp_b = f(B);
    ll rsl = tmp_a xor tmp_b;
    cout << rsl << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void) {
  int n;
  cin >> n;
  int a[101];
  for(int i=0;i<n;++i) cin >> a[i];
  sort(a,a+n);
  cout << a[n-1] - a[0] << endl;
}




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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};

struct train{
  double v,t;
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;cin>>n;
  vector<int>t(n+10);
  vector<int>v(n+10);
  for(int i=0;i<n;i++)cin>>t[i];
  for(int i=0;i<n;i++)cin>>v[i];

  double ans = 0,speed=0;
  for(int i=0;i<n;i++){
    for(double j=0;j<t[i];j+=0.5){
      bool flag=true,flag2=true;
      double time = t[i]-j-0.5;
      for(int k=i+1;k<n;k++){
	time += t[k];
	if(speed+0.5-time > v[k+1])flag=false;
	if(speed-v[k+1] > time) flag2=false;
      }
      if(speed+0.5 <= v[i] && flag &&(speed+0.5-(t[i]-j-0.5))<=v[i+1]){
	ans += speed*0.5;
	ans += 0.125;
	speed += 0.5;
      }else if(speed - v[i+1] <= t[i]-j-0.5 &&flag2){
	ans += speed*0.5;
      }else{
	speed -= 0.5;
	ans += speed*0.5;
	ans += 0.125;
      }
    }
  }
  printf("%.10lf\n",ans);
  return 0;
}


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

using P = pair<int, int>;

int main() {
    int n;
    while(cin >> n, n) {
        vector<P> v(n);
        for(int i=0; i<n; ++i) {
            cin >> v[i].first >> v[i].second;
        }
        int m;
        cin >> m;
        for(int i=0; i<m; ++i) {
            int h, r;
            cin >> h >> r;
            v.emplace_back(h, r);
        }
        sort(v.begin(), v.end());
        vector<int> dp(n+m, 1);
        for(int i=0; i<n+m; ++i) {
            for(int j=0; j<i; ++j) {
                if(v[i].first > v[j].first && v[i].second > v[j].second) {
                    dp[i] = max(dp[i], dp[j]+1);
                }
            }
        }
        cout << *max_element(dp.begin(), dp.end()) << endl;
    }
}


Measured memory_bytes: 3000
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement, groupby
from math import floor, ceil, sqrt, factorial, log
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop
from itertools import product
import sys
stdin = sys.stdin
mod = 10**9 + 7


def ns(): return stdin.readline().rstrip()


def ni(): return int(ns())


def na(): return list(map(int, stdin.readline().split()))


n = ni()
ab = []
for _ in range(n):
    ab.append(na())

ab.sort()

amin, bmin = ab[-1][0], ab[-1][1]
print(amin + bmin)


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

void    SSub(int K, string &s, char C, vector<string> &B) {
        for (int i=0; i<s.size(); i++) {
                if (C==s.at(i)) {
                        string SS="";
                        for (int k=0; k<K; k++) {
                                if (i+k>=s.size()) break;
                                SS += s.at(i+k);
                                B.push_back(SS);
                        }
                }
        }
        return;
}

int     main() {
        string s;
        int K;
        cin >>s >>K;
        string ss=s;
        sort(ss.begin(), ss.end());
        ss.erase(unique(ss.begin(), ss.end()), ss.end());
        vector<string> B(0);
        int i=0;
        while (K>B.size()) {
                SSub(K, s, ss.at(i), B);
                sort(B.begin(), B.end());
                B.erase(unique(B.begin(), B.end()), B.end());
                i++;
        }
        cout <<B.at(K-1) <<endl;
        return 0;
};

Measured memory_bytes: 1660
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
vint adj[100001];
bool visited[100001]={};
vint edgedepth[100001];
int depthmax=0;
int pmax[100001],pmin[100001];
int vdepth[100001];
int p[100001];
int ans[100001];
void dfs(int u,int depth){
	visited[u]=1;
	edgedepth[depth].push_back(u);
	vdepth[u]=depth;
	depthmax=max(depthmax,depth);
	int flag=0;
	rep(i,adj[u].size()){
		int v=adj[u][i];
		if(visited[v]==0){
			flag=1;
			p[v]=u;
			dfs(v,depth+1);
		}
	}
}
int main(){
	int N;
	scan(N);
	rep(i,N-1){
		int a,b;
		scan(a>>b);
		a--; b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	dfs(0,0);
	fill(pmax,pmax+N,INF);
	fill(pmin,pmin+N,-INF);
	int K;
	scan(K);
	int flag=1;
	int V[100001],P[100001];
	rep(i,K){
		scan(V[i]>>P[i]);
		V[i]--;
		pmax[V[i]]=P[i];
		pmin[V[i]]=P[i];
	}
	rep(i,K-1){
		if((vdepth[V[i]]+P[i])%2!=(vdepth[V[i+1]]+P[i+1])%2){
			prin("No");
			return 0;
		}
	}
	brep1(d,depthmax){
		rep(i,edgedepth[d].size()){
			int v=edgedepth[d][i];
			int u=p[v];
			pmax[u]=min(pmax[u],pmax[v]+1);
			pmin[u]=max(pmin[u],pmin[v]-1);
			if(pmax[u]<pmin[u]){
				prin("No");
				return 0;
			}
		}
	}
	rep(d,depthmax){
		rep(i,edgedepth[d].size()){
			int u=edgedepth[d][i];
			rep(j,adj[u].size()){
				int v=adj[u][j];
				if(v==p[u]) continue;
				pmax[v]=min(pmax[v],pmax[u]+1);
				pmin[v]=max(pmin[v],pmin[u]-1);
				if(pmax[v]<pmin[v]){
					prin("No");
					return 0;
				}
			}
		}
	}
	rep(d,depthmax+1){
		rep(i,edgedepth[d].size()){
			int u=edgedepth[d][i];
			ans[u]=pmin[u];
		}
	}
	prin("Yes");
	rep(i,N) prin(ans[i]);
	return 0;
}


Measured memory_bytes: 18816
#pragma region header
#include <bits/stdc++.h>
using namespace std;

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;

constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
constexpr char EL[] = "\n";

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
#define UNIQUE(x) (x).erase(unique(all(x)), (x).end());
#define REPIT(x) for(auto it=(x).begin(), end=(x).end(); it!=end; ++it)
#define perm(c) sort(all(c)); for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<typename T = i64>
T IN() { T x; cin >> x; return (x); }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}

void print() {
	cout << EL;
}
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
	cout << head;
	if (sizeof...(tail) != 0) cout << " ";
	print(forward<Tail>(tail)...);
}
template <class T>
void print(vector<T> &vec) {
	for (auto& a : vec) {
		cout << a;
		if (&a != &vec.back()) cout << " ";
	}
	cout << EL;
}
template <class T>
void print(vector<vector<T>> &df) {
	for (auto& vec : df) {
		print(vec);
	}
}

struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

signed solve()
{
	int n, a, b;
	cin >> n >> a >> b;
	print(min(n*a, b));
	return 0;
}

#ifndef LOCALCODE
signed main()
{
	return solve();
}
#endif


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

#define fr(i,b,e) for(int i=(b); i<(e); ++i)
#define rp(i,e) for(int i=0; i<(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long ll;
const int INF=1000000;

vector<int> a(1e6);
vector<ll> cnt(1e6);

int main(void){
    int n;
    cin >> n;
    rp(i,n){
        cin >> a[i];
        ++cnt[a[i]-1];
    }

    ll sum=0;
    
    rp(i,n){
        sum+=cnt[i]*(cnt[i]-1);
    }

    sum=sum>>1;

    rp(i,n){
        cout << sum-cnt[a[i]-1]+1 << '\n';
    }
}

Measured memory_bytes: 14336
#include <iostream>
#include <cmath>
using namespace std;
int main() {
  int D, E;
  double ans;
  while (cin >> D >> E, D) {
    ans = 200;
    for (int i = 0; i <= D/2; ++i) {
      ans = min(ans, fabs(sqrt(i*i + (D-i)*(D-i)) - E));
    }
    cout << ans << endl;
  }
  return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  long long n; scanf("%lld", &n);
  if (n == 2) {
    printf("1");
    return;
  }
  int ans = 2; // n and n-1
  for (long long i = 2; i*i <= n; ++i) {
    if ((n-1) % i == 0) {
      ++ans;
      if ((n-1) / i != i) ++ans;
    }
    if (n % i) continue;
    long long x = n;
    while (x % i == 0) {
      x /= i;
    }
    ans += x % i == 1;
  }
  printf("%d", ans);
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3816
#include <bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll dp[10001][2][101];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string k;
cin>>k;
int d;
cin>>d;
dp[0][0][0]=1;
for(int i=0;i<k.size();i++){
     int tmp=k[i]-'0';
     for(int j=0;j<2;j++){
      for(int l=0;l<d;l++){
         for(int r=0;r<(j?10:tmp+1);r++){
             (dp[i+1][j||(j!=1&&tmp!=r)][(l+r)%d]+=dp[i][j][l])%=mod;
            }
        }
     }
 }
cout<<(dp[k.size()][0][0]+dp[k.size()][1][0]-1+mod)%mod <<endl;
}


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

#define NUM 36

int myatoi(char);

int main()
{
    char a[NUM][5],b[NUM][5],d[5];
    int c[NUM],f[NUM],n;
    int i,j,k = 0,flag = 1,minj = 0;
    
    scanf("%d",&n);
    
    for(i = 0;i < n;i++){
        scanf("%s",a[i]);
        strcpy(b[i],a[i]);
        c[i] = myatoi(a[i][1]);
        f[i] = c[i];
    }
    
    while(flag){
        flag = 0;
        for(j = i-1;j > 0;j--){
            if(c[j] < c[j-1]){
                strcpy(d,a[j-1]);
                strcpy(a[j-1],a[j]);
                strcpy(a[j],d);
                k = c[j];
                c[j] = c[j-1];
                c[j-1] = k;
                flag = 1;
            }
        }
    }
    
    printf("%s",a[0]);
    for(i = 1;i < n;i++){
        printf(" %s",a[i]);
    }
    printf("\n");
    printf("Stable\n");
    
    for(i = 0;i < n;i++){
        minj = i;
        for(j = i;j < n;j++){
            if(f[j] < f[minj]) minj = j;
        }
        if(i != minj){
            strcpy(d,b[i]);
            strcpy(b[i],b[minj]);
            strcpy(b[minj],d);
            k = f[i];
            f[i] = f[minj];
            f[minj] = k;
        }
    }
    
    printf("%s",b[0]);
    for(i = 1;i < n;i++){
        printf(" %s",b[i]);
    }
    printf("\n");
    
    for(i = 0;i < n;i++){
        k = strcmp(a[i],b[i]);
        if(k != 0) break;
    }
    if(k == 0) printf("Stable\n");
    else printf("Not stable\n");
    
    return 0;
}

int myatoi(char x)
{
    if(x == '1') return 1;
    if(x == '2') return 2;
    if(x == '3') return 3;
    if(x == '4') return 4;
    if(x == '5') return 5;
    if(x == '6') return 6;
    if(x == '7') return 7;
    if(x == '8') return 8;
    if(x == '9') return 9;
    else return 0;
}



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

using namespace std;

int main() {
	int n;
	string s;
	cin >> n >> s;
	if (s.length() % 2 == 1) {
		cout << "No";
		return 0;
	}
	string a, b;
	a = s.substr(0, s.length() / 2);
	b = s.substr(s.length() / 2, s.length() - 1);

	if (a == b)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 256
#include <cstdio>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

char buf[10];
int main(void) {
  scanf("%s", buf);
  puts(buf[1] == buf[0] && buf[2] == buf[0] || buf[1] == buf[3] && buf[2] == buf[3] ? "Yes" : "No");
  return 0;
}


Measured memory_bytes: 128