akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

void solve()
{
	ll a, b;
	cin >> a >> b;

	cout << max({a + b, a - b, a * b}) << endl;	
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define VEC vector<vector<int> >

void dep(int now,VEC &ch, vector<int> &dp , int depth){
    dp[now]=depth;
    for(auto x: ch[now]) dep(x,ch,dp,depth+1);
    return;
}

int main(){
    int u;
    cin>>u;
    VEC ch(u,vector<int>(0));
    vector<int> pr(u,-1);
    vector<int> dp(u);
    for(int i=0;i<u;i++){
        int a,b;
        cin>>a>>b;
        while(b-->0){
            int k;
            cin>>k;
            ch[a].push_back(k);
            pr[k]=a;
        }
    }
    int rt=find(pr.begin(),pr.end(),-1)-pr.begin();
    dep(rt,ch,dp,0);
    for(int i=0;i<u;i++){
        cout<<"node "<<i<<": parent = "<<pr[i]<<", depth = "<<dp[i]<<", ";
        if(i==rt) cout<<"root";
        else if(ch[i].empty()) cout<<"leaf";
        else cout<<"internal node";
        cout<<", [";
        for(int j=0;j<ch[i].size();j++){
            if(j) cout<<", ";
            cout<<ch[i][j];
        }
        cout<<"]"<<endl;
    }

    return 0;
}


Measured memory_bytes: 6696
/* 
 * Project: AtCoder Beginners Contest 165 
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/05/02
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <cmath>
using namespace std;

int k;
int a, b;

void solve() {

    for (int i=a;i<=b;i++) {
        if (i%k == 0) {
            printf("OK\n");
            return;
        }
    }
    printf("NG\n");
}

int main() {

    scanf("%d", &k);
    scanf("%d", &a);
    scanf("%d", &b);

    solve();

}

Measured memory_bytes: 1616
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var NM = ReadLine().Split().Select(int.Parse).ToArray();
        var N = NM[0];
        var M = NM[1];
        var A = ReadLine().Split(' ').Select(int.Parse).ToArray();
        var B = new int[M];
        var C = new int[M];
        for (int i = 0; i < M; i++)
        {
            var line = ReadLine().Split(' ');
            B[i] = int.Parse(line[0]);
            C[i] = int.Parse(line[1]);
        }
        Array.Sort(A);
        Array.Sort(C, B);
        Array.Sort(C);
        Array.Reverse(B);
        Array.Reverse(C);

        var Z = new int[A.Length];
        var a = 0;
        for (int i = 0; i < B.Length; i++)
        {
            for (int j = 0; j < B[i]; j++)
            {
                Z[a] = C[i];
                a++;
                if (a >= Z.Length) break;
            }
            if (a >= Z.Length) break;

        }

        var ans = 0L;
        for (int i = 0; i < N; i++)
        {
            ans += Max(A[i], Z[i]);
        }
        WriteLine(ans);
    }
}


Measured memory_bytes: 30156
#include<bits/stdc++.h>
using namespace std;
const int maxn = 111;
vector<int>g[maxn];
int a[maxn],b[maxn],c[maxn],d[maxn];
int vis[maxn];
int tim;
int match[maxn];
bool found(int x)
{
	for(int nxt:g[x])
	{
		if(vis[nxt]!=tim)
		{
			vis[nxt] = tim;
			if(!match[nxt]||found(match[nxt]))
			{
				match[nxt] = x;
				return true;
			}
		}
	}
	return false;
 } 
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i]>>b[i];
	for(int j=1;j<=n;j++)
		cin>>c[j]>>d[j];
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(a[i]<c[j]&&b[i]<d[j])
			{
				g[i].push_back(j);
			}
		}
	}
	int ans = 0;
	tim = 0;
	for(int i=1;i<=n;i++)
	{
		++tim;
		if(found(i))
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;
string N;
char S[4000];
int main()
{
  long long A,B,V,W,T;
  cin>>A>>V>>B>>W>>T;
  if(abs(A-B)-V*T+W*T>0){
  cout<<"NO";
  }else{
  cout<<"YES";
  }
  return 0;
}





Measured memory_bytes: 3640
#include <iostream>
#define ll long long
#define f(i, n) for (int i=1; i < n; i++)
// sort(bb, bb+n);

using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    ll k,n,aa[1000000],d=0;
    cin >>k>>n;
    cin >>aa[0];
    f(i,n){
        cin>>aa[i];
        d=max(d,aa[i]-aa[i-1]);
    }
    d=max(d,min(aa[n-1]-aa[0],k-(aa[n-1]-aa[0])));
    cout<<k-d;
    return 0;
}

Measured memory_bytes: 3840
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main() {

	long res = 0;
	long A, B, C; cin >> A >> B >> C;
	int a, b, c; a = A % 2; b = B % 2; c = C % 2;

	if (a == b && b == c && c == a) { res = (3 * max(A, max(B, C)) - A - B - C) / 2; goto koko; }

	if (max(A , max(B,C)) % 2 == (A + B + C) % 2 ) res = (3 * max(A, max(B, C)) - A - B - C -1) / 2 + 1;
	else res =( 3 * max(A, max(B, C)) - A - B - C ) / 2 + 2;

koko:
	cout << res << endl;
}

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

int main()
{
    int n, r;
    cin >> n >> r;
  
    if (10 <= n)
    {
      cout << r << endl;
    }
    else
    {
      cout << r + 100 * (10 - n) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
# C - Streamline


def main():
    s1 = input()
    s2 = input()
    ret = solve(s1, s2)
    print(ret)


def solve(s1, s2):
    N, M = list(map(int, s1.split()))
    X = list(map(int, s2.split()))
    if (N >= M):
        return 0
    X.sort()
    l = []
    for i in range(M-1):
        l.append(X[i+1]-X[i])
    l.sort()
    ct = 0
    for j in range(M-N):
        ct += l[j]
    return ct


main()


Measured memory_bytes: 14588
import sys
if sys.argv[-1] == 'ONLINE_JUDGE':
    import os, zlib, base64
    open('solve.pyx', 'wb').write(zlib.decompress(base64.b85decode("c${rg%Wi`(5WFMt4|8b)jT3>?N)<}_BWVsi46N$di7_Po``R%Lq^U2Mnep!I*tJ#%l;5URa(&EoE(8}S>2Orq;HY!i@Gz*INKjF(J5!Om@eMa+n`>r;BuyO#WyNa<C7az_VpqCHHG(7sNp3&Jo|aJzsTvYl7{IPkVNfuX*dp=pxh27ojv}`TOO8#Wc!H_6%m%OT84AtwuZeNhO1vOVu(X<$)p$~K(`$)xv^OZKkXKdYToAjOx!jxdZU~z#<jhjFqdk^eTxNFMKj9fGnni-HKlt+h4DSVhM<;wBnf2;iVb^fpYc=(n4c6UqH;^s_7dpdf+S(}%L(edT!I?~ZXR21(RwX$;fk?)gkH^NCGG8M8UwVpXj?Hhs3F;rA;SsV|YO?WNMT;j<eaZ#9MmWUw8r`OkXL>F=?k)D-;$X=i3Q@g&")))
    os.system('cythonize -i -3 -b solve.pyx')
import solve

Measured memory_bytes: 12828
import sys
from math import ceil
input = sys.stdin.readline
N = int(input())
csf = [[int(i) for i in input().split()] for _ in range(N-1)]
ans = []
for i, sa in enumerate(csf):
    t = sa[0]+sa[1]
    for gc, gs, gf in csf[i+1:]:
        t = max(ceil((t-gs)/gf)*gf+gs+gc, gc+gs)
    ans.append(t)
ans.append(0)
print(*ans, sep='\n')


Measured memory_bytes: 41436
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vll2 = vector<vector<ll>>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    vll a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    ll lc = a[0] / 2LL;
    for (int i = 1; i < n; i++) {
        lc = (lc * a[i] / 2LL) / __gcd(lc, a[i]);
    }
    for (int i = 0; i < n; i++) {
        if ((lc / (a[i] / 2LL)) % 2 == 0) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (1 + m / lc) / 2 << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    cout<<(a*3+b)/2<<endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

void solve()
{
    int64_t N;
    std::cin >> N;
    std::map<int64_t, int64_t> num;
    for (int64_t i = 0; i < N; i++)
    {
        int64_t a;
        std::cin >> a;
        num[a]++;
    }

    int64_t ans = 0;
    for (auto e : num)
    {
        int64_t a = e.first;
        int64_t v = e.second;
        int64_t tmp_ans = v;
        if (num.count(a - 1) != 0) tmp_ans += num[a - 1];
        if (num.count(a + 1) != 0) tmp_ans += num[a + 1];
        ans = std::max(ans, tmp_ans);
    }

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

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}


Measured memory_bytes: 7568
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

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

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n;
  cin >> n;
  priority_queue<ll, vector<ll>, greater<ll>> a;
  ll minusNumber = 0;
  ll zeroNumber = 0;
  rep(i, n) {
    ll temp;
    cin >> temp;
    minusNumber += temp < 0;
    zeroNumber += temp == 0;
    a.push(abs(temp));
  }
  ll leftNumber = max(minusNumber - zeroNumber, 0LL) % 2;
  ll res = 0;
  rep(i, leftNumber) {
    res -= a.top();
    a.pop();
  }
  while (!a.empty()) {
    res += a.top();
    a.pop();
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  int ret = 0;
  REP(i,1,N+1){
    int x = i;
    int cnt = 0;
    while(x>0){
      cnt++;
      x /= 10;
    }
    if(cnt % 2 == 1) ret++;
  }
  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << precision(10)
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"

typedef long lint;
typedef pair<lint, lint> P;

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

    vector<lint> a(N);
    vector<lint> b(N);
    vector<lint> c(N);

    vector<vector<lint>> dp(N, vector<lint>(3));

    REP(i, N) {
      lint x;
      cin >> x; a[i] = x;
      cin >> x; b[i] = x;
      cin >> x; c[i] = x;
    }

    dp[N-1][0] = a[N-1];
    dp[N-1][1] = b[N-1];
    dp[N-1][2] = c[N-1];

    for(lint i=N-2; i >=0;i--) {
      lint res = 10000000000;

      dp[i][0] = max(a[i] + dp[i+1][1], a[i]+dp[i+1][2]);
      dp[i][1] = max(b[i] + dp[i+1][0], b[i]+dp[i+1][2]);
      dp[i][2] = max(c[i] + dp[i+1][0], c[i]+dp[i+1][1]);
    }
    
    PRINT(max(dp[0][0], max(dp[0][1], dp[0][2])));
    return 0;
}


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

using namespace std;

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

    int n, k;
    cin >> n >> k;

    vector<long long> h(n);
    vector<long long> jump(n);
    for(int i = 0; i < n; ++i)
        cin >> h[i];

    jump[n - 1] = 0;
    for(int i = n - 2; i >= 0; i--) {
        jump[i] = jump[i + 1] + abs(h[i] - h[i + 1]);
        for (int j = i + 2; j < min(n, i + k + 1); ++j)
            jump[i] = min(jump[i], jump[j] + abs(h[i] - h[j]));
    }


    cout << jump[0] << "\n";

    return 0;
}//RUL0

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

int main(){
    string s;
    cin >> s;
    int n,count=0;
    
    n=s.length()/2;
    for(int i=0;i<n;i++){
        if(s[i] != s[s.length()-i-1])
            count++;
    }
    cout << count << endl;
    return 0;
}

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

#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) 
\

int main()
{
	
	int n;
	cin>>n;
	int* arr = new int[n-1];
	REP(i,0,n-2)
	{
		cin>>*(arr+i);
	}
	int* arr1 = new int[n];
	REP(i,0,n-1)
	{
		*(arr1+i)=0;
	}
	REP(i,0,n-2)
	{
		arr1[arr[i]-1]++;
	}
	REP(i,0,n-1)
	{
		cout<<*(arr1+i)<<"\n";
	}
  	return 0;

}

Measured memory_bytes: 4712
#include<bits/stdc++.h>
int main()
{
    int a,b,x,i,s,c;
    while(scanf("%d %d",&a,&b)==2){
            x=1;
            s=0;
        for(i=1;i<=a;i++){
            scanf("%d",&c);
            s+=c;
            if(s<=b)
                x++;
        }
        printf("%d\n",x);
    }
}

Measured memory_bytes: 256
N = int(input())
s = sorted(("".join(sorted(list(input()))) for _ in range(N))) + [""]

ans = 0

w = None
cnt = 0
path = 0
for x in s:
    if x != w:
        ans += path
        if x is None:
            break
        path = 0
        cnt = 1        
        w = x
    else:
        path += cnt
        cnt += 1

print(ans)


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

const int N=100100;
int a[N],n,f[N][30],L,Q;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i];
	cin>>L>>Q;
	for(int i=1;i<=n;++i)f[i][0]=upper_bound(a+1,a+n+1,a[i]+L)-a-1;
	for(int i=1;i<=20;++i)
		for(int j=1;j<=n;++j)f[j][i]=f[f[j][i-1]][i-1];
	for(;Q --> 0;){
		int l,r;cin>>l>>r;
		if(l>r)swap(l,r);
		int ans=1;
		for(int i=20;~i;--i)
			if(f[l][i]<r)l=f[l][i],ans+=1<<i;
		cout<<ans<<'\n';
	}
	return 0;
}


Measured memory_bytes: 12928
#ALDS1_2-B Sort 1 - Selection Sort
def selectionSort(A,N):
    c=0
    for i in range(N):
        minj = i
        j=i
        while j<N:
            if(int(A[j])<int(A[minj])):
                minj = j
            j+=1
        if(i!=minj):
            A[i],A[minj]=A[minj],A[i]
            c+=1
    return c

N=int(input())
A=input().split()
c=selectionSort(A,N)
S=""
for i in range(N-1):
    S+=A[i]+" "
S+=str(A[-1])
print(S)
print(c)

Measured memory_bytes: 7720
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <random>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define rep(x, b, e) for(int x=(b); x<(e); ++x)
#define ford(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define all(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);
	ll a;
	string x;
	ll b;
	cin >> a >> x;
	b = (x[0] - '0')*100 + (x[2]-'0' )*10 + (x[3] - '0');
	cout << (a * b) / 100 << endl;
	
}

Measured memory_bytes: 3656
// #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

#define rep(i,n) for (int i = 0; i < n; ++i)
#define repr(i,n) for (int i = n; i > 0; --i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MAX = 100;
const int INF = (1<<12);

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

  vector<char> S(N), P(N), Q(N);
  rep(i,N) cin >> P[i];
  rep(i,N) cin >> Q[i];

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

  string p(P.begin(), P.end());
  string q(Q.begin(), Q.end());

  S = P;
  sort(S.begin(),S.end());

  int a,b;
  a = b = 0;
  int i = 1;
  do{
    string s(S.begin(), S.end());
    if(s == p) a = i;
    if(s == q) b = i;
    i++;
  }while(next_permutation(S.begin(), S.end()));

  cout << abs(a - b) << endl;
  return 0;
}

Measured memory_bytes: 256
import collections, sys

N = int(input())
S = list(map(int, input().split()))
if N ==1 :
  if S[0] == S[1]:
    print("No")
  else:
    print("Yes")
  sys.exit()
  
K = collections.Counter(S)
score_sorted = sorted(K.items(), key=lambda x:x[0], reverse = True)

if score_sorted[0][1] > 1:
  print("No")
  sys.exit()
  

DP = [[0 for i in range(len(K))] for j in range(N+1)]
DP[0][0] = 1
for i in range(N):#日数
  nokoshi = 0
  for k in range(len(K)):
    if k == 0:
      DP[i+1][k] = DP[i][k]
    else:
      hairu = score_sorted[k][1] - DP[i][k]
      ireru = min(hairu, DP[i][k-1] + nokoshi)
      
      DP[i+1][k] = DP[i][k] + ireru
      nokoshi = DP[i][k-1] + nokoshi - ireru
  if nokoshi > 0:
    print("No")
    break
else:
  for i in range(len(score_sorted)):
    if DP[N][i] != score_sorted[i][1]:
      print("No")
      break
  else:
    print("Yes")

Measured memory_bytes: 145024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if (A+B>C+D) {
    cout << "Left" ; 
   }
  else if (A+B<C+D) {
    cout << "Right" ;
  }
  else {
    cout << "Balanced" ;
  }
}


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

int main() {
  //A,Bを入力
  int A, B;
  cin >> A >> B;
  
  // 計算
  int plus;
  int minus;
  int multi;
  plus = A + B;
  minus = A - B;
  multi = A * B;
  
  //計算結果を配列変数に代入
  vector<int> vec;
  vec = {plus, minus, multi};
  sort(vec.begin(), vec.end());
  cout << vec.at(2) << endl;
  
}

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

    cin >> n >> m;

    int sum = 0;

    for (int i = 0; i < m; i++)
    {
        int ai;
        cin >> ai;
        sum += ai;
    }

    if(n < sum) cout << "-1" << endl;
    else cout << n - sum << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

// Most important thing in CP - Have Fun :)

void solve(){
	//write here
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max({a*c,a*d,b*c,b*d})<<endl;
	return;
}

int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
	
		solve();
	return 0;
}

Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    ll n, m;
    cin >> n >> m;
    if ( n == 1 && m == 1 )      cout << 1 << endl;
    else if ( n == 1 )           cout << m - 2 << endl;
    else if ( m == 1 )           cout << n - 2 << endl;
    else                         cout << ( m - 2 ) * ( n - 2 ) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define pii 3.14
#define mod (ll)(1e9 + 7)
#define inf (ll)(1e18)
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ordered_set tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update>
#define pi pair<int,int>
#define N (ll)(2e5+5)

void solve()
{
   ll n,x;
   cin>>n;

   map<ll,ll> p;
   ll m[n];
   for(ll i=1;i<=n;i++)
   {
       cin>>x;
       m[i-1] = i-x;
       p[i+x]++;
   }

   ll ans = 0;

   for(int i=0;i<n;i++)
       ans += p[m[i]];

   cout<<ans<<"\n";
}

int main()
{
    fio;
    ll tc = 1;
    //cin>>tc;
    while(tc--)
    {
        solve();
    }
}


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

using namespace std;

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

#define int ll

const ll mod = 1e9 + 7;


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

	int t=0,u=0,v=0;
	for(int i=0;i<n;i++){
		if(p[i]<=a){
			t++;
		}else if(a<p[i]&&p[i]<=b){
			u++;
		}else if(b<p[i]){
			v++;
		}
	}
	
	cout << min(min(t,u),v) << endl;


	return 0;
}


Measured memory_bytes: 3516
#include <stdio.h>

int main()
{
    char b;
    
    scanf("%c",&b);
    if(b == 'A'){
        printf("T");
    }else if(b == 'C'){
        printf("G");
    }else if(b == 'G'){
        printf("C");
    }else{
        printf("A");
    }
    return 0;
}


Measured memory_bytes: 128
n = input()

n1 = int(n[0])
n2 = int(n[1])
n3 = int(n[2])
n4 = int(n[3])

for op2 in [n2,-n2]:
	for op3 in [n3,-n3]:
		for op4 in [n4,-n4]:			
			if n1+op2+op3+op4 == 7:
				a = [op2,op3,op4]
				break

ans = str(n1)
for i in a:
	if i >= 0:
		ans += (('+') + str(i))
	else:
		ans += str(i)

ans += '=7'
print(ans)


Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#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())
int main(){
  int a,b;cin>>a>>b;
  int ans=3*a+b;
  ans/=2;
  cout<<ans<<endl;


}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(void) {
	int n;
	cin >> n;
	string s;
	cin >> s;
	for (int i(0); i < s.size(); i++) {
		s[i] += n;
		if ((int)s[i] > 90)s[i] -= 26;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
import sys

S = list(input())

nS = S
i = 0

while len(nS) > 2:
    i += 1
    lns = len(S) - 2*i
    nS = S[:lns]
    nS1 = "".join(nS[:lns//2])
    nS2 = "".join(nS[lns//2:])
    if nS1 == nS2:
        print(len(nS))
        sys.exit()

print(1)  

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;

using ll = long long;

const ll MOD = 1000000007;
vector<ll> fact(300000);

ll pow(ll a, ll b){
    if(b == 1)
        return a;//a^1を計算した
    if(b % 2 == 1)
        return a * pow(a,b-1) % MOD;
    ll x = pow(a,b/2);
    return x * x % MOD;
}

ll invarse(ll a){
    return pow(a , MOD - 2);
}

ll Comb(ll n, ll k){//組み合わせnCkの計算
    return fact[n] * invarse(fact[k] * fact[n-k] % MOD) % MOD;
}

int main(){
    ll h,w,a,b;
    cin >> h >> w >> a >> b;
    fact[0] = 1;
    fact[1] = 1;
    for(int i = 2; i < 300000; i++){
        fact[i] = (fact[i-1] * i) % MOD;
    }
    ll ans = 0;
    int i = 0;
    //数え上げをする。
    
    for(int j = 0; j < h-a; j++){
        ans = (ans + Comb(b+j-1,j) * Comb(w-b-2+h-j,h-j-1)  % MOD) % MOD; 
       // cout << b+j-1 << "C" << j << " * " << w - b  + h - j - 2<< "C" << h-j << endl;
    }
    cout << ans << endl;
    return 0;
}



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

#define int long long
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define allrev(x) (x).rbegin(), (x).end()
#define pb push_back
#define pf push_front
#define fori(i, a, n) for(int i = a; i < n; ++i)
#define MAX(x) (*max_element(all(x)))
#define MIN(x) (*min_element(all(x)))
#define sortarr(a,n) sort(a, a+n)
#define sortvec(V) sort(all(V))

typedef vector<int> V;
typedef pair<int , int> pairi;
typedef set<int> seti;
typedef deque<int> deqi;

const int MOD = 1e9+7;
const int INF = 1e9+8;
const double pi = 3.14159265359;

const int N = 6;
string s[N];
void solve()
{
    int h, w, k;
    cin >> h >> w >> k;
    for(int i = 0; i < h; i++)
        cin >> s[i];
    int ans = 0;
    for(int S = 0; S < (1 << h); S++){
        for(int t = 0; t < (1 << w); t++){
            int rs = 0;
            for(int i = 0; i < h; i++){
                for(int j = 0; j < w; j++){
                    if(S & (1 << i) || t & (1 << j))    continue;
                    rs += (s[i][j] == '#');
                }
            }
            ans += (rs == k);
        }
    }
    cout << ans << endl;
}
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    solve();
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
}

Measured memory_bytes: 3788
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <vector>
typedef long long ll;
const int maxn = 1e5 + 5;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);


int main (int argc, char **argv) {
  int x, y, z;
  std::cin >> x >> y >> z;
   
  for (int i=1;;i++) {
    if (i*y + (i+1)*z > x) {
      std::cout << (i-1) << std::endl;
      break;
    }
  }	  
  return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
string b;
int main(){
    int q=0;
    cin>>b;
    for(int i=0;i<b.size();i++){ 
    if(b[i]=='C') q++;
    if(q!=0 && b[i]=='F') q=-10000;
    }
    if(q<0) cout<<"Yes"; else cout<<"No";
    return 0;
}

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

using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;

int main() {
    int m1,d1,m2,d2;
    cin >> m1 >> d1 >> m2 >> d2;
    if(m1 + 1 == m2) {
        cout << 1 << endl;
        return 0;
    }

    cout << 0 << endl;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "
#define fi first
#define se second

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

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

ll modinv(ll a, ll mod){
  ll b=mod, u=1, v=0;
  while(b){
    ll t=a/b;
    a-=t*b; swap(a, b);
    u-=t*v; swap(u, v);
  }
  u%=mod;
  if(u<0)u+=mod;
  return u;
}

ll gcd(ll a, ll b){
  ll r = a%b;
  if(r==0) return b;
  else return gcd(b, a%b);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;
  cin >> N;
  ll ans = 0;
  for(ll a=1;a<=N;a++){
    ans += (N-1)/a;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3640
n,c = (int(i) for i in input().split())
d = [[int(i) for i in input().split()] for i in range(c)]
x = [[int(i) for i in input().split()] for i in range(n)]
lis0,lis1,lis2 = [0 for i in range(c)],[0 for i in range(c)],[0 for i in range(c)]
for i in range(n):
	for j in range(n):
		if (i+j)%3==0: lis2[x[i][j]-1]+=1
		elif (i+j)%3==1: lis0[x[i][j]-1]+=1
		else: lis1[x[i][j]-1]+=1
from itertools import permutations
y,ans = [i for i in range(c)],float("inf")
for i,j,k in list(permutations(y,3)):
	num = 0
	for i2 in range(c): num+=lis0[i2]*d[i2][i]+lis1[i2]*d[i2][j]+lis2[i2]*d[i2][k]
	ans = min(ans,num)
print(ans)

Measured memory_bytes: 7412
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
//Modulo Calculation
const int MOD = 998244353;
//ModInt
template <int mod>
struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {
        if ((x = x_ % mod + mod) >= mod) x -= mod;
    }
    ModInt& operator+=(ModInt rhs) {
        if ((x += rhs.x) >= mod) x -= mod;
        return *this;
    }
    ModInt& operator-=(ModInt rhs) {
        if ((x -= rhs.x) < 0) x += mod;
        return *this;
    }
    ModInt& operator*=(ModInt rhs) {
        x = (unsigned long long)x * rhs.x % mod;
        return *this;
    }
    ModInt& operator/=(ModInt rhs) {
        x = (unsigned long long)x * rhs.inv().x % mod;
        return *this;
    }
  
    ModInt operator-() const { return -x < 0 ? mod - x : -x; }
    ModInt operator+(ModInt rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(ModInt rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(ModInt rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(ModInt rhs) const { return ModInt(*this) /= rhs; }
    ModInt &operator++ () { *this += 1; return *this;}
    ModInt operator++ (int) { *this += 1; return *this - 1;}
    ModInt &operator-- () { *this -= 1; return *this;}
    ModInt operator-- (int) { *this -= 1; return *this + 1;}
    bool operator==(ModInt rhs) const { return x == rhs.x; }    
    bool operator!=(ModInt rhs) const { return x != rhs.x; }
    bool operator<=(ModInt rhs) const { return x <= rhs.x; }
    bool operator>=(ModInt rhs) const { return x >= rhs.x; }
    bool operator<(ModInt rhs) const { return x < rhs.x; }
    bool operator>(ModInt rhs) const { return x > rhs.x; }
    ModInt inv() const { return pow(*this, mod - 2); }
  
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {
        s << a.x;
        return s;
    }
    friend istream& operator>>(istream& s, ModInt<mod>& a) {
        s >> a.x;
        return s;
    }
};
using mint = ModInt<MOD>;

//二項定理計算
const int MAX = 500000;
mint fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*(mint)i;
        inv[i]=(mint)MOD-inv[MOD%i]*(mint)(MOD/i);
        finv[i]=finv[i-1]*inv[i];
    }
}

mint COM(int n,int k){
    if(n < k or n < 0 or k < 0)return 0;
    return fac[n]*finv[k]*finv[n-k];
}

struct maketable{
    maketable(){
        COMinit();
        ios::sync_with_stdio(false);\
        cin.tie(nullptr);
    }
}maketable_;

mint res;
int main(){
    int n, k;
    cin >> n >> k;
    for(int r = n - 1; r <= k; r++) res += COM(k - 1, r);
    cout << res << '\n';
}

Measured memory_bytes: 9472
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
int main() {
    int k,n;
    cin>>k,n=(k+3)/4*2;
    if(k==1) return puts("1\n1"),0;
    cout<<n<<endl;
    for(int i=0;i<n;i++,puts(""))
	for(int j=0;j<n;j++) {
	    int t=(i+j)%n;
	    if(i&1&&t+n<k) t+=n;
	    printf("%d ",t+1);
	}
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>

#define MOD 1000000007LL

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

vector<vector<ll>> CM;

ll C(int a, int b)
{
    if(b==0) return 1;
    if(a<b) return 0;
    if(CM[a][b]!=-1) return CM[a][b];
    return CM[a][b]=(C(a-1,b-1)+C(a-1,b))%MOD;
}

ll H(int a, int b)
{
    return C(a+b-1,b);
}

int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
    CM.resize(4000,vector<ll>(4000,-1));

    int n,k;
    cin>>n>>k;
    for(int i=0; i<k; i++){
        ll sum=0;
        for(int j=0; j<=n-k-i; j++){
            sum=(sum+(H(i,n-k-i-j)*H(2,j))%MOD)%MOD;
        }
        sum=(sum*C(k-1,i))%MOD;
        cout<<sum<<"\n";
    }

    return 0;
}


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


Measured memory_bytes: 128
while 1:
    n = int(raw_input())
    m = int(raw_input())
    dic = {}

    if not n and not m:
       break
    
    for i in range(n):
        dic[i+1] = []
    
    for i in range(m):
        a, b = [int(j) for j in raw_input().split(" ")]
        dic[a].append(b)
        dic[b].append(a)
    
    invite = list(dic[1])
    for i in dic[1]:
        invite += dic[i]
    
    d = set(invite)
    print len(d) - (1 in d)

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

int main(void){
  int N, temp;
  cin >>N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> temp;
    A[temp - 1] = i + 1;
  }
  for(int i = 0; i < N; i++){
    cout << A[i] << " ";
  }
  return 0; 
}

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdio>
#include <vector>

using namespace std;

int main()
{
    int h,w;
    cin>>h>>w;
    char brd[52][52];
    bool ok=true;
    for (int i=0; i<52; i++)
    {
        for (int j=0; j<52; j++)
        {
            brd[i][j]='.';
        }
    }
    for (int i=1; i<=h; i++)
    {
        for (int j=1; j<=w; j++)
        {
            cin>>brd[i][j];
        }
    }
    int cnt;
    for (int i=1; i<=h; i++)
    {
        for (int j=1; j<=w; j++)
        {
            cnt=0;
            if (brd[i][j]=='#')
            {
                if (brd[i-1][j]=='#') cnt++;
                if (brd[i+1][j]=='#') cnt++;
                if (brd[i][j-1]=='#') cnt++;
                if (brd[i][j+1]=='#') cnt++;
                if (cnt==0) ok=false;
            }
        }
    }
    if (ok) cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
vector<vector<int>> dp((1<< 17),vector<int>(17,INF));
vector<vector<int>> t(17,vector<int>(17));



int mini(int bit,int j,int n){
    int ans = t[j][0];
    for(int k = 0; k < n; k++) {
        if ((bit >> k) & 1){
            ans = min(ans,t[j][k + 1]);
        }
    }
    // cout << ans << endl;
    return ans;
}
int search(int n){
    vector<vector<int>> dp((1<< 17),vector<int>(17,INF));
      t.resize(17,vector<int>(17,INF));
      for(int i = 0; i < n; i++) {
      for(int j = 0; j <= n; j++) {
          cin>>t[i][j];
      }
  }
  for(int i = 0; i < (1 << n); i++) {
      dp[i][0] = 0;
  }
  for(int i = 0; i <= n; i++) {
      dp[(1 << (n)) - 1][i + 1] = 0;
  }
    for(int bit = (1 << (n)) - 2; bit >= 0; bit--) {
        for(int i = 0; i < n; i++) {
            for(int j= 1; j <= n; j++) {
                if (!((bit >> i) & 1)){
                    dp[bit][i + 1] = min(dp[bit][i + 1],dp[(bit | (1 << i))][j] + mini(bit,i,n));
                }    
            }
            
        }
    }
    // for(int i = 0; i < (1 << n); i++) {
    //     for(int j = 0; j <= n; j++) {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    int res = INF;
    for(int i = 1; i <= n; i++) {
        res = min(res,dp[0][i]);
    }
    cout << res << endl;
    return 0;
}

int main(){
    int n;cin>>n;
    while (n != 0){
        search(n);
        cin>>n;
    }
    return 0;
}




Measured memory_bytes: 29540
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define F first
#define S second
#define pss pair<string,string>
#define pcc pair<char,char>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
#define vs vector<string>
#define vl vector<ll>
#define vs vector<string>
#define vll vector<pll>
#define vss vector<pss>
#define vcc vector<pcc>
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=n-1;i>=0;i--)
using namespace std;
const int N = 1005;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int n,m,dis[N][N];deque<pii>q;
int X,Y,XX,YY;char c[N][N];
inline bool ok(int x,int y){return (x>=0&&y>=0&&x<n&&y<m&&c[x][y]=='.');}
void bfs()
{
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			dis[i][j]=1e9;
	dis[X][Y]=0;
	q.push_front(mp(X,Y));
	while(!q.empty())
	{
		pii p=q.front();q.pop_front();
		
		for(int i=0;i<4;i++)
		{
			int x2=p.F+dx[i];
			int y2=p.S+dy[i];
			if(ok(x2,y2)&&dis[x2][y2]>dis[p.F][p.S])
			{
				dis[x2][y2]=dis[p.F][p.S];
				q.push_front(mp(x2,y2));
			}
		}
		for(int i=p.F-2;i<=p.F+2;i++)
		{
			for(int j=p.S-2;j<=p.S+2;j++)
			{
				if(ok(i,j)&&dis[i][j]>dis[p.F][p.S]+1)
				{
					dis[i][j]=dis[p.F][p.S]+1;
					q.push_back(mp(i,j));
				}
			}
		}
	}
}
int main()
{
	cin>>n>>m>>X>>Y>>XX>>YY;X--,Y--,XX--,YY--;
	for(int i=0;i<n;i++)
		cin>>c[i];
	bfs();
	if(dis[XX][YY]==1e9)cout<<"-1\n";
	else cout<<dis[XX][YY];
	return 0;
}

Measured memory_bytes: 8548
#include<iostream>
using namespace std;
int main(){
  int X,Y;
  cin>>X>>Y;
  int sum=0;
  if(X==1){
    sum+=300000;
  }
  else if(X==2){
    sum+=200000;
  }
  else if(X==3){
    sum+=100000;
  }
  if(Y==1){
    sum+=300000;
  }
  else if(Y==2){
    sum+=200000;
  }
  else if(Y==3){
    sum+=100000;
  }
  if(X==1&&Y==1){
    sum+=400000;
  }
  cout<<sum<<endl;
 return 0; 
}

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

#define ll long long
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
const int N = 2e5 + 5;
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int h , n;
    cin >>h >> n;
    for (int i = 0 ; i < n ; i++) {
        int x;
        cin >> x;
        h -= x;
    }
    if (h > 0)
        cout << "No";
    else cout<< "Yes";
    return 0;
}


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

using namespace std;

int main() {
    char s[3];
    scanf("%s", s);
    if (s[0] == s[1] && s[1] == s[2] && s[2] == 'S') puts("0");
    else if (s[0] == s[1] && s[1] == s[2] && s[2] == 'R') puts("3");
    else if ((s[0] == s[1] && s[1] == 'R') || (s[1] == s[2] && s[2] == 'R')) puts("2");
    else puts("1");
    return 0;
}


Measured memory_bytes: 3732
#include <iostream>
#include "bits/stdc++.h"
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a) for(ll i=0;i<a;i++)
#define jkl ll debug = 0;
#define RREP(i,a) for(ll i=a-1;i>=0;i--)
#define rrep(i,a,b) for(ll i=a-1;i>=b;i--)
#define printall(n,array) {for(ll i=0;i<n;i++){cout<<array[i]<<" ";}cout<<endl;}
#define U() cout<<endl;
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> Pi;
typedef pair<ll, Pi> V;
typedef vector<ll> VE;
const ll mod = 1e9 + 7; //10^9+7

ll h, w;
vector<vector<int> > s(400, vector<int>(400));
vector<vector<bool>> used(400, vector<bool>(400));
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

bool check_next(int y, int x, bool color){
    if(y < 0 || y >= h || x < 0 || x >= w || used[y][x] || s[y][x] != color)return 0;
    return 1;
}

int main(){
    cin >> h >> w;
    REP(i, h)REP(j, w){
        char ch;
        cin >> ch;
        s[i][j] = (ch == '#');
    }
    //when input[i][j] == black them the value is 1, while 0 when input[i][j] == white
    jkl;
    ll ans = 0;
    REP(i, h)REP(j, w){
        if(used[i][j] || !s[i][j])continue;
        queue<pair<ll, Pi>> que;
        ll black = 1, white = 0;
        que.push(make_pair(1, make_pair(i, j)));
        used[i][j] = true;
        while(!que.empty()){
            auto top = que.front();
            que.pop();
            bool color = top.first;
            auto grid = top.second;
            ll y = grid.first;
            ll x = grid.second;
            REP(k, 4){
                int nexty = y + dy[k];
                int nextx = x + dx[k];
                if(!check_next(nexty, nextx, !color))continue;
                used[nexty][nextx] = 1;
                if(!s[nexty][nextx])white++;
                if(s[nexty][nextx])black++;
                que.push(make_pair(s[nexty][nextx], make_pair(nexty, nextx)));
            }
        }
        ans += black * white;
    }
    print(ans);
}




Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,m;
	scanf("%lld%lld",&n,&m);
	ll ans=1ll*n*(m/2)+1ll*(m%2)*(n+1)/2;
	if(n==1 || m==1)
	{
		ans=1;
	}
	printf("%lld\n",ans);
	return 0;
}

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

int main(void)
{
    int n;
    int W[40];
    char word[11];
    int i, j;
    int len;
    
    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }
        
        for (i = 0; i < n; i++){
            scanf("%s", word);
            W[i] = strlen(word);
        }
        
        for (i = 0; i < 40; i++){
            len = 0;
            j = 0;
            while (len < 5){
                len += W[i + j];
                j++;
            }
//printf("[1:len=%d, j=%d]", len, j);
            if (len != 5){
                continue;
            }
            
            len = 0;
            while (len < 7){
                len += W[i + j];
                j++;
            }
//printf("[2:len=%d, j=%d]", len, j);
            if (len != 7){
                continue;
            }

            len = 0;
            while (len < 5){
                len += W[i + j];
                j++;
            }
//printf("[3:len=%d, j=%d]", len, j);
            if (len != 5){
                continue;
            }

            len = 0;
            while (len < 7){
                len += W[i + j];
                j++;
            }
//printf("[4:len=%d, j=%d]", len, j);
            if (len != 7){
                continue;
            }

            len = 0;
            while (len < 7){
                len += W[i + j];
                j++;
            }
//printf("[5:len=%d, j=%d]", len, j);
            if (len != 7){
                continue;
            }
            printf("%d\n", i + 1);
            break;
        }
    }
    return (0);
}



Measured memory_bytes: 2044
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<vector<int>> ice(90, vector<int>(90));

int m, n;

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

int dfs(int i, int j, int count) {
	if (i < 0 || n <= i || j < 0 || m <= j || ice[i][j] == 0) return 0;
	ice[i][j] = 0;
	int ret = count;
	for (int k=0; k<4; ++k) {
		ret = max(ret, dfs(i + dy[k], j + dx[k], count + 1));
	}
	ice[i][j] = 1;
	return ret;
}

int main() {
	while (cin >> m >> n && m && n) {
		for (int i=0; i<n; ++i) {
			for (int j=0; j<m; ++j) {
				cin >> ice[i][j];
			}
		}
		int ans = 0;
		for (int i=0; i<n; ++i) {
			for (int j=0; j<m; ++j) {
				ans = max(ans, dfs(i, j, 1));
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1248