akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) {cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;}
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod=1000000007;
const int MAXN=510, BIG=1000000;

int n, m, k, u, v, x, y, t, a, b, ans;
int A[MAXN][MAXN];

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	cin>>n>>m>>x>>y;
	for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) A[i][j]=+BIG;
	if (m%y){
		for (int i=1; i<=n; i++) for (int j=y; j<=m; j+=y) A[i][j]=-((y-1)*BIG+1);
		cout<<"Yes\n";
		for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) cout<<A[i][j]<<" \n"[j==m];
		return 0;
	}
	if (n%x){
		for (int i=x; i<=n; i+=x) for (int j=1; j<=m; j++) A[i][j]=-((x-1)*BIG+1);
		cout<<"Yes\n";
		for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) cout<<A[i][j]<<" \n"[j==m];
		return 0;
	}
	kill("No")
	
	return 0;
}


Measured memory_bytes: 3328
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int main() {
  //
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  set<int> x, y;
  rep(i, f / (100 * a) + 1) {
    rep(j, f / (100 * b) + 1) {
      if (100 * a * i + 100 * b * j <= f) {
        x.insert(100 * a * i + 100 * b * j);
      }
    }
  }
  rep(i, f / c + 1) {
    rep(j, f / d + 1) {
      if (c * i + d * j <= f) {
        y.insert(c * i + d * j);
      }
    }
  }
  double max = 0;
  int maxw, maxs;
  for (const auto& p : x) {
    if (p == 0) continue;
    for (const auto& q : y) {
      if (p / 100 * e < q) continue;
      if (p + q > f) continue;
      double d = (double)q / (double)(p + q);
      if (max <= d) {
        maxw = p;
        maxs = q;
        max = d;
      }
    }
  }
  cout << maxw + maxs << " " << maxs << endl;
  return 0;
}
// 900 *3000

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

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


const int MOD = 1000000007;

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

    // N 以下の値の和でNを作る
    // 使用する値の最大値が最小になるようにする
    //全部足して、超えたら、あまりの数を取り除く(1から順に足してるので必ずある)
    int cnt = 0;
    int amari,owari;
    for(int i = 1; i <= N; ++i)
    {
      cnt += i;
      if(cnt >= N)
      {
        amari = cnt % N;
        owari = i;
        break;
      }
    }
    for(int i = 1; i <= owari; ++i)
    {
      if(i == amari)continue;
      cout <<  i << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;
const int MOD = 1000000007;


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

    int n; cin >> n;
    std::vector<int> p(n), q(n);

    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];

    std::vector<int> v(n); rep(i,n) v[i] = i+1;

    int pc = 0, qc = 0;
    int c = 1;

    while(next_permutation(v.begin(), v.end())){
        
        bool ps = true, qs = true;

        rep(i,n) if(v[i]!=p[i]) ps = false;
        rep(i,n) if(v[i]!=q[i]) qs = false;

        if(ps) pc = c;
        if(qs) qc = c;

        c++;

    }

    cout << abs(pc - qc) << endl;

    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		ArrayList<Integer> A = new ArrayList<>();
		int N = sc.nextInt();
		for(int a=0; a<N; ++a) {
			A.add(sc.nextInt());
		}
		
		
		int p_num[] = new int[8];
		Arrays.fill(p_num, 0);
		int sp = 0;
		
		int redExist = 0;
		for(int a: A) {
			if(a<3200) {
				p_num[a/400] += 1;
			} else {
				sp += 1;
				redExist = 1;
			}
		}
		
		int ans = 0;
		for(int p: p_num) {
			if(p>0) {
				ans += 1;
			}
		}
		
		int ans_min = Math.max(ans,1);
		int ans_max = ans + sp;
		System.out.println(ans_min + " "+ ans_max);
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
#define ll long long int
using namespace std;

vector<int> x(10), y(10);

double dis(int i, int j) {
	double dx = x[i] - x[j];
	double dy = y[i] - y[j];
	return pow(dx * dx + dy * dy, 0.5);
}

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) cin >> x[i] >> y[i];
	double f = 1;
	for (int i = 1; i <= N; i++) f *= i;

	double ans = 0.0;
	vector<int> v(N);
	for (int i = 0; i < N; i++) v[i] = i;
	do {
		for (int i = 0; i < N - 1; i++) ans += dis(v[i], v[i + 1]);
	} while (next_permutation(v.begin(), v.end()));

	cout << setprecision(20) <<  ans/f << endl;
}	


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int count=0;
  string s;
  getline(cin,s);
  for(int i=0;i<s.length();i++){
    count=count+(s[i]-'0');
  }
  if(count%9==0){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3752
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")
#define int long long

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 2000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

int n, x[200010], y[200010], dp[N << 1][N << 1], inv[200010], fac[200010];

int POW(int x, int t){
	int res = 1;
	while(t){
		if (t & 1) res = res * x % MOD;
		t >>= 1;
		x = x * x % MOD;
	}
	return res;
}

void calc(){
	fac[0] = 1;
	inv[0] = 1;
	for (int i = 1; i < 200010; i++){
		fac[i] = fac[i - 1] * 1ll * i % MOD;
		inv[i] = POW(fac[i], MOD - 2);
	}
}

int nCr(int x, int y){
	if (y > x || y < 0 || x < 0) return 0;
	int res = fac[x];
	res = res * 1ll * inv[y] % MOD;
	res = res * 1ll * inv[x - y] % MOD;
	return res;
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> x[i] >> y[i];
	calc();
	ll ans = 0;
	for (int i = 1; i <= n; i++){
		dp[-x[i] + N][-y[i] + N] ++;
	}
	for (int j = 1; j < 2 * N; j++) dp[0][j] = (dp[0][j] + dp[0][j - 1]) % MOD;
	for (int i = 1; i < 2 * N; i++) dp[i][0] = (dp[i - 1][0] + dp[i][0]) % MOD; 
	for (int i = 1; i < N * 2; i++) for (int j = 1; j < N * 2; j++){
		dp[i][j] += (dp[i - 1][j] + dp[i][j - 1]) % MOD;
		dp[i][j] %= MOD;
	}
	for (int i = 1; i <= n; i++){
		ans = (ans + dp[x[i] + N][y[i] + N]) % MOD;
	//	cout << i << ' ' << dp[x[i] + N][y[i] + N] << '\n';
	}
	//cout << ans << '\n';
	for (int i = 1; i <= n; i++){
		ans -= nCr(x[i] * 2 + y[i] * 2, y[i] * 2);
		ans %= MOD;
		ans += MOD;
		ans %= MOD;
	}
	cout << ans * inv[2] % MOD;






	return 0;
}


Measured memory_bytes: 132736
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        char X = sc.next().charAt(0);
        char Y = sc.next().charAt(0);
        
        int num = X - Y;
        System.out.println(num < 0 ? "<" : (num > 0) ? ">" : "=");
    }
}


Measured memory_bytes: 23764
s = input()
n = len(s)

l = [0 for _ in range(n+1)]
r = [0 for _ in range(n+1)]

for i in range(n):
    if(s[i] == '<'):
        l[i+1] = l[i] + 1
    else:
        l[i+1] = 0
for i in range(n)[::-1]:
    if(s[i] == '>'):
        r[i] = r[i+1] + 1
    else:
        r[i] = 0

t = 0
for i in range(n+1):
    t += max(l[i],r[i])
print(t)

Measured memory_bytes: 29980
H,W=gets.chomp.split.map(&:to_i)
s = []
s << ['#'] * (W+2)
H.times { s << ['#'] + gets.chomp.split("") + ['#']}
s << ['#'] * (W+2)

d = Array.new(H+2).map{Array.new(W+2,Float::INFINITY)}

def dfs(s, d, i, j, c)
  return if s[i][j] == '#'
  return if d[i][j] <= c

  d[i][j] = c
  dfs(s,d,i,j+1,c+1)
  dfs(s,d,i,j-1,c+1)
  dfs(s,d,i+1,j,c+1)
  dfs(s,d,i-1,j,c+1)
end

dfs(s, d, 1, 1, 1)

if d[H][W] == Float::INFINITY
  puts -1
else
  ans = 0
  s.each {|ss| ans += ss.count('.')}
  puts ans - d[H][W]
end


Measured memory_bytes: 2428
import numpy as np
def cmb(n, r):
    if n<r:
      return 0
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

n = int(input())
field = np.array([[0 for _ in range(9)] for _ in range(9)])

for i in range(1, n+1):
    stri = str(i)
    mae = int(stri[0])
    ushiro = int(stri[-1])
    if mae != 0 and ushiro != 0:
        field[mae-1, ushiro-1] += 1

total = 0
for i in range(9):
    val = field[i, i]
    #print(val)
    #print(cmb(val, 2))
    total += val
    total += 2*cmb(val, 2)

for i in range(9):
    for j in range(i, 9):
        if i==j:
            continue
        else:
            total += 2*field[i,j]*field[j,i]
#print(field)
print(total)

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}



int main(){
    int x;
    cin >> x;
    int y=8;
    for(int i=600;i<=1800;i+=200){
        if(x<i){
            cout << y << endl;
            return 0;
        }
        y--;
    }
    cout << 1 << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
vector<ll> v;
ll p[15],hell=pow(10,5);
void func(ll x,ll dep,ll val,ll f){
	if(dep==(-1)){
		v.push_back(val);
		return;
	}
	if(f){
		for(ll i=1;i<10;i++)
		func(i,dep-1,val+p[dep]*i,0);
		func(0,dep-1,0,1);
	}
	else{
	    func(x,dep-1,val+p[dep]*x,0);
	    if(x>=1)
	    func(x-1,dep-1,val+p[dep]*(x-1),0);
	    if(x<9)
	    func(x+1,dep-1,val+p[dep]*(x+1),0);
    }
}
void solve(){
	ll k;
	cin>>k;
	func(0,9,0,1);
	sort(v.begin(),v.end());
	cout<<v[k];
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	for(ll i=0;i<15;i++)
	p[i]=pow(10,i);
	ll qc=1;
	for(ll i=1;i<=qc;i++)
	solve();
}


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

int main() {
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    for (int i = 0; i < 3; i++) {
        if (s.at(i) == t.at(i)) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int INF = 2e9 + 3;
const int N = 2e5 + 3;
const int MOD = 1e9 + 9;
const double EPS = 1e-9;
 
const double PI = acos(-1);
 
void solve() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max({1ll * a * c, 1ll * b * d, 1ll * a * d, 1ll * b * c});
}
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int t;
    t = 1;
    while (t--) {
        solve();
    }
}

Measured memory_bytes: 3648
A, B = gets.split.map(&:to_i)

c = B - A + 1

def bit_cnt(n)
  l = n.to_s(2).size
  result = Hash.new(0)
  return result if n < 0

  result[0] = (n + 1) / 2
  i = 1
  v = 2
  t = 4

  (1..l).each do |i|
    result[i] = v * (n / t) + [n % t - ((2 ** i) - 1), 0].max

    v *= 2
    t *= 2
  end

  result
end

a_h = bit_cnt(A - 1)
b_h = bit_cnt(B)

l = B.to_s(2).size

puts (0..l).map { |i| (b_h[i] - a_h[i]).odd? ? '1' : '0' }.reverse.join.to_i(2)

__END__
1 = (c + 1) / 2
2 = 2 * (c / 4) + [c % 4 - 1, 0].max
3 = 4 * (c / 8) + [c % 8 - 3, 0].max
4 = 8 * (c / 16) + [c % 16 - 7, 0].max
n = (2 ** i) * (c / (2 ** i)) + [c / 



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

int main() {
  int n;
  cin >> n;
  vector<pair<pair<string,int>,int>>data(n);
  for(int i = 0;i < n;i++){
    cin >> data[i].first.first >> data[i].first.second;
    data[i].first.second *= -1;
    data[i].second = i;
  }
  sort(data.begin(),data.end());
  for(int i = 0;i < n;i++){
    cout << data[i].second+1 << endl;
  }
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

ll f(ll a){
  ll cnt=0;
  while(a%2==0){
    a/=2;
    cnt++;
  }
  return cnt;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  vll a(n);
  rep(i,n) cin>>a[i];
  
  rep(i,n){
    if(a[i]%2==1){
      cout<<0<<endl;
      return 0;
    }
    a[i]/=2;
  }
  
  ll t=f(a[0]);
  rep(i,n){
    if(f(a[i])!=t){
      cout<<0<<endl;
      return 0;
    }
    a[i]>>=t; // 2でt回割るのと同値
  }
  m>>=t;
  
  ll l=1;
  rep(i,n){
    l=lcm(l,a[i]);
    if(l>m){
      cout<<0<<endl;
      return 0;
    }
  }
  
  m/=l;
  ll ans=(m+1)/2;
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int a, b, h; cin >> a >> b >> h;
  int res = (a + b) * h / 2;
  cout << res << endl;
  return 0;
}


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

typedef long long ll;

string s; int n;
ll k;
int ans1, ans2;

int main() {
	
	cin >> s; n = (int)s.size();
	cin >> k;
	
	if (s == string(n, s[0])) {
		cout << n * k / 2 << endl;
		return 0;
	}
	
	for (int i = 0; i + 1 < n; i++)
		if (s[i] == s[i + 1]) {
			++ans1;
			++i;
		}
	for (int i = 0; i + 1 < 2 * n; i++)
		if (s[i % n] == s[(i + 1) % n]) {
			++ans2;
			++i;
		}
	cout << ans1 + (ans2 - ans1) * (k - 1) << endl;
	
	return 0;
	
}

Measured memory_bytes: 256
#べき乗(MODあり)(繰り返し２乗法)
def pow(x, n, mod)
  ans = 1
  while n > 0
    ans = ans * x % mod if n.odd?
    x = x * x % mod
    n >>= 1
  end
  ans
end

N = gets.to_i
C = gets.chomp.split(" ").map(&:to_i)
MOD = 10 ** 9 + 7

C.sort!.reverse!
wk = pow(2, 2 * N - 1, MOD)
ans, s, t = [0, 1, 1]
C.each_with_index{|c, idx|
  ans = (ans + (c * s * wk)) % MOD
  s = (2 * s + t) % MOD
  t = (2 * t) % MOD
  wk = wk.even? ? wk / 2 : (wk + MOD) / 2
}

puts ans


Measured memory_bytes: 22264
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t;
    string s;
    cin>>s;
    cout<<s;
    if(s[s.size()-1]=='s') cout<<"es";
    else cout<<"s";
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
/*
CE
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>

*/
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define mem(a,b) memset(a,b,sizeof (a))
#define ios std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0);
// ios  can not be used with scanf,printf.  IF  ios MUST cin,cout.
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;
const ll mod=998244353;
const int INF=0x3f3f3f3f;
ll ksm(ll a,ll b){ll res=1;a%=mod;for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

const int N=2e6+10;
ll n,x,m;
ll s[N],a[N];
ll ans;
map<ll,ll>vis;
int main(){
    scanf("%lld%lld%lld",&n,&x,&m);
    a[1]=s[1]=x;
    ll st=1,ed=n;
    for(ll i=2;i<=n;i++){
        a[i]=a[i-1]%m*a[i-1]%m;
        if(!vis[a[i]]){
            vis[a[i]]=i;
        }
        else{
            st=vis[a[i]];
            ed=i-1;
            break;
        }
        s[i]=s[i-1]+a[i];
    }
    ll c=n-(st-1);
    ll t=c/(ed-st+1),need=c%(ed-st+1);
    ans=s[st-1]+(s[ed]-s[st-1])*t+(s[st+need-1]-s[st-1]);
    printf("%lld \n",ans);
    return 0;
}


Measured memory_bytes: 7660
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 
 
N, *num = [int(input()) for i in range(6)]
min = sorted(num)[0]

if N % min == 0:
    print(N//min + 4)
else:
    print(N//min + 5)



Measured memory_bytes: 14592
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

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

  for(int i=0;i<A;i++){
    if(!('0'<=S.at(i) && S.at(i)<='9')){
      cout << "No" << endl;
      return 0;
    }
  }

  if(S.at(A)!='-'){
    cout << "No" << endl;
    return 0;
  }

  for(int i=A+1;i<A+B+1;i++){
    if(!('0'<=S.at(i) && S.at(i)<='9')){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;

  ll p1 = a * x + b * y;
  ll p2 = c * x * 2 + max(y - x, 0) * b;
  ll p3 = c * y * 2 + max(x - y, 0) * a;

  cout << min(p1, min(p2, p3)) << ln;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

string s, t;
int pos[100005][30];

void init(){
    for (int i = 0; i < 26; i++)
        pos[s.size()][i] = -1;
    for (int i = s.size() - 1; i >= 0; i--){
        for (int j = 0; j < 26; j++){
            pos[i][j] = pos[i + 1][j];
            if (s[i] - 97 == j) pos[i][j] = i;
        }
    }
}

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> s >> t;
    init();
    int cur = -1;
    int64 res = 0;
    for (int i = 0; i < t.size(); i++){
        int last = cur++;
        if (cur >= s.size()) cur = 0;
        if (pos[cur][t[i] - 97] == -1 && pos[0][t[i] - 97] == -1){
            cout << -1;
            return 0;
        }
        if (pos[cur][t[i] - 97] != -1) cur = pos[cur][t[i] - 97];
        else cur = pos[0][t[i] - 97];
        int64 tmp = (cur + s.size() - last) % s.size();
        if (tmp == 0) tmp = s.size();
        res += 1ll * tmp;
    }
    cout << res;
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  char c = ' ';
  int res = 0;
  for (char s_i : s) {
    if (s_i != c) {
      ++res;
    }
    c = s_i;
  }
  cout << res << endl;
}


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

using ll=long long;

int main() {
  string s; cin >>s;
  string ans="";
  rep(i,0,s.size()) {
    if (s[i]=='0' || s[i]=='1') {
      ans.push_back(s[i]);
    } else {
      if (ans!="") ans.pop_back();
    }
  }
  cout <<ans <<endl;
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

vl dx={-1,1,0,0};
vl dy={0,0,-1,1};

int main(){
    ll H, W; cin >> H >> W;
    vs S(H);
    REP(i, H) cin >> S[i];
    
    queue<PL> q;
    q.push({0,0});
    vvl dist(H, vl(W, -1)); dist[0][0] = 1;
    while(!q.empty()){
        PL now = q.front(); q.pop();
        REP(i, 4){
            ll nh = now.ff+dx[i], nw = now.ss+dy[i];
            if(0<=nh && nh < H && 0 <= nw && nw < W && dist[nh][nw] == -1 && S[nh][nw] == '.'){
                dist[nh][nw] = dist[now.ff][now.ss]+1;
                q.push({nh,nw});
            }
        }
    }
    if(dist[H-1][W-1] == -1) cout << -1 << endl;
    else{
        ll wcnt = 0;
        REP(i, H) REP(j, W) if(S[i][j] == '.') wcnt++;
        cout << wcnt - dist[H-1][W-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cstdlib>
#include <queue>
using namespace std;
typedef long long ll;
#define N 100050
int n,a[N],m,p[N],vis[N],b[N],lb;ll X[N],d[N],K,ans[N];
int main() {
	scanf("%d",&n);
	int i,y=0,j;
	for(i=1;i<=n;i++) scanf("%lld",&X[i]),d[i]=X[i]-X[i-1];
	scanf("%d%lld",&m,&K);
	for(i=1;i<=m;i++) scanf("%d",&a[i]);
	for(i=1;i<=n;i++) p[i]=i;
	for(i=1;i<=m;i++) swap(p[a[i]],p[a[i]+1]);
	for(i=1;i<=n;i++) if(!vis[i]) {
		int x=i;lb=0;
		for(;!vis[x];x=p[x]) {
			vis[x]=1;
			b[lb++]=x;
		}
		for(int i=0;i<lb;i++) {
			ans[b[i]]=d[b[(i+K)%lb]];
		}
	}
	for(i=1;i<=n;i++) X[i]=ans[i]+X[i-1];
	for(i=1;i<=n;i++) printf("%lld.0\n",X[i]);
}


Measured memory_bytes: 5248
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item = U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let K: usize = sc.get();
    let N: usize = sc.get();
    let A: Vec<usize> = sc.vec(N);
    let mut d = 0;
    for i in 0..N-1 {
        d = max(d, A[i+1] - A[i]);
    }
    d = max(d, K - A[N-1] + A[0]);
    let ans = K - d;
    println!("{}", ans);
}


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


int main(){
        ll x; scanf("%lld", &x);
        ll prime[100010];
        bool is_prime[100011];

        ll p=0;
        for(ll i=0; i<=100010; i++) is_prime[i] = 1;
        is_prime[0] = is_prime[1] = 0;

        for(ll i=2; i<=100010; i++){
                if(is_prime[i]){
                        prime[p++] = i;
                        for(ll j=2*i; j<100010; j+=i) is_prime[j] = 0;
                }
        }

        ll ans = 0;
        for(ll i=x; i<=100010; i++){
                if(is_prime[i]){
                        ans = i;
                        break;
                }
        }
        printf("%lld\n", ans);
        return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a < b) {
            if (b < c) {
                System.out.printf("%d %d %d\n", a, b, c);
            } else {
                if (a < c) {
                    System.out.printf("%d %d %d\n", a, c, b);
                } else{
                    System.out.printf("%d %d %d\n", c, a, b);
                }
            }
        } else {
            if (a < c) {
                System.out.printf("%d %d %d\n", b, a, c);
            } else {
                if (b < c) {
                    System.out.printf("%d %d %d\n", b, c, a);
                } else {
                    System.out.printf("%d %d %d\n", c, b, a);
                }

            }
        }
    }
}


Measured memory_bytes: 26336
#include<stdio.h>

int main(void){
    int N;
    scanf("%d",&N);
    if(N%10==3){
        printf("bon\n");
    }else{
        if(N%10==0 || N%10==1 || N%10==6 || N%10==8){
            printf("pon\n");
        }else{
            printf("hon\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1664
import Data.List
import Control.Monad

solve :: Int -> Int -> [[Int]] -> Int
solve n m xyz = maximum . map f $ replicateM 3 [-1,1] where
  f p = sum . take m . sortBy (flip compare) $ map (sum . zipWith (*) p) xyz

main = do
  [n, m] <- readWords
  xyz <- replicateM n readWords
  print $ solve n m xyz

readWords = map read . words <$> getLine


Measured memory_bytes: 3836
module number_theory_mod
    use,intrinsic :: iso_fortran_env
    implicit none
    private
    public:: fc_init,comb,inv,mod_pow
    public:: lcm, gcd
    integer(int64):: md=1000000007,n
    integer(int64), allocatable:: frac(:), ifrac(:)

contains
    subroutine fc_init(input_n, input_md)
        integer(int64),intent(in):: input_n
        integer(int64),intent(in),optional:: input_md
        integer(int64):: i

        n = input_n
        if (present(input_md)) md = input_md
        allocate(frac(0:n), ifrac(0:n))
        frac(0) = 1; ifrac(0) = 1
        do i=1,n
            frac(i) = mod(frac(i-1)*i, md)
            ifrac(i) = inv(frac(i))
        end do
    end subroutine


    function comb(n,p) result(ret)
        integer(int64):: n,p
        integer(int64):: ret
        ret = mod(mod(frac(n)*ifrac(p),md)*ifrac(n-p),md)
    end function


    function inv(x) result(ret)
        integer(int64),intent(in):: x
        integer(int64):: ret
        ret = mod_pow(x,md-2)
    end function


    function mod_pow(base,exponent) result(ret)
        use,intrinsic :: iso_fortran_env
        integer(int64),intent(in):: base,exponent
        integer(int64):: ret,a,x

        ret = 1
        a = base
        x = exponent
        do while(x > 0)
            if (btest(x,0)) ret = mod(ret*a,md)
            a=mod(a*a,md)
            x=rshift(x,1)
        end do
    end function


    function lcm(x,y) result(ret)
        integer(int32):: x,y,ret
        ret=x*y/gcd(x,y)
    end function


    recursive function gcd(x,y) result(ret)
        integer(int32):: x,y,ret
    
        if (mod(x,y) == 0) then
            ret = y
            return
        end if
        ret = gcd(y,mod(x,y))
    end function
end module

program main
    use,intrinsic :: iso_fortran_env
    use number_theory_mod
    implicit none
    integer(int64):: n,md=1000000007

    read*, n
    print'(i0)', modulo(mod_pow(10_8,n) - 2*mod_pow(9_8,n) + mod_pow(8_8,n), md)    
end program main

Measured memory_bytes: 2928
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<P> d;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        d. push_back((P(a, i)));
    }
    sort(all(d));
    int ans = 0;
    set<int> st;
    st.insert(-1);
    st.insert(n);
    rep(i, 0, n){
        st.insert(d[i].second);
        auto it = st.find(d[i].second);
        it++;
        int right = *it;
        it--; it--;
        int left = *it;
        int tmp = (right - d[i].second) * (d[i].second - left);
        ans += tmp * d[i].first;
        // cout << right << ' ' << left << ' ' << tmp << endl;
    }
    cout << ans << endl;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
    int Q;cin>>Q;
    
    int sumB=0;
    
    priority_queue<int>lo;
    priority_queue<int,vint,greater<int>>hi;
    int sumlo=0,sumhi=0;
    
    while(Q--){
        int t;cin>>t;
        if(t==1){
            int a,b;
            cin>>a>>b;
            sumB+=b;
            hi.push(a);
            sumhi+=a;
            while(lo.size()<hi.size()){
                int tmp=hi.top();
                hi.pop();
                lo.push(tmp);
                sumhi-=tmp;
                sumlo+=tmp;
            }
            while(hi.size()&&lo.top()>hi.top()){
                int tmplo=lo.top();
                int tmphi=hi.top();
                lo.pop();hi.pop();
                sumhi+=tmplo-tmphi;
                sumlo+=tmphi-tmplo;
                lo.push(tmphi);hi.push(tmplo);
            }
        }
        else{
            int x=lo.top();
            int ans=sumB+sumhi-x*(int)hi.size()+x*(int)lo.size()-sumlo;
            cout<<x<<" "<<ans<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define rep(it,st,en) for(int it=(st);it<(int)(en);++it)
#define allof(c) (c).begin(), (c).end()
#define mt make_tuple
#define mp make_pair
#define pb push_back
#define X first
#define Y second
typedef long long int ll; 
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
const int INF=(int)1e9; 
const double EPS=(ld)1e-7;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<ll> v(n);
    ll ans = 0;
    rep(i,0,n) cin>>v[i];
    bool stop = false;
    while(!stop){
        stop = true;
        ll add = 0;
        rep(i,0,n) {
            ll k = v[i]/n;
            if(k) stop = false;
            v[i] -= k*(n+1);
            add += k;
        }
        ans += add;
        rep(i,0,n)
            v[i] += add;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
/*

                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                    prayer
*/

// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"Yes"<<"\n"
#define no cout<<"No"<<"\n"

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

	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a,b)<<" "<<max(0ll,a+b-n)<<endl;
}


Measured memory_bytes: 256
N = int(input())
a = list(map(int,input().split()))

r = []

ruiseki = 0
for val in a:
    ruiseki += val
    r.append(ruiseki)

ans = 999999999999
for i in range(N-1):
    if ans > abs(r[-1] - r[i] - r[i]):
        ans = abs(r[-1] - r[i] - r[i])
print(ans)


Measured memory_bytes: 24948
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    static void solve(Scanner sc) {
        int n = sc.nextInt();

        long l0 = 2l;
        long l1 = 1l;
        if (n == 1) {
            System.out.println(l1);
            return;
        }

        long li = 0;
        for (int i = 0; i < n - 1; i++) {
            li = l0 + l1;
            l0 = l1;
            l1 = li;
        }

        System.out.println(li);
    }
}

Measured memory_bytes: 22996
import sys
import math
import itertools
import collections
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    N, M, K = NMI()
    A = NLI()
    B = NLI()
    
    cumsum_A = [0 for _ in range(len(A)+1)]
    cumsum_B = [0 for _ in range(len(B)+1)]    
    
    cnt = 0
    
    for n in range(N):
        cnt += A[n]
        cumsum_A[n+1] = cnt
        
    cnt = 0
    
    for m in range(M):
        cnt += B[m]
        cumsum_B[m+1] = cnt
    

    
    ans = 0
    b= M
    
    for n in range(N+1):
        remain_K = K - cumsum_A[n]
        if remain_K < 0:
            break
        else:
            for m in range(b,-1,-1):
                if cumsum_B[m]> remain_K:
                    continue
                else:
                    b = m
                    ans = max(ans,n+m)
                break
    
    print(ans)
            
    


if __name__ == '__main__':
    main()

Measured memory_bytes: 47992
let split str delim =
  let rec doit s acc =
    match
      try Some (String.rindex s delim) with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s1 (s2 :: acc)
  in
  doit str []

let () =
  match List.map int_of_string (split (read_line ()) ' ') with
  | [n; k] -> begin
      let a = Array.init n (fun _ -> read_int ()) in
      let check p =
        let rec doit i j s =
          if i = n then n
          else if j >= k then i
          else
            let x = s + a.(i) in
            if x > p then doit i (j + 1) 0
            else doit (i + 1) j x
        in
        doit 0 0 0
      in
      let rec bin_search l r =
        if r < l then l
        else
          let m = (l + r) / 2 in
          if check m >= n then bin_search l (m - 1)
          else bin_search (m + 1) r
      in
      Printf.printf "%d\n" (bin_search 0 (100000 * 10000))
    end
  | _ -> exit 1

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
#define PINT pair<int,int>
#define f1 first
#define s2 second
const int INF = 1e9 + 7;

using namespace std;

#define MAX_V 202
struct edge{int to, cap, rev;}; //辺（行き先，容量，逆辺）

vector<edge> G[MAX_V];  //隣接リスト
int level[MAX_V];   //ｓからの距離
int iter[MAX_V];    //どこまで調べ終わったか

//sからの最短距離をBFSで計算する
void bfs(int s){
    memset(level, -1, sizeof(level));
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while(!que.empty()){
        int v = que.front(); que.pop();
        REP(i,G[v].size()){
            edge &e = G[v][i];
            if(e.cap > 0 && level[e.to] < 0){
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

//増加パスをDFSで探す
int dfs(int v, int t, int f){
    if(v == t) return f;
    for(int &i = iter[v]; i < G[v].size(); i++){
        edge &e = G[v][i];
        if(e.cap > 0 && level[v] < level[e.to]){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

//sからtへの最大流を求める
int max_flow(int s, int t){
    int flow = 0;
    for(;;){
        bfs(s);
        if(level[t] < 0) return flow;
        memset(iter, 0, sizeof(iter));
        int f;
        while((f = dfs(s, t, INF)) > 0){
            flow += f;
        }
    }
}

//fromからtoへ向かう容量capの辺をグラフに追加する
void add_edge(int from, int to, int cap){
    G[from].push_back((edge){to, cap, G[to].size()});
    G[to].push_back((edge){from, 0, G[from].size() - 1});
}

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

    int n;
    cin >> n;
    vector<PINT> red(n),blue(n);
    REP(i,n) cin >> red[i].f1 >> red[i].s2;
    REP(i,n) cin >> blue[i].f1 >> blue[i].s2;

    sort(red.begin(),red.end());
    sort(blue.begin(),blue.end());

    FOR(i,1,n+1) add_edge(0,i,1);
    FOR(i,101,101+n+1) add_edge(i,201,1);
    REP(i,n){
        REP(j,n){
            if(red[j].f1>=blue[i].f1) break;
            if(red[j].s2<blue[i].s2){
                add_edge(1+i,101+j,1);
            }
        }
    }

    cout << max_flow(0,201) << endl;
    return 0;
}


Measured memory_bytes: 384