akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;

namespace ABC145C
{
    public class EmptyClass
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var indexs = new int[n];
            int[][] xy = new int[n][];
            for (int i = 0; i < n; i++)
            {
                xy[i] = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                indexs[i] = i;
            }
            var perms = GeneratePermutation(indexs);
            double total = 0;
            foreach (var item in perms)
            {
                double subTotal = 0;
                for (int i = 0; i < item.Length-1; i++)
                {
                    subTotal += Math.Sqrt(Math.Pow(xy[item[i]][0] - xy[item[i + 1]][0], 2) + Math.Pow(xy[item[i]][1] - xy[item[i + 1]][1], 2));
                }
                total += subTotal;
            }
            Console.WriteLine(total / perms.Count);

        }

        static List<T[]> GeneratePermutation<T>(params T[] array) where T : IComparable
        {
            var a = new List<T>(array).ToArray();
            var res = new List<T[]>
            {
                new List<T>(a).ToArray()
            };
            var n = a.Length;
            var next = true;
            while (next)
            {
                next = false;
                int i;
                for (i = n - 2; i >= 0; i--)
                {
                    if (a[i].CompareTo(a[i + 1]) < 0)
                        break;
                }
                if (i < 0)
                    break;

                var j = n;
                do
                {
                    j--;
                } while (a[i].CompareTo(a[j]) > 0);

                if (a[i].CompareTo(a[j]) < 0)
                {
                    var tmp = a[i];
                    a[i] = a[j];
                    a[j] = tmp;
                    Array.Reverse(a, i + 1, n - i - 1);
                    res.Add(new List<T>(a).ToArray());
                    next = true;
                }
            }
            return res;
        }
    }
}


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

int main() {
  int64_t N,M,ans=0;
  cin >> N >> M;
  vector<int> vec(M);
  for(int i=0;i<M;i++){
    cin >> vec.at(i);
    ans+=vec.at(i);
  }
  if(N-ans>=0) cout << N-ans << endl;
  else cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 3668
#include <stdio.h>

int main(void){

  long n,k;
  scanf("%ld %ld", &n, &k);
  long sum = 0;
  for (long i = k; i <= n+1; i++) {
    sum += n*i-(i*(i-1)/2)+1;
    sum -= (i*(i-1)/2);
    sum %= 1000000007;
  }
  printf("%ld\n", sum);

  return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

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

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int n;
map<int, int> prime_factor(int n) {
  map<int, int> res;
  for(int i=2; i*i<=n; i++) {
    while(n % i == 0) {
      ++res[i];
      n /= i;
    }
  }
  if(n != 1) ++res[n];
  return res;
}

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

  cin >> n;

  map<int, int> mp;
  FOR(i, 2, n + 1) {
    auto p = prime_factor(i);
    for(auto j : p) {
      mp[j.first] += j.second;
    }
  }

  int ans = 0;
  for(auto i : mp) if(i.second >= 74) ans++;

  REP(i, mp.size()) REP(j, mp.size()) {
    if(i != j && mp[i] >= 14 && mp[j] >= 4) ans++;
  }

  REP(i, mp.size()) REP(j, mp.size()) {
    if(i != j && mp[i] >= 24 && mp[j] >= 2) ans++;
  }

  REP(i, mp.size()) REP(j, mp.size()) FOR(k, j + 1, mp.size()) {
    if(i != j && j != k && k != i && mp[i] >= 2 && mp[j] >= 4 && mp[k] >= 4) ans++;
  }

  cout << ans << endl;
}


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

int main () {
  int A, B;
  cin >> A >> B;
  int count = 0;
  for (int i = A; i <= B; i++) {
    if (i/10000 == i%10 && i%10000/1000 == i%100/10) {
      count ++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int maxn = 1e7 + 5;
typedef long long ll;
ll f[maxn], n, ans;
int main()
{
	for (int i = 1; i < maxn; i++)
	{
		for (int j = i; j < maxn; j += i)
			f[j]++;
	}
	cin >> n;
	for (int i = 1; i <= n; i++)
	{
		ans += f[i] * i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 81680
N = int(input())
H = list(map(int, input().split()))

ma = 0
cnt = 0
h = H[0]
for i in range(1, N):
    if h >= H[i]:
        cnt += 1
        ma = max(cnt, ma)
    else:
        cnt = 0
    h = H[i]
print(ma)

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

int main(){
  int a, b, c, t;
  cin >> a >> b >> c;

  if (a > b) {t = a; a = b; b = t;}
  if (b > c) {t = b; b = c; c = t;}
  if (a > b) {t = a; a = b; b = t;}

  cout << a << " " << b << " " << c << endl;

  return 0;
}

Measured memory_bytes: 3104
#define _USE_MATH_DEFINES
#include <array>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << ": " << arg1 << " |";
	__f(comma + 1, args...);
}


int main() {
	int N;
	cin >> N;
	if (N % 2 == 0) {
		cout << 0.5;
	}
	else 
		cout << (double)(N / 2 + 1) / N;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define dbg(n) cout<<#n<<' '<<n<<endl;
#define dbg_v(v) cout<<#v<<":";for(int i=0;i<(int)v.size();i++) cout<<" "<<v[i]; cout<<endl;
int power(ll x,ll y){ll res = 1;while(y>0){if(y&1)res = (res*x)%mod;y=y>>1;x=(x*x)%mod;}return res;}
int main(){ 
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);	
	int l,r,d;
	cin>>l>>r>>d;
	cout<<r/d-(l-1)/d<<endl;	
}




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

const ll N = 100005;

ll n, l, t, a[N], b[N], c[3];

vector<ll> ans;

int main()
{
	scanf("%lld%lld%lld",&n,&l,&t);
	for(ll i=0;i<n;i++) {
		scanf("%lld%lld",&a[i],&b[i]);
		if(b[i] == 1) {
			if(l - a[i] <= t % l) c[1]++;
			ans.push_back((a[i] + t) % l);
		}
		else {
			if(a[i] < t % l) c[2]++;
			ans.push_back(((a[i] - t) % l + l) % l);
		}
		c[b[i]] += t / l;
	}
	sort(ans.begin(), ans.end());
	for(ll i=0;i<n;i++) {
		printf("%lld\n",ans[((c[1] - c[2]) % n + n + i) % n]);
	}
}


Measured memory_bytes: 3700
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

ll rec(string N, int K) {
    
    ll m = N.length() - 1;
    ll msd = N[0] - '0';
    if (K == 0) return 1;
    if (N.empty()) {
        return 0;
    }

    ll dd1 = 1;
    ll dr1 = 1;
    ll t1  = 1;
    for (int i = 0; i < K; i++) {
        dd1 *= m - i;
        dr1 *= i + 1;
        t1  *= 9;
    }
    ll dd2 = 1;
    ll dr2 = 1;
    ll t2  = 1;
    for (int i = 0; i < K - 1; i++) {
        dd2 *= m - i;
        dr2 *= i + 1;
        t2  *= 9;
    }
    N.erase(N.begin());
    if (msd == 0) {
        return rec(N, K);
    }
    else {
        return dd1 / dr1 * t1 + (msd - 1) * dd2 / dr2 * t2 + rec(N, K - 1);
    }
}

int main()
{
    string N;
    int K;
    cin >> N;
    cin >> K;
    ll ans = rec(N, K);
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
def main():
    N, D = map(int, input().split())
    P =  [list(map(int, input().split())) for _ in range(N)]
    
    D2 = D**2
    count = 0
    for p in P:
        if p[0]**2 + p[1]**2 <= D2:
            count += 1

    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 45452
# include <bits/stdc++.h>
# define ll long long
# define all(x) x.begin(), x.end()
# define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
# define MOD 1000000007
using namespace std;
ll dp [2500]{0};
ll dp2 [2500]{0};
int main(){
	fastio;
	int n,k,tmp;
	cin>>n>>k;
	vector <int> l0,g0;
	ll num0=0;
	for (int i=0;i<n;i++){
		cin>>tmp;
		tmp-=k;
		if (tmp==0) num0++;
		else if (tmp<0) l0.push_back(-tmp);
		else g0.push_back(tmp);
	}
	sort(all(l0));sort(all(g0));
	dp[0]=1;dp2[0]=1;
	for (int i=0;i<l0.size();i++){
		for(int x=2499;x>0;x--){
			int t=x-l0[i];
			if (t<0)continue;
			dp[x]+=dp[t];
		}
	}
	for (int i=0;i<g0.size();i++){
		for(int x=2499;x>0;x--){
			int t=x-g0[i];
			if(t<0) continue;
			dp2[x]+=dp2[t];
		}
	}
	ll re=0;
	for(int i=0;i<2500;i++){
		 re+=dp[i]*dp2[i];
	}
	re*=(1LL<<num0);

	cout<<re-1<<'\n';
	return 0;
}

Measured memory_bytes: 3660
from functools import reduce
N,a,b = map(int,input().split())
MOD = 10**9+7
def f(r):
    nPr = reduce(lambda x,y: x * y % MOD,range(N,N-r,-1))
    r_fact = reduce(lambda x,y: x * y % MOD,range(1,r+1))
    return nPr * pow(r_fact,MOD-2,MOD) % MOD
result = pow(2,N,MOD) - f(a) - f(b) - 1
result %= MOD
print(result)


Measured memory_bytes: 38896
require 'forwardable'

class Array
    include Comparable
    def <=>(other)
        c = (self[0] <=> other[0])
        c == 0 ? (self[1] <=> other[1]) : c
    end
end

class Heap
    extend Forwardable

    def initialize
        @array = []
        @index = {}
    end

    def add(obj, key)
        @array << [obj, key]
        @index[obj] = @array.size - 1
        lift_up(@array.size - 1)
    end

    def swap(i, j)
        u = @array[i]
        v = @array[j]
        @index[u[0]], @index[v[0]] = j, i
        @array[i], @array[j] = v, u
    end

    def lift_up(i)
        return if i == 0
        j = (i - 1) / 2
        if @array[i][1] < @array[j][1]
            swap(i, j)
            lift_up(j)
        end
    end

    def del_min
        raise "heap is empty!" if empty?
        min = @array[0]
        if size > 1
            swap(0, @array.size-1)
            @array.pop
            lift_down(0)
        else
            @array.pop
        end
        @index.delete(min[0])
        min
    end

    def inc_key(obj, diff)
        i = @index[obj]
        @array[i][1] += diff
        lift_down(i)
    end

    def dec_key(obj, diff)
        i = @index[obj]
        @array[i][1] -= diff
        lift_up(i)
    end

    def update_key(obj, new_key)
        i = @index[obj]
        return unless i
        old_key = @array[i][1]
        @array[i][1] = new_key
        if new_key > old_key
            @array[i][1] = new_key
            lift_down(i)
        else
            @array[i][1] = new_key
            lift_up(i)
        end
    end

    def min_obj
        @array[0][0]
    end

    def min_key
        @array[0][1]
    end

    def lift_down(i)
        j = 2 * i + 1
        k = j + 1
        if k >= size
            return if j >= size
            if @array[i][1] > @array[j][1]
                swap(i, j)
                lift_down(j)
            end
        else
            l = (@array[j][1] < @array[k][1] ? j : k)
            if @array[i][1] > @array[l][1]
                swap(i, l)
                lift_down(l)
            end
        end
    end

    def key(obj)
        i = @index[obj]
        @array[i][1]
    end

    def_delegators :@array, :empty?, :size
end

n, r, l = gets.split.map(&:to_i)
heap = Heap.new
total_time = {}
(1..n).each do |i|
    heap.add(i, [0, i])
    total_time[i] = 0
end

events = (1..r).map { gets.split.map(&:to_i) }

t0 = 0
until events.empty?
    _, t, _ = events[0]
    top = heap.min_obj
    total_time[top] += t - t0

    while !events.empty? and events[0][1] == t
        d, t, x = events.shift
        score, i = heap.key(d)
        heap.update_key(d, [score - x, d])
    end
    t0 = t
end
top = heap.min_obj
total_time[top] += l - t0
p total_time.max_by {|i, t| t}[0]



Measured memory_bytes: 82184
#include <iostream>
#include <stack>
#include <string>
#include <cstdlib>
using namespace std;
int main() {
  string input;
  stack<int> opperand;
  int input_int;
  int first;
  int second;
  while (cin >> input) {
    if (input == "+") {
      first = opperand.top();
      opperand.pop();
      second = opperand.top();
      opperand.pop();
      opperand.push(first + second);
      }
    else if (input == "-") {
      first = opperand.top();
      opperand.pop();
      second = opperand.top();
      opperand.pop();
      opperand.push(second - first);
      }
    else if (input == "*") {
      first = opperand.top();
      opperand.pop();
      second = opperand.top();
      opperand.pop();
      opperand.push(first * second);

      }
    else {
      input_int = atoi(input.c_str());
      opperand.push(input_int);
	}
  }
  cout << opperand.top() << endl;
  return 0;
}


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<int, int> i_i;

const int MOD = 1e9 + 7;
const ll INF = LLONG_MAX / 2;

int main() {
	int N; cin >> N;
	vector<int> a(N);
	rep(i, N) scanf("%d", &a[i]);
	vector<ll> sum(N + 1);
	rep(i, N) sum[i + 1] = sum[i] + a[i];
	ll mi = INF;
	for (int i = 1; i <= N - 1; i++)
		mi = min(mi, abs(sum[N] - sum[i] * 2));
	cout << mi << endl;
}


Measured memory_bytes: 2560
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
count = - sum(A) + sum(B) #操作回数
inv = 0
for i in range(N):
  inv += max(0, A[i] - B[i])
  
inv2 = 0
for i in range(N):
  inv2 += max(0, (B[i] - A[i]+1)//2)
  
if count >= 0 and inv <= count and inv2 <= count:
  print("Yes")
else :
  print("No")

Measured memory_bytes: 4596
#include <cstdio>
#include <climits>

int min(int a, int b)
{
	return a < b ? a : b;
}

int main()
{
	int H, N;
	int A[10000];
	int B[10000];
	int dp[100000];

	scanf("%d %d", &H, &N);
	for (int i = 0; i < N; ++i)
		scanf("%d %d", &A[i], &B[i]);

	for (int h = 1; h <= H; ++h)
		dp[h] = INT_MAX;

	for (int h = 1; h <= H; ++h)
	{
		for (int j = 0; j < N; ++j)
			dp[h] = min(dp[h], dp[h - A[j]] + B[j]);
	}

	printf("%d\n", dp[H]);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt() -x;
        int b = sc.nextInt() -x;
        if(a < 0)a *= -1;
        if(b < 0)b *=-1;
        if(a > b){
            System.out.print("B");
        } else {
            System.out.print("A");
        }
    }
    
}


Measured memory_bytes: 21716
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<queue>
#include <algorithm>
#include<functional>
#include<cstdlib>
#include<cmath>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define CI cin >>
#define CO cout <<
#define E << endl;

using namespace std;

typedef pair<int, int> P;
typedef pair<long, long> LP;
typedef pair<int, P> PP;
typedef pair<long, LP> LPP;



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

int A = 0, B = 0, K = 0, T = 0, W = 0, N = 0, H = 0;
int n = 0;
double L = 0;
double S = 0;
double ar = 0, br = 0, cr = 0;
int answer = 0;

string C;
string sA, strB;
vector<vector<char>> map;
vector<double> num;
vector<string> str;

int sum = 0;

vector<int> value;
vector<int> weight;

int dp[110][10010];

void input() {
	CI N >> W;

	int temp;

	for (int i = 0; i < N;i++) {
		CI temp;
		value.push_back(temp);
		CI temp;
		weight.push_back(temp);
	}


	return;
}


int main(void) {
	input();

	for (int i = 0; i < N;i++) {
		for (int j = 0; j <= W;j++) {
			if (j >= weight[i]) {
				dp[i + 1][j] = max(dp[i][j], value[i] + dp[i + 1][j - weight[i]]);
			}
			else {
				dp[i + 1][j] = dp[i][j];
			}
		}
	}

	CO dp[N][W] E


	return 0;
}

Measured memory_bytes: 7084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	int a, b;
	cin >> a >> b;
	if(a > 9 || b > 9) cout << -1 << endl;
	else {
		cout << a*b << endl;
	}
	return 0;
}



Measured memory_bytes: 3508
a=input()
#print(a)
lenS=len(a)
b1=list()
b2=list()
c=a[0]
b1.append(1)
b2.append(a[0])
max_count=1
for i in range(1,len(a)):
  if c!=a[i]:
    c=a[i]
    b1.append(1)
    b2.append(a[i])
  else:
    b1[-1]+=1
    #if b[-1]>max_count:
      #max_count=b[-1]
      #max_i=i
#print(b1)
#print(b2)
N=len(b1)
ans=list()
if a[0]=='<':
  ans+=list(range(b1[0]+1))
else:
  ans+=list(range(b1[0]+1))[::-1]
#print(ans)  
for i in range(1,N):
  if b2[i]=='<':
    ad=list(range(b1[i]+1))
  else:
    ad=list(range(b1[i]+1)[::-1])
  if ans[-1]<ad[0]:
    del ans[-1]
  else:
    del ad[0]
  ans+=ad
#print(ans)
print(sum(ans))

Measured memory_bytes: 88716
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;

void debug_out() { cout << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
//




/*

*/

int main(){
  int n;
  cin >> n;
  //debug(n);
  vector<int> a(n);
  REP(i,n) cin >> a[i];
  debug(n);
  debug(a[0]);
  vector<int> sell;
  vector<int> buy;
  bool hold = false;

  REP(i,n-1){
    if(hold){
      if(a[i] > a[i+1] ){
        sell.push_back(a[i]);
        hold = false;
      }
    }

    if(!hold){
      if(a[i] < a[i + 1]){
        buy.push_back(a[i]);
        hold = true;
      }
    }
  }

  if(buy.empty()){
    cout << 1000 << endl;
    return 0;
  }

  if(sell.size() != buy.size()){
    sell.push_back(a[n-1]);
  }

  //
  // for(auto x: buy) cout << x << " ";
  // cout << endl;
  //
  // for(auto x: sell) cout << x <<" ";
  // cout <<  endl;



  ll sum = 1000;
  ll nmb = 0;

  REP(i,sell.size()){
    nmb =  sum/buy[i];
    sum %= buy[i];
    //sell
    sum += nmb*sell[i];
    nmb = 0;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3620
S=raw_input()
len=len(S)
str=""

if len%2==0:
	str="g"*(len/2)+"p"*(len/2)
else:
	str="g"*(len/2+1)+"p"*(len-(len/2+1))

ans=0
for i in range(len):
	if S[i]=="g" and str[i]=="p":
		 ans+=1
	elif S[i]=="p" and str[i]=="g":
		 ans-=1
	else:
		pass
print ans

Measured memory_bytes: 6020
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 整数の入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int c = Integer.parseInt(in.next());

            if (a + b + c >= 22) {
                out.println("bust");
                return;
            }

            // 出力
            out.println("win");

        }

    }
}



Measured memory_bytes: 21844
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

//Sliceconvtoi ...
func Sliceconvtoi() []int {
	strs := strings.Split(sc.Text(), " ")

	var ints []int
	var x int

	for _, s := range strs {
		x, _ = strconv.Atoi(s)
		ints = append(ints, x)
	}

	return ints
}

func main() {

	for sc.Scan() {
		i := Sliceconvtoi()
		fmt.Println(i[0] + i[1])
	}

}



Measured memory_bytes: 1068
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }

int main() {
    string S; cin >> S;
    int N = S.size();
    vector<vector<int>> dp(N + 1, vector<int>(2, -1));
    dp[0][0] = 0;
    rep(i, 0, N) rep(j, 0, 2) {
        if(dp[i][j] == -1) continue;
        int x = j ? 9 : S[i] - '0';
        rep(d, 0, x + 1) chmax(dp[i + 1][j || d < x], dp[i][j] + d);
    }
    cout << max(dp[N][0], dp[N][1]) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#define MP make_pair
using ll = long long;
using namespace std;

int ksum(int x){
  int s=0;
  for(;;){
    s += (x % 10);
    x = x/10;
    if(x < 10){
      s += x;
      break;
    }
  }
  return s;
}

int main()
{
  int N,A,B;
  cin >> N >> A >> B;
  ll ans=0;
  for(int i=1; i <= N; i++){
    if(ksum(i) >= A && ksum(i) <= B)
      ans += i;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
private:
  ll *fac,*finv,*inv;
public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  int d;
  cin >> d;
  string ans;
  ans = "Christmas";
  for(int i=0;i<(25-d);i++){
    ans += " Eve";
  }
  
  cout << ans << endl;
  
  return 0;
}


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

using namespace std;

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

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	double n, k;
	cin >> n >> k;
	/*int index = 0, tmp;
	REP(i, 0, n){
		cin >> tmp;
		if(tmp == 1) index = i;
	}*/
	cout << ceil((n-1)/(k-1));
	//if(n == k) cout << 1;
	//else if(index >= n-k || index < k) cout << ceil(n/(k-1));
	/*else{
		tmp =  ceil(n/(k-1));
		int tmp1 = ceil((index-k/2)/(k-1));*/

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1e9+7
using namespace std;
typedef long long ll;

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

    if(A>=B){
        cout<<"10";
    }else{
        cout<<"0";
    }

}

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

using namespace std;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string S;
  cin >> S;
  S = "0" + S;
  vector<int> T(S.size(), 0);
  for (int i = 0; i < (int)S.size(); i++) {
    T[i] = S[i] - '0';
  }
  int N = (int)S.size();
  vector<vector<int>> dp(N + 1, vector<int>(2, 1 << 28));
  dp[0][0] = 0;
  for (int i = 0; i < N; i++) {
    chmin(dp[i + 1][0], dp[i][0] + T[i]);
    chmin(dp[i + 1][1], dp[i][0] + T[i] + 1);
    chmin(dp[i + 1][0], dp[i][1] + 10 - T[i]);
    chmin(dp[i + 1][1], dp[i][1] + 10 - T[i] - 1);
  }
  cout << dp[N][0] << '\n';
  return 0;
}


Measured memory_bytes: 59848
#include <stdio.h>
#include <stdlib.h>
int main(){
  long long int X,K,D,ans,a,b,c;
  scanf("%lld %lld %lld",&X,&K,&D);
  if(X<0) X=-X;
  a=X%D;
  b=D-a;
  c=(X-a)/D;
  if(c<K){
    if((K-c)%2==0) ans=a;
    else ans=b;
  }
  else ans=X-K*D;
  printf("%lld",ans);
  return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=10;
const int MOD=1000000007;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	string s;cin>>s;
	int a=(s[0]-'0')*10+s[1]-'0';
	int b=(s[2]-'0')*10+s[3]-'0';
	if(1<=a&&a<=12&&1<=b&&b<=12){
		cout<<"AMBIGUOUS\n";
	}
	else if(1<=a&&a<=12)cout<<"MMYY\n";
	else if(1<=b&&b<=12)cout<<"YYMM\n";
	else cout<<"NA\n";
}
/*
1 3
#.#


2 3
#.#
..#

3 3
##.
#.#
..#

3
2 5
6 1
3 7
Ans:6

4
3 7
2 9
8 16
10 8
Ans:9
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

typedef long long ll;
typedef pair<int, int> ii;
 
int main(){

	int n;
	cin >> n;
	
	vector<int> r(n);
	rep(i, n) cin >> r[i];
	
	vector<double> dp(n);
	
	rep(i, n){
		dp[i] = 1.0 * r[i];
		for(int j = i - 1; j >= 0; j--){
			int tmp1 = r[i] + r[j];
			int tmp2 = r[i] - r[j];
			dp[i] = max(dp[i], dp[j] + sqrt(tmp1 * tmp1 - tmp2 * tmp2));
		}
	}
	double ans = 0;
	
	rep(i, n) ans = max(ans, dp[i] + (double)r[i]);
	
	printf("%.8lf\n", ans);
	return 0;
}

Measured memory_bytes: 3224
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct Graph {
    struct Vertex { int n, a, k; };
    struct Edge { int i, n; };
    Graph(int n, int m) : v(n, { -1, 0, 0 }), e(m), n(n), m(0) {}
    void add_edge(int i, int j) {
        e[m] = { j, v[i].n };
        v[i].n = m;
        m++;
    }
    void dfs(int i, int p) {
        auto it = lower_bound(a.begin(), a.begin() + k, v[i].a);
        int a0 = *it;
        int k0 = k;

        *it = v[i].a;
        if (it == a.begin() + k) k++;
        v[i].k = k;

        for (int j = v[i].n; j >= 0; j = e[j].n) {
            Edge& o = e[j];
            if (o.i == p) continue;
            dfs(o.i, i);
        }

        *it = a0;
        k = k0;
    }
    void solve() {
        for (int i = 0; i < n; i++) {
            cin >> v[i].a;
        }

        for (int i = 0; i < n - 1; i++) {
            int u, v;
            cin >> u >> v;
            u--; v--;

            add_edge(u, v);
            add_edge(v, u);
        }

        a.resize(n);
        k = 0;

        dfs(0, -1);

        for (int i = 0; i < n; i++) {
            cout << v[i].k << '\n';
        }
    }
    vector<Vertex> v;
    vector<Edge> e;
    int n, m;

    vector<int> a;
    int k;
};

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

    int n;
    cin >> n;

    Graph g(n, (n - 1) * 2);
    g.solve();

    return 0;
}

Measured memory_bytes: 23572
#include <stdio.h>

int main(void){
    int N, A[200005], i, M1, M2, I;
    scanf("%d", &N);
    scanf("%d", &A[1]); scanf("%d", &A[2]);
    if (A[1]>A[2]) {
        M1=A[1]; M2=A[2];
        I=1;
    }
    else {
        M1=A[2]; M2=A[1];
        I=2;
    }
    for (i=3; i<=N; i++) {
        scanf("%d", &A[i]);
        if (A[i]>M1) {
            M2=M1;
            M1=A[i];
            I=i;
        }
        else if (A[i]>M2) {
            M2=A[i];
        }
    }
    if (M1==M2) {
        for (i=1; i<=N; i++) printf("%d\n", M1);
    }
    else {
        for (i=1; i<=N; i++) {
           if (i==I) printf("%d\n", M2);
           else printf("%d\n", M1);
        }
    }
    return 0;
}


Measured memory_bytes: 2304
fun main(arg: Array<String>) {
    val (N, K, L) = listOfInt()
    val U1 = UnionFind(N)
    repeat(K) {
        val (p, q) = listOfInt(-1)
        U1.unite(p, q)
    }
    val U2 = UnionFind(N)
    repeat(L) {
        val (r, s) = listOfInt(-1)
        U2.unite(r, s)
    }
    var C = mutableMapOf<Pair<Int, Int>, Int>()
    repeat(N) { n ->
        val key = U1.root(n) to U2.root(n)
        val c = C.getOrElse(key, { 0 })
        C.set(key, c + 1)
    }
    val ans = IntArray(N)
    repeat(N) { n ->
        val key = U1.root(n) to U2.root(n)
        val c = C.getOrElse(key, { 0 })
        ans[n] = c
    }
    println(ans.joinToString(" "))
}

class UnionFind(n: Int) {
    var rank: IntArray
    var par:  IntArray
    var size: IntArray
    init {
        this.rank = IntArray(n) { 0 }
        this.par  = IntArray(n) { it }
        this.size = IntArray(n) { 1 }
    }
    fun unite(x: Int, y: Int): Boolean {
        var rx = this.root(x)
        var ry = this.root(y)
        if (rx == ry) return false
        if (this.rank[rx] < this.rank[ry]) {
            val w = rx
            rx = ry
            ry = w
        } else if (this.rank[rx] == this.rank[ry]) {
            this.rank[rx] += 1
        }
        this.par[ry] = rx.toInt()
        this.size[rx] += this.size[ry]
        return true
    }
    fun find(x: Int): Int {
        if (this.par[x] == x) return x
        else {
            this.par[x] = this.find(this.par[x])
            return this.par[x]
        }
    }
    fun isSame(x: Int, y: Int): Boolean = this.root(x) == this.root(y)
    fun size(x: Int): Int = this.size[this.find(x)]
    fun root(x: Int): Int = this.find(x)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }


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

bool isPrime(int i) {
    float sqrti = sqrt(i);
    for (int j = 2; j < sqrti; j++) {
        if (i % j == 0) {
            return false;
        }
    }
    return true;
}


int main() {
    int X;
    cin >> X;
    int i = X;
    while(!isPrime(i)) {
        i++;
    }
    cout << i << endl;
    }




Measured memory_bytes: 256
import sys

A,B,K = (int(a) for a in input().split())
if A > K :
    A = A - K
    print(A,B)
    sys.exit()
else : 
    K = K - A
    A = 0
    if B > K :
        B = B - K
        print(A,B)
    else : 
        print(0,0)


Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

#define SENTINEL 1000000000000000000

void merge(long long A[], long long left, long long mid, long long right){
  long long n1, n2, i, j, k;
  long long *L,*R;
  
  n1 = mid-left;
  n2 = right-mid;
  
  L = (long long*)malloc(sizeof(long long) *(n1 + 1));
  R = (long long*)malloc(sizeof(long long) *(n2 + 1));
  
  for(i = 0; i <= n1 - 1; i++){
    L[i] = A[left + i];
  }
  for(j = 0; j <= n2 - 1; j++){
    R[j] = A[mid + j];
  }
  
  L[n1] = SENTINEL;
  R[n2] = SENTINEL;
  
  i = 0;
  j = 0;
  
  for(k = left; k <= right - 1; k++){
   if(L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else{
      A[k] = R[j];
      j++;
    }
  }
  free(L);
  free(R);
}

void mergeSort(long long A[], long long left, long long right){
  long long mid;
  
  if(left + 1 < right){
    mid=(left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int main(void){

    int N;
    long long H;

    scanf("%d%lld", &N, &H);

    long long a[N], b[N];

    for(int i = 0; i < N; i++){
        scanf("%lld%lld", &a[i], &b[i]);
    }

    mergeSort(a, 0, N);
    mergeSort(b, 0, N);

    long long d = 0;
    long long c = 0;

    for(int i = N - 1; i >= 0; i--){
        if(d >= H || b[i] < a[N-1]){
            break;
        }
        d += b[i];
        c++;
    }

    if(d < H){
        if((H - d) % a[N-1] == 0){
            c += ((H-d) / a[N-1]);
        }else{
            c += ((H-d) / a[N-1]) + 1;
        }
    }

    printf("%lld\n", c);

    return 0;
}

Measured memory_bytes: 3752
import java.util.*;

class Main {
    static Scanner sc;
    static int n, m;
    static ArrayList<Integer>[] adj;
    public static void main(String[] args) {
        sc = new Scanner(System.in);
        n = sc.nextInt();
        m = sc.nextInt();
        adj = new ArrayList[n];
        for (int i = 0; i < n; i++) {
            adj[i] = new ArrayList<Integer>();
        }

        TreeSet<Pair> set = new TreeSet<Pair>();
        for (int i = 0; i < m; i++) {
            int x, y;
            x = sc.nextInt();
            y = sc.nextInt();
            x--;
            y--;
            if (x > y) {
                int tmp = x;
                x = y;
                y = tmp;
            }
            set.add(new Pair(x, y));
        }

        for (Pair p: set) {
            adj[p.x].add(p.y);
            adj[p.y].add(p.x);
        }

        int ans = solve();
        System.out.println(ans);
    }

    public static int solve() {
        Stack<Integer> stack = new Stack<Integer>();
        Boolean[] used = new Boolean[n];
        for (int i = 0; i < n; i++) {
            used[i] = false;
        }
        int maxSize = 0;
        for (int i = 0; i < n; i++) {
            if (used[i]) {
                continue;
            }
            stack.add(i);
            int size = 0;
            while (stack.size() > 0) {
                int crt = stack.pop();
                if (used[crt]) {
                    continue;
                }
                used[crt] = true;
                size++;
                for (int nxt: adj[crt]) {
                    if (used[nxt]) {
                        continue;
                    }
                    stack.add(nxt);
                }
            }
            if (size > maxSize) {
                maxSize = size;
            }
        }
        return maxSize;
    }
}

class Pair implements Comparable<Pair> {
    int x, y;

    Pair(int _x, int _y) {
        x = _x;
        y = _y;
    }

    public int compareTo(Pair b) {
        if (x > b.x) {
            return 1;
        } else if (x < b.x) {
            return -1;
        }

        if (y > b.y) {
            return 1;
        } else if (y < b.y) {
            return -1;
        }

        return 0;
    }
}

Measured memory_bytes: 86760
grade = []
while True:
    m, f, r = map(int, input().split())
    if m == -1 and f == -1 and r == -1:
        break
    elif m == -1 or f == -1:
        grade.append("F")
    elif m + f >= 80:
        grade.append("A")
    elif 65 <= m + f < 80:
        grade.append("B")
    elif 50 <= m + f < 65:
        grade.append("C")
    elif 30 <= m + f < 50:
        if r >= 50:
            grade.append("C")
        else:
            grade.append("D")
    elif m + f < 30:
        grade.append("F")

for i in grade:
    print(i)



Measured memory_bytes: 5600
x=int(input())
flag=False
ansi=0
ansj=0
for i in range(1,65):
    for j in range(-65,1):
        if i**5-j**5==x:
            ansi=i
            ansj=j
            flag=True
            break
    if flag:
        break
if not flag:
    for i in range(1,122):
        for j in range(1,122):
            if i**5-j**5==x:
                ansi=i
                ansj=j
                flag=True
                break
        if flag:
            break
print(str(i)+" "+str(j))

Measured memory_bytes: 64880
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const ll mod = 1000000007;
ll modpow(ll a,ll n){
	ll ret = 1;
	while(n){
		if(n&1) ret = ret*a%mod;
		a = a*a%mod;
		n >>= 1;
	}
	return ret;
}

ll h,w,t;

int main(){
	cin >> h >> w >> t;
	ll pt = 1;
	pt = pt * __gcd(h,t); h /= __gcd(h,t);
	pt = pt * __gcd(w,t); w /= __gcd(w,t);
	
	ll ans = 0;
	ans += 1;
	ans += modpow(2LL,h)-1;
	ans += modpow(2LL,w)-1;
	ans += modpow(2LL,__gcd(h,w))-2;
	ans = (ans%mod+mod)%mod;
	ans = modpow(ans,pt);
	cout << ans << endl;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
town=[0]*n
info=[1]
now=1
while town[now-1]==0:
    town[now-1]+=1
    now=a[now-1]
    info.append(now)
loop_list=list(info[info.index(now):-1])
loop_len=len(loop_list)
before_loop_list=list(info[:info.index(now)])
if k<len(before_loop_list):
    print(before_loop_list[k])
else:
    print(loop_list[((k-len(before_loop_list))%loop_len)])

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

#define int long long
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

const unsigned int M = 1e9 + 7;

int32_t main() {
	fastio;

	int x, n;
	cin >> x >> n;
	set<int> s;
	for(int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		s.insert(a);
	}
	for(int i = 0; i <= x; ++i) {
		if(!s.count(x - i)) {
			cout << x - i;
			return 0;
		} else if(!s.count(x + i)) {
			cout << x + i;
			return 0;
		}
	}

	return 0;
}


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

int main()
{
	int n,t,i,j,k;
	int a[100001], b[100001], c[100001];
	cin>>n;

	for(i=0;i<n;i++)
	{
		scanf("%d %d %d", &a[i], &b[i], &c[i]);
	}

	long ans = 0;
	
	int d[100001][3];

	d[0][0] = a[0];
	d[0][1] = b[0];
	d[0][2] = c[0];

	for(i=1;i<n;i++)
	{
		d[i][0] = a[i] + max(d[i-1][1], d[i-1][2]);
		d[i][1] = b[i] + max(d[i-1][0], d[i-1][2]);
		d[i][2] = c[i] + max(d[i-1][0], d[i-1][1]);
	}

	cout<<max(d[n-1][0],  max(d[n-1][1], d[n-1][2]))<<endl;

	return 0;

}

Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

int a[16][16];
LL value[1 << 16], f[1 << 16];
int n;

inline void work() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> a[i][j];
        }
    }
    for (int i = 1; i < (1 << n); ++i) {
        if (__builtin_popcount(i) > 1) {
            for (int j = 0; j < n; ++j) {
                if (i & (1 << j)) {
                    value[i] = value[i - (1 << j)];
                    for (int k = j + 1; k < n; ++k) {
                        if (i & (1 << k)) {
                            value[i] += a[j][k];
                        }
                    }
                    break;
                }
            }
        }
    }
    for (int i = 1; i < (1 << n); ++i) {
        if (__builtin_popcount(i) > 1) {
            for (int j = i; j; j = (j - 1) & i) {
                f[i] = max(f[i], f[i ^ j] + value[j]);
            }
        }
    }
    LL ans = *max_element(f, f + (1 << n));
    cout << ans << "\n";
}

int main() {
    // freopen("input.txt", "r", stdin);
    quickread();
    work();
    return 0;
}

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

using namespace std;

int INF = 1e9 + 5;

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

    int n, k;
    cin >> n >> k;
    
    vector<int> h(n);
    for(auto&x : h)
    {
        cin >> x;
    }
    
    vector<int> dp(n,INF); // dp[i] = minimum weight of jumps that ends at i
    dp[0] = 0;
    
    for(int i=0; i<n; ++i)
    {
        for(int j=1; j<=k && i+j<n; ++j)
        {
            dp[i+j] = min(dp[i+j],dp[i] + abs(h[i+j]-h[i]));
        }
    }
    
    cout << dp[n-1];
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    ll s;cin >> s;
    const int v=1e9;
    ll x=(v-s%v)%v;
    ll y=(s+x)/1e9;
    cout << "0 0 1000000000 1 " << x << " " << y << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <string>
#include <string.h>
#include <bitset>
#include <map>
#include <climits>
#include <set>

using namespace std;

int main()
{
    using T = long;
    vector<T> v(3);
    cin >> v[0] >> v[1] >> v[2];
    sort(v.begin(), v.end());
    for (auto &i : v)
    {
        i -= v[2];
    }

    int cnt = 0;
    cnt += -v[0] / 2;
    v[0] = -(v[0] % 2);
    cnt += -v[1] / 2;
    v[1] = -(v[1] % 2);

    auto nonzero_count = -(v[0] + v[1]);
    switch (nonzero_count)
    {
    case -2:
        ++cnt;
        break;
    case -1:
        cnt += 2;
        break;
    case 0:
        break;
    }

    cout << cnt << endl;
    return 0;
}

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

using namespace std;

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

int main()
{
    int a, b, c;
    cin >> a >> b >> c;

    if (c == a + b || b == c + a || a == b + c) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
require 'pp'
$DEBUG ? define_method(:dpp){|e|pp e} : define_method(:dpp){|e|}

# 入力値を文字の配列で返却する
def gets_nsp_list()
  gets.chomp.split("")
end

s_list = gets_nsp_list
n = s_list.size

if s_list.uniq.size == 1
  puts 0
  exit
end

c = s_list.first
count = 0
1.upto(n-1) do |i|
  dpp [c, s_list[i]]
  if s_list[i] != c
    count += 1
    c = s_list[i]
  end
end

puts count

Measured memory_bytes: 9980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pint pair<int, int>
#define pll pair<ll, ll>
#define vint vector<int >
#define vll vector<ll >
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n,x,t;
    cin >> n >> x >> t;
    if(n%x == 0){
    cout << (n/x)*t << "\n";            
    }else{

        cout << (n/x)*t+t << "\n";
    }
    return 0;
}

Measured memory_bytes: 3688
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int N, Q;
  string S;
  cin >> N >> Q >> S;
  vector<int> l(Q), r(Q);
  for (int i = 0; i < Q; ++i) {
    cin >> l[i] >> r[i];
  }
  vector<int> C(N);
  C[N - 1] = 0;
  for (int i = N - 1; 0 < i; --i) {
    C[i - 1] = C[i] + (0 == S.compare(i - 1, 2, "AC"));
  }
  for (int i = 0; i < Q; ++i) {
    cout << C[l[i] - 1] - C[r[i] - 1] << endl;
  }
  return 0;
}


Measured memory_bytes: 2304
package main

import (
	"fmt"
)

func main() {
	var h, w, n, sr, sc int
	var s, t string
	fmt.Scan(&h)
	fmt.Scan(&w)
	fmt.Scan(&n)
	fmt.Scan(&sr)
	fmt.Scan(&sc)
	fmt.Scan(&s)
	fmt.Scan(&t)

	dptl := make([]int, n+1)
	dptl[0] = sc
	dptr := make([]int, n+1)
	dptr[0] = sc
	dptu := make([]int, n+1)
	dptu[0] = sr
	dptd := make([]int, n+1)
	dptd[0] = sr
	dpal := make([]int, n+1)
	dpal[0] = sc
	dpar := make([]int, n+1)
	dpar[0] = sc
	dpau := make([]int, n+1)
	dpau[0] = sr
	dpad := make([]int, n+1)
	dpad[0] = sr

	for i := 1; i <= n; i++ {
		dptl[i] = dpar[i-1]
		dptr[i] = dpal[i-1]
		dptu[i] = dpad[i-1]
		dptd[i] = dpau[i-1]
		switch s[i-1] {
		case 'L':
			dptl[i]--
			if dptl[i] < 1 {
				fmt.Println("NO")
				return
			}
		case 'R':
			dptr[i]++
			if dptr[i] > w {
				fmt.Println("NO")
				return
			}
		case 'U':
			dptu[i]--
			if dptu[i] < 1 {
				fmt.Println("NO")
				return
			}
		case 'D':
			dptd[i]++
			if dptd[i] > h {
				fmt.Println("NO")
				return
			}
		}

		dpal[i] = dptr[i]
		dpar[i] = dptl[i]
		dpau[i] = dptd[i]
		dpad[i] = dptu[i]
		switch t[i-1] {
		case 'L':
			if dpal[i] > 1 {
				dpal[i]--
			}
		case 'R':
			if dpar[i] < w {
				dpar[i]++
			}
		case 'U':
			if dpau[i] > 1 {
				dpau[i]--
			}
		case 'D':
			if dpad[i] < h {
				dpad[i]++
			}
		}
	}

	fmt.Println("YES")
}


Measured memory_bytes: 16128