akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

struct STX {
    int s, t, x;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    int n, q;
    cin >> n >> q;
    vector<STX> stx(n);
    rep(i, n) cin >> stx[i].s >> stx[i].t >> stx[i].x;
    set<pair<int, int>> d;
    rep(i, q) {
        int td;
        cin >> td;
        d.insert(make_pair(td, i));
    }
    vector<int> ans(q, -1);
    sort(all(stx), [](const STX &a, const STX &b) { return a.x < b.x; });
    rep(i, n) {
        int l = stx[i].s - stx[i].x;
        int r = stx[i].t - stx[i].x;
        for (auto it = d.lower_bound(make_pair(l, -1)); it != d.end(); ) {
            if (it->first >= r) break;
            ans[it->second] = stx[i].x;
            d.erase(it++);
        }
    }
    rep(i, q) printf("%d\n", ans[i]);
    return 0;
}


Measured memory_bytes: 14464
#include<iostream>

int main(){
    int i,j,r,c;

    std::cin>>r>>c;

    int a[r+1][c+1];

    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            std::cin>>a[i][j];
        }
    }

    for(i=0;i<r;i++){
        a[i][c]=0;
    }
    for(j=0;j<c;j++){
        a[r][j]=0;
    }
    a[r][c]=0;

    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            a[i][c]+=a[i][j];
        }
    }

    for(i=0;i<r;i++){
        for(j=0;j<c;j++){
            a[r][j]+=a[i][j];
        }
    }

    for(i=0;i<r;i++){
        a[r][c]+=a[i][c];
    }

    for(i=0;i<r+1;i++){
        for(j=0;j<c;j++){
            std::cout<<a[i][j]<<" "<<std::flush;
        }
        std::cout<<a[i][c]<<std::endl;
    }
    return 0;
}


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

const int N = 2e3 + 3;

int n, k, q;
int a[N];
bool used[N];
int section[N], tot;

int cal(int val) {
    memset(used, 0, sizeof used);
    for (int i = 1; i <= n; i++)
        if (a[i] < val)
            used[i] = true;
    memset(section, 0, sizeof section);
    tot = 0;
    multiset<pair<int, int>> s;
    for (int i = 1; i <= n; i++) {
        if (used[i]) continue;
        int ptr = i;
        while (ptr <= n && used[ptr] == false) ptr++;
        for (int j = i; j < ptr; j++) {
            s.insert({a[j], tot});
        }
        section[tot++] = ptr - i;
        i = ptr - 1;
    }
    int cnt = 0;
    int mx = 0;
    for (auto x : s) {
        if (section[x.second] >= k) {
            section[x.second] -= 1;
            cnt += 1;
            mx = max(mx, x.first);
        }
        if (cnt == q) break;
    }
    if (cnt < q) return 1e9 + 1;
    return mx;
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n >> k >> q;
    set<int> s;

    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        s.insert(a[i]);
    }
    int ans = 1e9 + 1;
    for (int minimum : s) {
        if (cal(minimum) > 1e9) continue;
        ans = min(ans, cal(minimum) - minimum);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int p[1111],d[1111],t[1111];
map<int,int> w;
vector<int> pos;
int dp[2222];

int main(void)
{
  int l,n;
  scanf("%d%d",&l,&n);
  for( int i = 0; i < n; i++ ) {
    scanf("%d%d%d",p+i,d+i,t+i);
    w[p[i]] = i+1;
    pos.push_back(p[i]);
    pos.push_back(d[i]+p[i]);
  }
  pos.push_back(0);
  pos.push_back(l);
  sort(pos.begin(),pos.end());
  pos.erase(unique(pos.begin(),pos.end()),pos.end());
  for( int i = 0; i < int(pos.size()); i++ ) dp[i] = 1000010000;
  //for( int i = 0; i < int(pos.size()); i++ ) printf("%d\n",pos[i]);
  dp[0] = 0;
  for( int i = 0; i < int(pos.size()); i++ ) {
    if( dp[i+1] > dp[i]+pos[i+1]-pos[i] ) {
      dp[i+1] = dp[i]+pos[i+1]-pos[i];
    }
    if( w[pos[i]] ) {
      int x = w[pos[i]]-1;
      int y = lower_bound(pos.begin(),pos.end(),d[x]+p[x])-pos.begin();
      //printf("%d %d\n",d[x]+p[x],y);
      if( dp[y] > dp[i]+t[x] ) {
        dp[y] = dp[i]+t[x];
      }
    }
  }
  printf("%d\n",dp[pos.size()-1]);
  return 0;
}


Measured memory_bytes: 1176
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);

int n;

long long extGCD(long long a, long long b, long long &x, long long &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a%b, y, x);
    y -= a/b * x;
    return d;
}

signed main(){

    int a,b;
    cin >> a >> b;
    int x,y;
    extGCD(a, b, x, y);
    cout << x << " " << y << endl;


    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}




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

#define ll long long 
#define sz(x) (int)x.size()

using namespace std;

int main(){
	int n,x=0,ans=0;
	string s;
	cin>>n>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='I')x++;
		else x--;
		ans=max(ans,x);
	}
	cout<<ans;
	
	
}





Measured memory_bytes: 3596
import math
a,b,h,m=map(int,input().split())

if 30*h+m/2-6*m>=0:
  x=30*h+m/2-6*m
else:
  x=6*m-30*h-m/2
  
print((a**2+b**2-2*a*b*math.cos(math.radians(x)))**(1/2))

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

//#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

const int INF = 1 << 29;

signed main() {
	string s; cin >> s;
	int ans = 0;
	rep(i, s.size()) {
		if (i % 2 == 0) {
			ans += s[i] == 'g' ? 0 : -1;
		} else {
			ans += s[i] == 'g' ? 1 : 0;
		}
	}
	cout << ans << endl;
	system("pause");
}

Measured memory_bytes: 760
import sys
input=sys.stdin.readline  #危険！基本オフにしろ！

n,m,p=map(int,input().split())

d={}
for s in range(m):
    a,b,c=map(int,input().split())
    if a in d:
        d[a].append((b,c))
    else:
        d[a]=[(b,c)]

#print(d)


def BELLMANFORD(point,d,p):
    cost       = [-float("inf")]*(n+1)  #infじゃないと閉路検出がうまくいかない
    cost[point]= 0
    for i in range(n-1):                                  #経路の長さは最大n-1であるため
        for now,lis in d.items():
            for nex,c in lis:
                if cost[nex]<cost[now]+c-p:
                    cost[nex]=cost[now]+c-p

    negative=[0]*n                                        #負閉路の長さは最大nであるため
    
    for i in range(n):                  #閉路判定 negativeの1は閉路に入っている部分を表す
        for now,lis in d.items():
            for nex,c in lis:
                if negative[now-1]==1:
                    negative[nex-1]=1
                if cost[nex]<cost[now]+c-p:
                    cost[nex]=cost[now]+c-p
                    negative[now-1]=1
 
    return cost,negative

def main():
    x,y=(BELLMANFORD(1,d,p))
    
    if y[n-1]==1:
        print(-1)
    else:
        print(max(x[n],0))

    
if __name__ == '__main__':
    main()


Measured memory_bytes: 50268
#include<bits/stdc++.h>
using namespace std;
namespace comp {
    struct istream {
        template <typename T> inline const istream& operator>>(T &_a) const {
            T x = 0, f = 1;
            char c = getchar();
            while (c < '0' || c > '9' ) {
                if (c == '-') f = -1;
                c = getchar();
            }
            while (c >= '0' && c <= '9') {
                x = x*10+c-'0';
                c = getchar();
            }
            _a = x*f;
            return *this;
        }
        inline const istream& operator>>(string &_a) const {
            string s = "";
            char c = getchar();
            while (c < '!' || c > '~') {
                c = getchar();
            }
            while ( c >= '!' && c <= '~') {
                s += c;
                c = getchar();
            }
            _a = s;
            return *this;
        }
        inline const istream& operator>>(vector<int> &_a) const {
            for (auto &__a : _a) {
                operator>>(__a);
            }
            return *this;
        }
    };
};
int main() {
    comp::istream cin;
    int N, Q;
    cin >> N >> Q;
    vector<queue<int> > edges(N+1);
    for (int i = 0; i < N-1; i++) {
        int a, b;
        cin >> a >> b;
        edges[a].push(b);
        edges[b].push(a);
    }
    vector<int> counter(N+1, 0);
    for (int i = 0; i < Q; i++) {
        int p, x;
        cin >> p >> x;
        counter[p] += x;
    }
    queue<int> current;
    current.push(1);
    vector<int> distances(N+1, -1);
    distances[1] = counter[1];
    while (!current.empty()) {
        int a = current.front();
        while(!edges[a].empty()) {
            int b = edges[a].front();
            if (distances[b] == -1) {
                distances[b] = distances[a]+counter[b];
                current.push(b);
            }
            edges[a].pop();
        }
        current.pop();
    }
    for (int i = 1; i < N+1; i++) {
        printf("%d\n", distances[i]);
    }
    return 0;
}

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

using namespace std;

#define watch(x) cout << (#x) << " is " << (x) << endl
#define watchArray(v) for(auto i : v) cout << i << " "; cout << endl;
#define all(v) (v).begin(), (v).end()

#define endl '\n'
#define MAX 100000
#define MOD 100000007
#define INF numeric_limits<int>::max()
#define INFLL numeric_limits<long long int>::max()

typedef long long int lli;
typedef long double ld;

vector<vector<int>> adj;
vector<bool> vis;
vector<int> grau, dist;
int n, m, x, y;

void dfs(int u){
  if(vis[u]) return;
  vis[u] = true;
  for(auto v : adj[u]) {
    if(!vis[v]) {
      dist[v] = max(dist[v], dist[u] + 1);
      grau[v]--;
      if(grau[v] == 0) dfs(v);
    }
  }
}

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

  cin >> n >> m;
  adj.resize(n+1);
  grau.resize(n+1);
  vis.assign(n+1, 0);
  dist.assign(n+1, 0);
  while(m--) {
    cin >> x >> y;
    adj[x].push_back(y);
    grau[y]++;
  }

  int ans = 0;
  for(int i = 1; i < grau.size(); i++) {
    if(grau[i] == 0) dfs(i);
  }
  for(auto i : dist) ans = max(ans, i);

  cout << ans << endl;
  return 0;
}


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

int main(){
    ll n;
    cin >> n;
    vector <ll> a(n);

    ll kk;
    rep(i,n){
        cin >> kk;
        if(i==0){
            a[i]=kk;
        }
        else{
            a[i]=kk+a[i-1];
        }
    }

    sort(a.begin(),a.end());
    ll ans=0;
    ll k=0;
    rep(i,n){
        if(a[i]==0){
            ++ans;
        }

        if(i==0){
            k=1;
        }
        else if(a[i]==a[i-1]){
            ++k;
        }
        else{
            if(k>=2){
                ans+=k*(k-1)/2;
            }
            k=1;
        }
    }

    if(k>=2){
        ans+=k*(k-1)/2;
    }

    /*rep(i,n){
        cout << a[i] << endl;
    }*/

    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 4840
import numpy as np
i4 = np.int32
i8 = np.int64


def solve(a, b, H, W):
    ret = np.empty(H, i8)
    for i in range(H):
        ret[i] = -1
    dp0 = np.arange(W)
    dp = np.arange(W)
    arg0 = W - 1
    arg = 0
    for i in range(H):
        r1 = np.searchsorted(dp, a[i])
        r2 = np.searchsorted(dp, b[i])
        if b[i] == W:
            if r1 == 0:
                return ret
            else:
                dp0 = dp0[: r1]
                dp = dp[: r1]
        else:
            dp[r1:r2] = b[i]

        if arg0 > -1:
            if r1 <= arg0 < r2:
                for j in range(r1 - 1, -1, -1):
                    if dp[j] == dp0[j]:
                        arg0 = j
                        ret[i] = i + 1
                        break
                else:
                    arg0 = -1
                    arg = np.argmin(dp - dp0)
                    ret[i] = dp[arg] - dp0[arg] + i + 1
            else:
                ret[i] = i + 1
        else:
            if r1 <= arg < r2:
                arg = np.argmin(dp - dp0)
            ret[i] = dp[arg] - dp0[arg] + i + 1

        if i % 1000 == 999:
            m = 0
            prev = dp[0]
            for k in range(1, dp.shape[0]):
                if dp[k] > prev:
                    dp0[m] = dp0[k - 1]
                    dp[m] = prev
                    m += 1
                    prev = dp[k]
            else:
                dp0[m] = dp0[dp0.shape[0] - 1]
                dp[m] = prev
                m += 1
            dp0 = dp0[: m]
            dp = dp[: m]
            if arg0 > -1:
                for j in range(m - 1, -1, -1):
                    if dp[j] == dp0[j]:
                        arg0 = j
                        break
            else:
                arg = np.argmin(dp - dp0)
    return ret


def main(in_file):
    stdin = open(in_file)
    H, W = [int(x) for x in stdin.readline().split()]
    ab = np.fromstring(stdin.read(), i8, sep=' ').reshape((-1, 2)).T.copy()
    ans = solve(ab[0] - 1, ab[1], H, W)
    p = '\n'.join([str(x) for x in ans.tolist()])
    print(p)


def cc_export():
    from numba.pycc import CC
    from numba.types import Array, int64
    cc = CC('my_module')
    cc.export('solve', (Array(int64, 1, 'C'), Array(int64, 1, 'C'), int64, int64))(solve)
    cc.compile()


if __name__ == '__main__':
    import sys
    if sys.argv[-1] == 'ONLINE_JUDGE':
        cc_export()
        exit(0)
    from my_module import solve
    main('/dev/stdin')


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

void call(int n){
  int i = 1;
 CHECK_NUM:
  int x = i;
  if ( x % 3 == 0 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
 INCLUDE3:
  if ( x % 10 == 3 ){
    cout << " " << i;
    goto END_CHECK_NUM;
  }
  x /= 10;
  if ( x ) goto INCLUDE3;
 END_CHECK_NUM:
  if ( ++i <= n ) goto CHECK_NUM;

  cout << endl;
}

int main(){
  int n;
  cin >> n;
  call(n);
  return 0;
}


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


Measured memory_bytes: 2124
#include <bits/stdc++.h> 
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define sp(x) fixed<<setprecision(x)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
ll mod = 1e9+7;
ll dp[22][(1<<22)];

ll fun( vector< vector<ll>> &comp, ll N, ll i, ll woman_bit)
{
    //Base case
    if(i == N+1)
    {
        if(woman_bit == 0)
        return 1;
        return 0;
    }
    
    //Lookup
    if(dp[i][woman_bit] != -1)
    return dp[i][woman_bit];
    
    //Rec case
    ll ans = 0;
    for(ll w=0;w<N;w++)
    {
        bool is_avail = ( ((1<<w) & woman_bit) == 0) ? 0 : 1;
        
        if(is_avail && comp[i][w+1])
        {
            ans += fun( comp,N,i+1, (woman_bit ^ (1<<w)));
            ans %= mod;
        }
    }
    return dp[i][woman_bit] = ans;
}

int main()
{
    fast_io;
    
    ll N;
    cin>>N;
    
    vector< vector<ll>> comp(N+1, vector<ll>(N+1));
   //int comp[22][22];
    for(ll i=1;i<=N;i++)
    {
        for(ll j=1;j<=N;j++)
        cin>>comp[i][j];
    }
    
    memset(dp,-1,sizeof(dp));
    cout<<fun(comp,N,1,(1<<N)-1)<<endl;
    
    return 0;
}






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

namespace Atc_0040
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            int A = int.Parse(S.Split(' ')[0]);
            int B = int.Parse(S.Split(' ')[1]);

            int aa = 0;
            int bb = 0;

            for (int i = 1; i <= 16; i++)
            {
                if (i % 2 == 1)
                {
                    aa++;
                }
                else
                {
                    bb++;
                }

                if (A <= aa && B <= bb)
                {
                    Console.WriteLine("Yay!");
                    return;
                }
            }

            Console.WriteLine(":(");
        }
    }
}


Measured memory_bytes: 27484
fn main() {
    proconio::input! {
    a:usize,
    b:[usize;a],
    c:[usize;a],
    }
    let mut s=0;
    for i in 0..a {
        let mut d=0;
        for j in 0..=i {
            d+=b[j];
        }
        let mut e=0;
        for j in i..a {
            e+=c[j];
        }
        if s<d+e {s=d+e}
    }
    println!("{}",s)
}

Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOR(i,n,m) for (int i=n; i<(int)(m); ++i)
#define ALL(x) x.begin(), x.end()
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define in(i, n) (0 <= (i) && (i) < (n))
#define on(bit, i) (((bit >> i) & 1) == 1)

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
const int INF = 1e9+7;

const int mod = 1e9+7;
struct Mod {
  int num;
  Mod () : num(0) {;}
  Mod (int n) : num(n) {;}
  operator int() { return num; }
};
Mod operator+(Mod a, Mod b) { return Mod((a.num + b.num) % mod); }
Mod operator-(Mod a, Mod b) { return Mod((mod + a.num - b.num) % mod); }
Mod operator*(Mod a, Mod b) { return Mod(((long long)a.num * b.num) % mod); }
Mod operator^(Mod a, int n) {
  if (n == 0) return Mod(1);
  Mod res = (a * a) ^ (n / 2);
  if (n % 2) res = res * a;
  return res;
}
Mod inv(Mod a) { return a ^ (mod - 2); }
Mod operator/(Mod a, Mod b) { return a * inv(b); }
Mod operator+=(Mod &a, Mod b) { return a = a + b; }
Mod operator-=(Mod &a, Mod b) { return a = a - b; }
Mod operator*=(Mod &a, Mod b) { return a = a * b; }
Mod operator/=(Mod &a, Mod b) { return a = a / b; }

int N;
int a[100000], b[100000];

int main(void) {
  cin >> N;
  REP(i, N) cin >> a[i];
  REP(i, N) cin >> b[i];

  vector<int> aka(N), bka(N);
  REP(i, N) if (i == 0 or a[i - 1] < a[i]) aka[i] = true;
  for (int i = N - 1; i >= 0; i--) if (i == N - 1 or b[i] > b[i + 1]) bka[i] = true;

  
  Mod res = 1;
  REP(i, N) {
    //    cout << i << endl;
    if (aka[i] and bka[i]) {
      if (a[i] != b[i]) { cout << 0 << endl; return 0; }
    } else if (aka[i]) {
      if (a[i] > b[i]) { cout << 0 << endl; return 0; }
    } else if (bka[i]) {
      if (b[i] > a[i]) { cout << 0 << endl; return 0; }
    } else {
      res *= min(a[i], b[i]);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1920
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int N=0,A=0;
  cin >> N >> A;
  cout << N*N - A << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
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; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    string a, b, c;
    cin >> a >> b >> c;

    char next = a[0];
    int cnt_a = 1, cnt_b = 0, cnt_c = 0;

    while (true) {
        if (next == 'a') {
            if (cnt_a == a.length()) {
                cout << "A" << endl;
                break;
            } else {
                next = a[cnt_a];
                cnt_a++;
            }
        }
        if (next == 'b') {
            if (cnt_b == b.length()) {
                cout << "B" << endl;
                break;
            } else {
                next = b[cnt_b];
                cnt_b++;
            }
        }
        if (next == 'c') {
            if (cnt_c == c.length()) {
                cout << "C" << endl;
                break;
            } else {
                next = c[cnt_c];
                cnt_c++;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 3532
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll,P> T; 
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
ll L[2010];
int main(){
    cin>>N;
    for(ll i=0;i<N;i++){
        cin>>L[i];
    }
    sort(L,L+N);
    ll ans=0;
    for(ll i=0;i<N;i++){
        for(ll j=i+1;j<N;j++){
            auto it=lower_bound(L+j+1,L+N,L[i]+L[j]);
            ans+=it-(L+j)-1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;
// const int MOD = 998244353;

int a[55], b[55], c[55], d[55];
int n, m, q;
int ans = 0;
void dfs(vector<int> A) {
   if (A.size() == n + 1) {
      int now = 0;
      rep(i, 0, q) {
         if (A[b[i]] - A[a[i]] == c[i]) now += d[i];
      }
      ans = max(ans, now);
      return;
   }
   A.push_back(A.back());
   while (A.back() <= m) {
      dfs(A);
      A.back()++;
   }
}
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   cin >> n >> m >> q;
   rep(i, 0, q) cin >> a[i] >> b[i] >> c[i] >> d[i];

   dfs(vector<int>(1, 1));
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 3592
import heapq

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

ans = 0
b = list(map(lambda x: x * (-1), a))
heapq.heapify(b)
for _ in range(N):
    heapq.heappop(b)
    ans -= heapq.heappop(b)
print(ans)

Measured memory_bytes: 43228
fun main(args :Array<String>) {
    val (n, k) = readIntegerList()
    val vList = readIntegerList()
    var ans = 0
    for (left in 0..Math.min(n, k)) {
        for (right in 0..Math.min(k - left, n - left)) {
            val sum = (vList.subList(0, left) + vList.subList(n - right, n))
                .sorted()
                .filterIndexed { index, v ->
                    if (index >= k - left - right) {
                        true
                    } else if (v < 0) {
                        false
                    } else {
                        true
                    }
                }.sum()
            ans = Math.max(ans, sum)
        }
    }

    println(ans)
}

fun readInteger() = readLine()!!.toInt()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 39904
#include <iostream>

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    if (s[a] != '-') {
        cout << "No\n";
        return 0;
    }
    for (int i = 0; i < s.size(); ++i) {
        if (i != a and !isdigit(s[i])) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>

int main()
{
	int A, B, X;
	scanf("%d %d", &A ,&B);
	if (A == B) {
		X = A + B;
	}
	else {
		X = 2 * std::max(A, B);
		X = X - 1;
	}
	printf("%d", X);
}



Measured memory_bytes: 128
#include "bits/stdc++.h"
#include<assert.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define MRE assert(0);
const int inf = 1e17;
const int mod = 1000000007;
typedef pair<int, int> P;
typedef pair<int, P> PP;
int n;
int A[105], B[106];
vector<int>G[106];
int d0[106],d1[106], d2[106],d3[105];
int r[105];

void dfs1(int now, int par, int d[]) {
	for (int e : G[now]) {
		if (e == par)continue;
		d[e] = d[now] + 1;
		dfs1(e, now, d);
	}
}

int dfs2(int now) {
	int res = d3[now];
	for (int e : G[now]) {
		if (d3[e] == -1) {
			d3[e] = d3[now] + 1;
			res = max(res, dfs2(e));
		}
	}
	return res;
}

int maxpos(int d[]) {
	int now = -1, pos;
	rep(i, n) {
		if (now < d[i]) {
			now = d[i];
			pos = i;
		}
	}
	return pos;
}

int calc(int dia) {
	int d = dia / 2;
	int epos;
	rep(i, n - 1) {
		if (d1[A[i]] > d1[B[i]])swap(A[i], B[i]);
		if (d1[A[i]] == d&&d1[B[i]] == d + 1 && d1[A[i]] + d2[B[i]] + 1 == dia) {
			epos = i; break;
		}
	}
	fill(d3, d3 + n, -1);
	d3[A[epos]] = d3[B[epos]] = 0;
	dfs2(A[epos]); dfs2(B[epos]);

	fill(r, r + n, 0);
	rep(i, n) {
		r[d3[i]] = max(r[d3[i]], (int)G[i].size() - 1);
	}

	int res = 2;
	rep(i, d)res *= r[i];
	return res;
}

void reset() {
	rep(i, n) {
		d0[i] = 0; d1[i] = 0; d2[i] = 0;
	}
}

signed main() {
	cin >> n;
	rep(i, n - 1) {
		cin >> A[i] >> B[i];
		A[i]--; B[i]--;
		G[A[i]].push_back(B[i]);
		G[B[i]].push_back(A[i]);
	}

	dfs1(0, -1, d0);
	int X = maxpos(d0);
	dfs1(X, -1, d1);
	int Y = maxpos(d1);
	dfs1(Y, -1, d2);
	int dia = d1[Y];

	if (dia & 1) {
		cout << (dia + 1) / 2 << ' ' << calc(dia) << endl;
	}
	else {
		int ans = 1;
		
		//中心1個

		int center;
		rep(i, n) {
			if (d1[i] == d2[i] && d1[i] + d2[i] == dia) {
				center = i; break;
			}
		}

		fill(d3, d3 + n, -1);
		d3[center] = 0;
		dfs2(center);

		rep(i, n) {
			r[d3[i]] = max(r[d3[i]], (int)G[i].size() - 1);
		}
		r[0] = G[center].size();
		rep(i, dia / 2)ans *= r[i];

		//中心2個

		for(int e:G[center]) {
			fill(d3, d3 + n, -1);
			d3[center] = 0;
			d3[e] = 0;
			int t1=dfs2(center),t2= dfs2(e);
//			if (t1 + t2 + 1 != dia)continue;
			int res = 2;
			fill(r, r + n, 0);
			rep(i, n) {
				r[d3[i]] = max(r[d3[i]], (int)G[i].size() - 1);
			}
			rep(i, dia / 2)res *= r[i];
			ans = min(ans, res);
		}

		cout <<dia/2+1<<' '<< ans << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 998244353;
const ll INF = 1e16;
const ll MAX_N = 400010;

// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}

ll inverse(ll a) {
    return modpow(a, mod-2);
}

ll inv[MAX_N];  // inv[i] : iの逆数のmod
ll fact[MAX_N];  // fact[i] : iの階乗のmod
ll invfact[MAX_N];

void init() {
    inv[0] = fact[0] = invfact[0] = 1;
    inv[1] = 1;
    for(ll i = 1; i < MAX_N; i++) {
        if(i >= 2) {
            inv[i] = mod - inv[mod%i]*(mod/i)%mod;
        }
        fact[i] = (i*fact[i-1])%mod;
        invfact[i] = inverse(fact[i]);
    }
}
 
ll Comb(ll n, ll r) {
    if(r < 0 || n < 0 || n < r) {
        return 0;
    }
    ll res = fact[n];
    res = (res * invfact[r])%mod;
    res = (res * invfact[n-r])%mod;
    return res;
}

//--- main関数でinit()を呼び出すのを忘れるな ---//
int main() {
    ll n, m, k;
    cin >> n >> m >> k;

    init();

    ll ans = 0;
    exrep(i, 0, k) {
        ans += (Comb(n-1, i)*modpow(m-1, n-1-i))%mod;
        ans %= mod;
    }

    ans *= m;
    ans %= mod;
    
    out(ans);
    re0;
}

Measured memory_bytes: 13012
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <math.h>
#include <tuple>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    int n, t, a[3030], b[3030];
    cin >> n >> t;
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];

    int dp1[n + 5][t + 3030] = {}, dp2[n + 5][t + 3030] = {};
    for (int i = 0; i < n; i++) {
        for (int w = 0; w <= t + 3000; w++) {
            if (w >= a[i]) {
                dp1[i + 1][w] = max(dp1[i][w - a[i]] + b[i], dp1[i][w]);
            }
            else {
                dp1[i + 1][w] = dp1[i][w];
            }
        }
    }
    reverse(a, a + n);
    reverse(b, b + n);
    for (int i = 0; i < n; i++) {
        for (int w = 0; w <= t + 3000; w++) {
            if (w >= a[i]) {
                dp2[i + 1][w] = max(dp2[i][w - a[i]] + b[i], dp2[i][w]);
            }
            else {
                dp2[i + 1][w] = dp2[i][w];
            }
        }
    }

    //for (int i = 0; i <= n + 20; i++) cout << i << " " << dp[n][i] << " " << mx[n][i] << endl;

    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < t; j++) {
            ans = max(ans, dp1[i][j] + dp2[n - i - 1][t - 1 - j] + b[n - 1 - i]);
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 141824
#include<bits/stdc++.h>
using namespace std;
#define int long long
int dp[111][111];
signed main(){
  int n;
  cin>>n;
  int r[n],c[n];
  for(int i=0;i<n;i++) cin>>r[i]>>c[i];
  int INF=1LL<<55LL;
  for(int i=0;i<111;i++) fill_n(dp[i],111,INF);
  for(int i=0;i<n;i++) dp[i][i+1]=0;
  for(int i=2;i<=n;i++)
    for(int j=0;j<=n-i;j++)
      for(int k=1;k<i;k++)
	dp[j][j+i]=min(dp[j][j+i],dp[j][j+k]+dp[j+k][j+i]+(r[j]*r[j+k]*c[j+i-1]));
  cout<<dp[0][n]<<endl;
  return 0;
}

Measured memory_bytes: 3192
/******************
*  Author: BD747  *
******************/
#include<algorithm>
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;

int n,k;
int a[1005];
ll f[1000005];
vector<ll> u,v;
ll ans,sum;

int main(){

	cin>>n>>k;
	for(register int i=1;i<=n;i++){
		cin>>a[i];
		f[i]=f[i-1]+a[i];
	}
	for(register int i=1;i<=n;i++){
		for(register int j=i;j<=n;j++){
			v.push_back(f[j]-f[i-1]);
		}
	}
	for(register int i=40;i>=0;i--){
		u.clear();
		ll cnt=0,cur=(1ll)<<i;
		for(register int j=0;j<v.size();j++){
			if(v[j]&cur){
				cnt++;
				u.push_back(v[j]);
			}
		}
		if(cnt>=k){
			v=u;
			ans+=cur;
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 6124
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    string s;
    cin>>s;
    int ans=0;
    rep(i,0,6) ans+=(int)s[i]-'0';
    cout<<ans<<endl;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



int main(){
  ll n;
  cin >> n;

  cout << 180*(n-2) << endl;
  

  return 0;
}

Measured memory_bytes: 256
s = input()

if len(s) %2 == 1:
  print("No")
  exit()
elif len(s)%2 ==0:
  num=0
  for i in range(0,len(s),2):
    if s[i] == "h":
      num +=1
    if s[i+1] =="i":
      num +=1
      
  if num ==len(s):
    print("Yes")
    exit()
    
print("No")

Measured memory_bytes: 3060
#!/usr/bin/env python3
# https://atcoder.jp/contests/abc129/tasks/abc129_b

n = int(input())
w = [int(x) for x in input().split()]
r = []
for i in range(len(w)):
    r.append(abs(sum(w[:i]) - sum(w[i:])))
print(min(r))


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

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}

bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

int n, m;

int main(){
    cin >> n >> m;
    int ans = 1;
    for(int i = 0; i < m; i++) {
        ans *= 2;
    }
    cout << (m*1900 + (n-m)*100)* ans * 1LL<< endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ans=1,n,k;
int main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		if(ans<k)
			ans+=ans;
		else
			ans+=k;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
/* ex5_3
  terakura */

  #include <stdio.h>
  #define MAX 100

  int main(void){
      int  height, width, i, j, row_white[MAX] = {0}, col_white[MAX] = {0};
      char input[MAX][MAX];
      scanf("%d %d", &height, &width);

      for(i = 0; i < height; i++){
          for(j = 0; j < width; j ++){
              scanf(" %c", &input[i][j]);       //マスに白と黒を入力
          }
      }

      //白いマスのみからなるrowを探す
      for(i = 0; i < height; i++){
          for(j = 0; j < width; j ++){
             if (input[i][j] == '#')break;

             if (j == width - 1){       //もし白いマスのみからなるrowが見つかったらrow_white[i] = 1として印をつける
                 row_white[i] = 1;
             }

          }
      }

      //白いマスのみからなるcolを探す
      for(j = 0; j < width; j++){
          for(i = 0; i < height; i ++){
             if (input[i][j] == '#')break;

             if (i == height - 1){      //もし白いマスのみからなるcolが見つかったらcol_white[i] = 1として印をつける
                 col_white[j] = 1;
             }

          }
      }

      //白黒を出力
      for(i = 0; i < height; i++){
          if (row_white[i] == 1) continue;  //row_white[i] = 1ならばそのrowをスキップ

          for(j = 0; j < width; j ++){
              if (col_white[j] == 1) continue;  //col_white[i] = 1ならばそのcolをスキップ

              printf("%c", input[i][j]);
          }
          printf("\n");
      }

      return 0;


  }


Measured memory_bytes: 128
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
#include <tuple>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;
typedef tuple<int, int , int> T;
int dp[366][366];
int dp2[366][366];
int main() {
while(1){
	memset(dp,0,sizeof(dp));
	memset(dp2,0,sizeof(dp2));
	int ret=0;
	T in[1000];
	int n;
	cin >> n;
	if(n==0)return 0;
	for(int i=0;i<n;i++){
		int a,b,w;
		cin >> a >> b >> w;
		in[i]=T(b,a,w);
	}
	sort(in,in+n);
	for(int k=0;k<n;k++){
		int a=get<1>(in[k]);
		int b=get<0>(in[k]);
		int w=get<2>(in[k]);
		for(int i=0;i<a;i++){
			for(int j=i;j<=b;j++){
				if(j<a){
					dp2[i][b]=max(dp2[i][b],dp[i][j]+w);
				}
				else
				{
					dp2[j][b]=max(dp2[j][b],dp[i][j]+w);
				}
			}
		}
		for(int j=0;j<=b;j++){
			dp[j][b]=max(dp[j][b],dp2[j][b]);
			ret=max(ret,dp[j][b]);
		}
	}
	cout << ret << endl;
}
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n, m;
	cin >> n >> m;
	vector<int> a(n), b(n);
	rep(i, n) cin >> a[i] >> b[i];
	vector<int> c(m), d(m);
	rep(i, m) cin >> c[i] >> d[i];

	rep(i, n) {
		int mi = INF;
		int num = -1;
		rep(j, m) {
			int dd = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (mi > dd) {
				mi = dd;
				num = j + 1;
			}
		}
		out(num);
	}

	return 0;
}

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

int n, m, c, b[20], a[20][20];

int main() {
  cin >> n >> m >> c;
  rep(i,m) cin >> b[i];
  rep(i,n) {
    rep(j,m) {
      cin >> a[i][j];
    }
  }
  
  int ans = 0;
  rep(i,n) {
    int sum = c;
    rep(j,m) sum += a[i][j] * b[j];
    if (sum > 0) ans++;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
const int N = 17; 
using namespace std;

int n, m, pw[N], sz, w[N][N], g[N][(1 << 17) + 5], h[(1 << 17) + 5], f[(1 << 17) + 5][N], ans, vis[(1 << 17) + 5], sum; 

template < typename T >
inline T read()
{
	T x = 0, w = 1; char c = getchar();
	while(c < '0' || c > '9') { if(c == '-') w = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * w; 
}

int lowbit(int x) { return x & (-x); }

int main()
{
#ifndef ONLINE_JUDGE
	freopen("cpp.in", "r", stdin); 
#endif
	n = read <int> (), m = read <int> ();
	for(int i = (pw[0] = 1); i <= n; i++) pw[i] = 2 * pw[i - 1];
	for(int i = 0; i <= n; i++) vis[pw[i]] = i; 
	sz = pw[n] - 1; 
	for(int u, v, i = 1; i <= m; i++)
	{
		u = read <int> (), v = read <int> (), w[u][v] = w[v][u] = read <int> (); 
		sum += w[u][v], g[u][pw[v - 1]] = g[v][pw[u - 1]] = w[u][v]; 
	}
	for(int i = 1; i <= n; i++)
		for(int j = 0; j <= sz; j++) g[i][j] = g[i][lowbit(j)] + g[i][j ^ lowbit(j)]; 
	for(int u, v, i = 1; i <= sz; i++)
	{
		u = lowbit(i), v = i ^ u, u = vis[u] + 1; 
		h[i] = h[v] + g[u][v]; 
	}
	memset(f, -0x3f, sizeof(f));
	for(int i = 1; i <= sz; i++) if(i & pw[0]) f[i][1] = h[i]; 
	for(int x, s = 1; s <= sz; s++)
		for(int i = 1; i <= n; i++)
			if(s & pw[i - 1])
				for(int j = 1; j <= n; j++)
					if(!(s & pw[j - 1]) && w[i][j])
					{
						x = sz ^ s; 
						for(int t = x; t; t = (t - 1) & x)
							if((t & pw[j - 1]) && !(t & s))
								f[s | t][j] = max(f[s | t][j], f[s][i] + w[i][j] + h[t]); 
					}
	for(int i = 0; i <= sz; i++) ans = max(ans, f[i][n]); 
	printf("%d\n", sum - ans); 
	return 0; 
}


Measured memory_bytes: 14012
n=int(input())
S=input()
ans=0
sublist=[]
for i in range(100):
    used=0
    j="0"*(2-len(str(i)))+str(i)
    flag1=False
    flag2=False
    for i in range(n):
        if not flag1 and S[i]==j[0]:
            flag1=True
            continue
        if flag1 and not flag2:
            if S[i]==j[1]:
                flag2=True
                used=i+1
    if flag2:
        sublist.append((j,used))
anslist=[]
for some in sublist:
    a1=some[0]
    index=some[1]
    lis=[0 for i in range(10)]
    for j in range(index,n):
        anslist.append(a1+S[j])
anslist=set(anslist)
print(len(anslist))


Measured memory_bytes: 193140
#include<bits/stdc++.h>
#define N 1005
#define int long long
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<'!');
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>'!')x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
const int mod=1000000007;
int n,m,k,cnt;
char s[N][N];
struct mat
{
	int s[3][3];
	mat(){memset(s,0,sizeof s);}
}f,g;
mat operator * (const mat& a,const mat& b)
{
	mat res;
	for(int i=0;i<3;++i)
		for(int j=0;j<3;++j)if(a.s[i][j])
			for(int k=0;k<3;++k)if(b.s[j][k])
				res.s[i][k]=(res.s[i][k]+1ll*a.s[i][j]*b.s[j][k])%mod;
	return res;
}
int mi(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=1ll*res*a%mod;
		a=1ll*a*a%mod;
		b>>=1;
	}
	return res;
}
mat mi(mat a,int b)
{
	mat res=a;--b;
	while(b)
	{
		if(b&1)res=res*a;
		a=a*a;
		b>>=1;
	}
	return res;
}
main()
{
	re(n),re(m),re(k);
	for(int i=1;i<=n;++i)
	{
		scanf("%s",s[i]+1);
		for(int j=1;j<=m;++j)
			cnt+=s[i][j]=='#';
	}
	if(k<=1)return puts("1"),0;
	int x=0,y=0;
	for(int i=1;i<=n;++i)
		if(s[i][1]=='#' && s[i][m]=='#')
			++y;
	for(int i=1;i<=m;++i)
		if(s[1][i]=='#' && s[n][i]=='#')
			++x;
	if(x&&y)return puts("1"),0;
	if(!x&&!y)return printf("%lld\n",mi(cnt,k-1)),0;
	int w=0;
	if(!x)
	{
		swap(x,y);
		for(int i=1;i<=n;++i)
			for(int j=1;j<m;++j)
				w+=s[i][j]=='#'&&s[i][j+1]=='#';
	}
	else 
	{
		for(int i=1;i<n;++i)
			for(int j=1;j<=m;++j)
				w+=s[i][j]=='#'&&s[i+1][j]=='#';
	}
	g.s[0][0]=cnt;
	g.s[0][1]=cnt-1;
	g.s[0][2]=1;
	f.s[0][0]=cnt;
	f.s[1][1]=cnt;
	f.s[2][2]=x;
	f.s[2][1]=w;
	g=g*mi(f,k-1);
	printf("%lld\n",(g.s[0][0]-g.s[0][1]+mod)%mod);
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main(){
    char s[5];scanf("%s",s);
    for(int i=0;i<3;i++){
          if(s[i]=='1') s[i]='9';
          else if(s[i]=='9') s[i]='1';
    } 
    printf("%s\n",s);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {


        static void Main(string[] args)
        {
            char[] cardsA = Console.ReadLine().ToCharArray();
            char[] cardsB = Console.ReadLine().ToCharArray();
            char[] cardsC = Console.ReadLine().ToCharArray();

            int indexA = 0;
            int indexB = 0;
            int indexC = 0;

            string parent = "A";

            while (true)
            {
                if (parent == "A")
                {
                    if (cardsA.Length  == indexA)
                    {
                        Console.WriteLine("A");
                        return;
                    }

                    if (cardsA[indexA] == 'a')
                    {
                        parent = "A";
                    }
                    else if (cardsA[indexA] == 'b')
                    {
                        parent = "B";
                    }
                    else
                    {
                        parent = "C";
                    }
                    indexA++;
                    
                    continue;
                }
                else if (parent == "B")
                {
                    if (cardsB.Length  == indexB)
                    {
                        Console.WriteLine("B");
                        return;
                    }
                    if (cardsB[indexB] == 'a')
                    {
                        parent = "A";
                    }
                    else if (cardsB[indexB] == 'b')
                    {
                        parent = "B";
                    }
                    else
                    {
                        parent = "C";
                    }
                    indexB++;
                    
                    continue;
                }
                else
                {
                    if (cardsC.Length == indexC)
                    {
                        Console.WriteLine("C");
                        return;
                    }
                    if (cardsC[indexC] == 'a')
                    {
                        parent = "A";
                    }
                    else if (cardsC[indexC] == 'b')
                    {
                        parent = "B";
                    }
                    else
                    {
                        parent = "C";
                    }
                    indexC++;
                    
                    continue;
                }
            }

        }
    }

}


Measured memory_bytes: 13140
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;

string s;
void dfs(int pos, int n, int mask) {
  if(pos == n) {
    cout<<s<<endl;
    return;
  }
  for(int i=0;i<26;i++){
    if(mask&(1<<i)){
      s[pos] = 'a' + i;
      dfs(pos+1,n,mask);
    } else {
      s[pos] = 'a' + i;
      dfs(pos+1, n, mask|(1<<i));
      break;
    }
  }
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  s = string(n, ' ');
  dfs(0, n, 0);
  return 0;
}


Measured memory_bytes: 1536