akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

//省略形
#define rep(i,n) for(auto i=0; i<n ; ++i)
#define REP(i,a,b) for(auto i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//よく使う定数
const int INF = 1e9;
const int MOD = 1e9+7;
//逆元
const int INV = 1e9+5;

//UnionFindTree
struct union_find{
  vector<int> data;
  union_find(int size) : data(size , -1) { }

  void merge(int x , int y){
    x = root(x); y = root(y);
    if(x == y) return;
    if(data[y] < data[x]) swap(x , y);
    data[x] += data[y];
    data[y] = x;
    return; 
  }

  bool same(int x , int y){
    x = root(x) , y = root(y);
    return x == y;
  }

  int root(int x){
    return data[x] < 0 ? x : (data[x] = root(data[x]));
  }

  int size(int x){
    return -data[root(x)];
  }
};

//プロトタイプ宣言
void faster(void);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);
template <class T>
T modpow(T , T , T);
bool is_palindrome(string);

//メモ
//最大公約数:__gcd　|　最小公倍数:__lcm
//回文は反転させて一致すればよい


int main(){
  int n , hap1=0 , hap2=0;
  cin >> n;
  cout << (n/500)*1000 + ((n%500)/5)*5;
}


























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//繰り返し自乗法
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//繰り返し自乗法(剰余)
template <class T>
T modpow(T x , T y , T mod){
  if(y == 0) return 1;
  if(y%2 == 1){
    ll temp = modpow(x,y-1,mod);
    return temp*x%mod;
  }
  else{
    ll temp = pow_mod(x,y/2,mod);
    return temp*temp%mod;
  }
}

bool is_palindrome(string s){
    string t(s.rbegin(),s.rend());
    return s == t;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
ll A[100005];
ll dp[3][100005];
ll gcd(ll a, ll b ) {
  ll t;
  if( a < b ){ t = a; a = b; b = t; }
  while( ( t = a % b ) != 0 ){ a = b; b = t; }
  return b;
}
int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  for (int i=0; i<N; i++) cin >> A[i];
  dp[0][1] = max(A[0], A[1]);
  dp[1][1] = min(A[0], A[1]);
  dp[2][1] = gcd(A[0], A[1]);
  for (int i=2; i<N; i++) {
    dp[2][i] = gcd(dp[2][i-1], A[i]);
    ll a = gcd(dp[0][i-1], A[i]);
    ll b = gcd(dp[1][i-1], A[i]);
    ll c = dp[2][i-1];
    ll s = a + b + c;
    ll d = max(a, max(b, c));
    ll f = min(a, min(b, c));
    ll e = s - d - f;
    dp[0][i] = d;
    dp[1][i] = e;
  }
  cout << dp[0][N-1] << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  for(int i = 0; i < N; ++i){
    cin >> a.at(i);
    a.at(i)--;
  }
  int count = 1;
  for(int i = 0; a.at(i) != 1; ++count){
    i = a.at(i);
    if(count >= N){
      count = -1;
      break;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <functional>
#include <string>
#include <vector>
#include <algorithm>
 
using namespace std;

int main()
{
    string S;
    cin >> S;

    int result = 753;
    for (int i=0; i<S.size()-2; i++) {
        string checkS = S.substr(i, 3);
        int checkI = stoi(checkS);
        int compare = abs(753 - checkI);
        if (result > compare) {
            result = compare;
        }
        // cout << checkI << " " << result << "\n";
    }
    cout << result;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7;//998244353 ;

int main(){
  int n;
  cin >> n;
  ll a[n],b[2*n];
  rep(i,n){
    cin >> a[i];
    b[2*i]=a[i];
    b[2*i+1]=a[i];
  }
  sort(b,b+2*n,greater<ll>());
  ll ans=b[0];
  int cnt=0;
  for(int i=0;i<n-2;i++){
    ans+=b[i+2];
    cnt++;
  }
  cout << ans << endl;
return 0;}

Measured memory_bytes: 8316
#include<stdio.h>
#include<math.h>
int main(){
  int D,N;
  scanf("%d %d",&D,&N);
  if(N!=100) printf("%d\n",(int)pow(100,D) * N);
  else printf("%d\n",(int)pow(100,D) * 101);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
using namespace __gnu_pbds;
using namespace std;
typedef tree<
    pair<int, int>,
    null_type,
    less_equal<pair<int, int>>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;
#define int long long
#define double long double
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define lb(v, z) lower_bound(all(v), z)
#define ub(v, z) upper_bound(all(v), z)
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define rdp(i, a, b) for (int i = (a); i >= (b); i--)
#define rlt(i, a, b) for (int i = (a); i < (b); i++)
#define cns(z) cout << (z) << ' '
#define cnl(z) cout << (z) << '\n'
#define M1 1000000007
#define M2 998244353
#define MAXN 300005
#define INF (1ll << 60)
#define endl "\n"
#define garr(ip)       \
    for (auto &x : ip) \
        cin >> x;
#define parr(ip)          \
    for (auto &x : ip)    \
        cout << x << " "; \
    cout << endl;
#define nl cout << endl
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int>> vp;

void solve(int testCaseNumber = 1)
{
    int animals, legs;
    cin >> animals >> legs;
    legs -= (animals + animals);
    if (legs >= 0 and legs <= (animals + animals) and legs % 2 == 0)
        cnl("Yes");
    else
        cnl("No");
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
}

Measured memory_bytes: 3616
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 110
using namespace std;
int n,cnt,a,b;
int m[MAXN][MAXN],las;
int flag,sum;
void print(){
    PF("%d %d\n",sum,100);
    for(int i=1;i<=sum;i++){
        for(int j=1;j<=100;j++){
            if(m[i][j]==1)
                PF("#");
            else
                PF(".");
        }
        PF("\n");
    }
}
int main(){
    //freopen("1.txt","w",stdout);
    SF("%d%d",&a,&b);
    if(a>b)
        flag=1;
    else
        flag=0;
    if(a<b)
        swap(a,b);
    if(a>b){
        b--;
        for(int i=1;a>b;i+=2){
            for(int j=1;j<=100;j++){
                if(j%2==1&&a>b){
                    m[i][j]=1-flag;
                    a--;
                }
                else
                    m[i][j]=flag;
            }
            for(int j=1;j<=100;j++)
                m[i+1][j]=flag;
            cnt=i+1;
        }
    }
    sum=cnt;
    for(int i=cnt+1;a;i+=4){
        a--;
        b--;
        if(a==0&&b==0){
            for(int j=1;j<=100;j++){
                m[i][j]=1-flag;
                m[i+1][j]=flag;
            }
            sum=i+1;
            break;
        }
        for(int j=1;j<=100;j++)
            m[i][j]=1-flag;
        for(int j=1;j<=100;j++)
            m[i+3][j]=flag;
        for(int j=1;j<=100;j++){
            if(a){
                if(j%2){
                    m[i+1][j]=1-m[i][j];
                    a--;
                }
                else
                    m[i+1][j]=m[i][j];
            }
            else
                m[i+1][j]=m[i+1][j-1];
        }
        for(int j=1;j<=100;j++)
            m[i+2][j]=1-m[i+1][j];
        sum=i+3;
    }
    print();
}


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    double a,b,x;
    cin>>a>>b>>x;
    cout<<fixed<<setprecision(10);
    double ans;
    if(a*a*b/2>=x)ans=atan((a*b*b)/(2*x))*(180/3.1415926535897932);
    else ans=90-atan((a*a*a)/(2*(a*a*b-x)))*(180/3.1415926535897932);
    cout<<ans<<endl;
}


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

int main() {
    vector<string> s(3);
    vector<int> i(3), len(3);
    for (int i = 0; i < 3; i++) {
        cin >> s.at(i);
        len.at(i) = (int)s.at(i).size();
    }
    
    int p = 0;
    while (i.at(p) < len.at(p)) {
        p = s.at(p).at(i.at(p)++) - 'a';
    }
    cout << (char)('A' + p) << endl;
}   

Measured memory_bytes: 256
import re
text = input()
for i in list('abcdefghijklmnopqrstuvwxyz'):
    match_object = re.search(r'{0}.?{0}'.format(i), text)
    if match_object:
        print(str(match_object.start() + 1) + ' ' + str(match_object.end()))
        exit()
print('-1 -1')

Measured memory_bytes: 9880
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

// 重複した要素を削除してソートをする。
template<typename T>
void unique_sort(std::vector<T>& vec) {
    std::sort(vec.begin(), vec.end());
    vec.erase(std::unique(vec.begin(), vec.end()), vec.end());
}

// n*n <= xを満たす最大のnを返す。
// sqrt(x)をintでキャストした時に、まるめ誤差によって小さくなることが
int64_t sqrt_int(int64_t x) {
    assert(0 <= x);
    if (x <= 1) { return x; }
    int128_t ret = std::sqrt(x);
    assert(ret * ret <= x);
    assert(x < (ret + 2) * (ret + 2));
    return ((ret + 1) * (ret + 1) <= x) ? ret + 1 : ret;
}

const int MAX_K = 150;
int64_t N, K;
const int MOD = 1e9 + 7;

std::vector<int> largest;
std::unordered_map<int, int> mp;

std::vector<int128_t> dp[MAX_K], dp_sum[MAX_K];

int main(int argc, char **argv) {
    std::cin >> N >> K;

    largest.push_back(0);
    for (int64_t i = 1; i * i <= N; i++) {
        largest.push_back(i);
        largest.push_back(N/i);
    }
    unique_sort(largest);
    const int S = largest.size();
    for (int i = 0; i < S; i++) {
        mp[largest[i]] = i;
        //std::cout << largest[i] << " ";
    }
    //std::cout << std::endl;

    dp[0].resize(S, 0);
    dp[0][1] = 1;
    dp_sum[0].resize(S, 1);
    dp_sum[0][0] = 0;
    for (int i = 1; i <= K; i++) {
        dp[i].resize(S, 0);
        dp_sum[i].resize(S, 0);
        for (int j = 1; j < S; j++) {
            int ns = mp[N/largest[j]];
            dp[i][j] = dp_sum[i-1][ns] * (largest[j] - largest[j-1]);
            dp[i][j] %= MOD;
            dp_sum[i][j] = dp_sum[i][j-1] + dp[i][j];
            dp_sum[i][j] %= MOD;
            //std::cout << i << " " << j << " " << ns << " " << dp[i][j] << " " << dp_sum[i][j] << std::endl;
        }
    }

    std::cout << dp_sum[K][S-1] << std::endl;

    return 0;
}

Measured memory_bytes: 204064
#include "stdio.h"
#include "string.h"
 
int main(){
        char str[21];
        int i=0;
        int flag=0;
 
        memset(str,'0',21);
 
        fgets(str,sizeof(str),stdin);
 
        for(i=20,flag=0;i>=0;i--){
                if(str[i]==0){
                        flag++;
                }else if(flag==1 && str[i]!=10){
                        printf("%c",str[i]);
                }
        }
        printf("\n");
        return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
#define rep(i,a,b) for(register int i=a;i<=b;++i)
#define rpd(i,a,b) for(register int i=a;i>=b;--i)
#define rep1(i,x) for(register int i=head[x];i;i=nxt[i])
typedef long long ll;
//const int N=+5;
using namespace std;
inline int read(){
    int x=0,f=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=-1;ch=getchar();}
    while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
ll ans;int N,K;
ll cal(int x){return 1LL*x*x*x;}
int main(){
	N=read();K=read();ans+=cal(N/K);
	if(K%2==0)ans+=cal((N+K/2)/K);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int a,b,c,d,l,sansuu = 0,kokugo = 0;
    cin >> l >> a >> b >> c >> d ;
    
    if(a % c == 0){
        kokugo = a/c;
    }
    else{
        kokugo = a/c+1;
    }
    
    if(b % d == 0){
        sansuu = b/d;
    }
    else{
        sansuu = b/d+1;
    }
    
    cout << l-max(kokugo,sansuu) << endl;
    
    
    return 0;
}


Measured memory_bytes: 3064
s = int(input())

x1 = 10 ** 9
y1 = 1
if s % x1 == 0:
    y2 = s // x1
else:
    y2 = s // x1 + 1
x2 = x1 * y2 - s

print(x1,y1,x2,y2,0,0)


Measured memory_bytes: 2940
/* -------------------------------- Template -------------------------------- */

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

// template<typename T> constexpr T inf = [](){ assert(false); };
// template<> constexpr int inf<int> = 1e9;
// template<> constexpr ll inf<ll> = 1e18;
// template<> constexpr ld inf<ld> = 1e30;

struct yes_no : std::numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve();

int main() {
  std::locale loc(std::locale(), new yes_no);
  std::cout << std::boolalpha << std::setprecision(12) << std::fixed;
  std::cout.imbue(loc);
  solve();
  return 0;
}

using namespace std;

/* -------------------------------- Library -------------------------------- */

/* ---------------------------------- Main ---------------------------------- */

vector<int> g[128000];
bool visited[128000];

pair<int,int> dp(int v) {
  visited[v] = true;
  int path = 0, res = 0;
  vector<int> ps;
  for (int i: g[v]) {
    if (visited[i]) continue;
    int p, r;
    tie(p, r) = dp(i);
    chmax(path, p);
    chmax(res, r);
    ps.push_back(p);
  }
  sort(ps.rbegin(), ps.rend());
  if (ps.size() >= 1) chmax(res, ps[0]);
  if (ps.size() >= 2) chmax(res, ps[0] + ps[1] + (g[v].size() == 2));
  if (g[v].size() == 2) path++;
  return make_pair(path, res);
}

void solve() {
  int N;
  cin >> N;
  REP(i,N-1) {
    int a, b;
    cin >> a >> b;
    g[a-1].push_back(b-1);
    g[b-1].push_back(a-1);
  }
  int res = dp(0).second;
  REP(i,N) res += (g[i].size() == 1);
  cout << res << endl;
  return;
}


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

#include <algorithm>

int main(int argc, char const *argv[]) {
  int a, b, c;
  cin >> a >> b >> c;
  if (b - a == c - b)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#include <cmath>

using namespace std;

int func(int p){
	int count = 0;
	while(true){
		if(p%2==0){
			p = p / 2;
			count++;
		}else{
			break;
		}
	}
	return count;
}

int main(void){
	int n; int sum = 0;
	cin >> n;
	vector<int> arr(n);
	for(int i=0;i<n;i++){
		cin >> arr[i];
		sum += func(arr[i]);
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 888
n = int(input())
arr = list(map(int,input().split()))

temp = 0
ans = 0
now = arr[0]
for i in range(1,n):
    if arr[i] <= now:
        temp += 1
        now = arr[i]
    else:
        if temp > ans:
            ans = temp
        temp = 0
        now = arr[i]

if temp > ans:
    ans = temp

print(ans)

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

namespace ABC128D
{
    class Program
    {

        static void Main(string[] args)
        {
            var nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
            var n = nums[0];
            var k = nums[1];

            var q = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();
            var qr = q.AsEnumerable().Reverse().ToList();

            var opc = Math.Min(n, k) + 1;
            var maxValue = int.MinValue;
            foreach (var i in Enumerable.Range(0, opc))
            {
                foreach (var j in Enumerable.Range(0, opc - i))
                {
                    var list = new List<int>();
                    list.AddRange(q.Take(i));
                    list.AddRange(qr.Take(j));
                    var plus = list.Where(x => x >= 0);
                    var minus = list.Where(x => x < 0).OrderBy(x => x);

                    // 捨ててよいカウント
                    var dc = k - (i + j);

                    var result = plus.Sum() + minus.Skip(dc).Sum();
                    if (result > maxValue) maxValue = result;
                }
            }

            Console.WriteLine(maxValue);
        }
    }
}


Measured memory_bytes: 15572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
#define REP3(i,x,n) for(ll i=x; i>(n); i--)
#define ALL(n) begin(n),end(n)
#define MAX 500000
#define SENTINEL 2000000000
#define NIL -1
static const int N=100;
static const int INFTY = (1<<21);
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int n,M[N][N];
int d[N];//訪問状態の管理


void bfs(int s){
    queue<ll>q;
    q.push(s);
    for(int i = 0;i<n;i++){
        d[i] = INFTY;
    }
    d[s]=0;
    int u;
    while (!q.empty())
    {
        u=q.front();q.pop();
        for(int v = 0;v < n;v++){
            if(M[u][v]==0)continue;
            if(d[v]!=INFTY)continue;
            d[v]=d[u]+1;
            q.push(v);
        }
    }
    for(int i = 0;i<n;i++){
        cout << i + 1 << " " << ((d[i]==INFTY)?(-1):d[i]) << endl;
    }
    

}

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



Measured memory_bytes: 3268
import scala.io.StdIn.{readInt,readLine}
import scala.collection.mutable.ArrayBuffer

object Main {
  def main(args:Array[String]) = {
    var n = 0
    while( {n=readInt;n} != 0 ) {
      val l = new ArrayBuffer[Array[Int]]
      val sum = new Array[Int](n+1)
      for(i<-1 to n) {
        val s = readLine.split(" ").map(_.toInt)
        l += s :+ s.sum
        (0 until n).foreach ( i => sum(i) += s(i) )
      }
      sum(n) = l.toArray.map(e=>e(n)).sum
      println(l.toArray.map(_.map("%5d".format(_)).mkString).mkString("\n"))
      println(sum.map("%5d".format(_)).mkString)
    }
  }
}

Measured memory_bytes: 47796
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func main() {
	sc.Split(bufio.ScanWords)

	H, W := getInt(), getInt()
	var c [10][10]int
	for i := 0; i < 10; i++ {
		for j := 0; j < 10; j++ {
			c[i][j] = getInt()
		}
	}
	a := make(map[int]int)
	for i := 0; i < H; i++ {
		for j := 0; j < W; j++ {
			x := getInt()
			a[x]++
		}
	}

	for k := 0; k < 10; k++ {
		for i := 0; i < 10; i++ {
			for j := 0; j < 10; j++ {
				c[i][j] = min(c[i][j], c[i][k]+c[k][j])
			}
		}
	}

	ans := 0
	for i, n := range a {
		if i == -1 {
			continue
		}
		cost := c[i][1]
		ans += cost * n
	}

	out(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}

int D;
int N = 26;
vi c;
vvi s;
vi t;
vi las;

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

    cin >> D;
    c.resize(N);
    in(N,c);
    s.resize(D,vi(N));
    rep(i,D) rep(j,N) cin >> s[i][j];
    t.resize(D);
    in(D,t);
    rep(i,D) t[i]--;
    las.assign(N,-1);
    
    vi ans(D+1,0);
    
    rep(d,D){
        ans[d+1] = ans[d];
        las[t[d]] = d;
        ans[d+1] += s[d][t[d]];
        rep(i,N) ans[d+1] -= c[i]*(d-las[i]);
        
    }
    
    rep(i,si(ans)-1) cout << ans[i+1] << endl;
    
    
    

    return 0;
}


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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)
// ----------------------------------------------------------------------

// ----------------------------------------------------------------------
int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int N; cin >> N;
  vector<ll> A(N), B(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  for (int i = 0; i < N; i++) cin >> B.at(i);
  ll sumA = 0;
  ll sumB = 0;
  for (int i = 0; i < N; i++) {
    sumA += A.at(i);
    sumB += B.at(i);
  }
  ll diff = sumB - sumA;
  if (diff < 0) {
    cout << "No\n";
    return 0;
  }
  ll cnt = 0;
  for (int i = 0; i < N; i++) {
    ll x = B.at(i) - A.at(i);
    if (x <= 0) continue;
    cnt += (x + 1) / 2;
  }
  if (cnt <= diff) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}



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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
template< typename T > void modAdd(T& a, T b, T m) { a = (a+b+m)%m; }
typedef long long lint;

int N, X, Y, Z;
lint dp[41][1<<18];
const lint MOD = (lint)1e9 + 7;

int main() {
	cin >> N >> X >> Y >> Z;
	
	int MASK = (1 << (X+Y+Z+1)) - 1, valid = (1 << Z) | (1 << (Y+Z)) | (1 << (X+Y+Z));
	
	memset(dp, 0, sizeof(dp));
	dp[0][1] = 1;
	
	for_(i,0,N) for_(S,0,MASK+1) {
		for_(x,1,11) {
			int nxt = ((S << x) | 1) & MASK;
			if ((nxt & valid) == valid) continue;
			modAdd(dp[i+1][nxt], dp[i][S], MOD);
		}
	}
	
	lint ans = 1;
	for_(i,0,N) ans *= 10, ans %= MOD;
	for_(S,0,MASK) modAdd(ans, -dp[N][S], MOD);
	cout << ans << endl;
}

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

// #define REP(i, x) REPI(i, 0, x)
// #define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
// #define ALL(x) (x).begin(), (x).end()

// typedef long long ll;
// using namespace std;

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

//   int H, W;
//   cin >> H >> W;

//   vector<vector<bool>> visit(H + 1);
//   REP(i, H + 1) {
//     REP(j, W + 1) { visit.at(i).push_back(false); }
//   }

//   visit.at(1).at(1) = true;
//   ll ans = 1ll;

//   queue<pair<int, int>> q;
//   q.push(make_pair(1, 1));

//   vector<int> x = {-1, 1};
//   vector<int> y = {-1, 1};

//   while (!q.empty()) {
//     auto v = q.front();
//     q.pop();

//     REP(i, 2) {
//       REP(j, 2) {
//         if (1 <= v.first + x.at(i) && v.first + x.at(i) <= W &&
//             1 <= v.second + y.at(j) && v.second + y.at(j) <= H &&
//             ((v.first + v.second == v.first + x.at(i) + v.second + y.at(j))
//             ||
//              (v.first - v.second ==
//               v.first + x.at(i) - (v.second + y.at(j))))) {
//           if (!visit.at(v.second + y.at(j)).at(v.first + x.at(i))) {
//             ++ans;
//             visit.at(v.second + y.at(j)).at(v.first + x.at(i)) = true;
//             q.push(make_pair(v.first + x.at(i), v.second + y.at(j)));
//           }
//         }
//       }
//     }
//   }

//   cout << ans << endl;

//   return 0;
// }

#include <bits/stdc++.h>

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  ll H, W;
  cin >> H >> W;

  ll ans = 0ll;
  if (H == 1 || W == 1) {
    cout << 1 << endl;
    return 0;
  }

  if (H % 2 == 0) {
    if (W % 2 == 0) {
      ans = H * W / 2;
    } else {
      ans = H * (W - 1) / 2 + ceil(H / 2.0);
    }
  } else {
    ans = (H - 1) * (W - 1) / 2 + ceil(H / 2.0) + ceil(W / 2.0) - 1;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class B
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		int N = GetInt();
		string S = GetString();
		int cnt = 0;
		for(int i = 0; i < N - 2; i++)
			if(S.Substring(i, 3).Equals("ABC"))
				cnt++;

		WriteLine(cnt);
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 13140
import sys
from collections import Counter

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    A.sort(reverse=True)

    i = 0
    w = h = 0
    while i < N - 1:
        if A[i] == A[i + 1]:
            if w == 0:
                w = A[i]
            else:
                h = A[i]
                break
            i += 2
        else:
            i += 1

    print(w * h)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 20696
n=int(input())
lst=list(map(int,input().split()))
m1=0
for i in range(n):
    if i%2==0:
        m1+=lst[i]
    else:
        m1-=lst[i]
ans=[m1]
for i in range(n-1):
    tmp=lst[i]
    tmp-=ans[-1]//2
    ans.append(tmp*2)
print(*ans)

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

using namespace std;

int main(){
    string s;
    int f, e;

    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'A'){
            f = i;
            break;
        }
    }
    for(int i = 0; i < s.size(); i++){
        if(s[s.size() - i - 1] == 'Z'){
            e = s.size() - i - 1;
            break;
        }
    }

    cout << e - f + 1;

    return 0;
}



Measured memory_bytes: 640
while 1:
    try:
        ds = map(int, raw_input().split(','))
        d = [sum(ds[:i + 1]) for i in xrange(10)]
        t = sum(ds[:10]) / float(ds[10] + ds[11])
        s = ds[10] * t
        for i, j in enumerate(d):
            if j >= s:
                print i + 1
                break
    except:
        break

Measured memory_bytes: 6344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    ll S;
    cin >> S;
    ll X1, X2, X3, Y1, Y2, Y3;
    X1 = 0;
    Y1 = 0;
    X2 = 1000000000;
    Y3 = (S-1)/1000000000 + 1;
    if(S % 1000000000 == 0){
        Y2 = 0;
        X3 = 0;
    }
    else{
        Y2 = 1;
        X3 = X2 * Y3 - S;
    }
    printf("%lld %lld %lld %lld %lld %lld\n", X1, Y1, X2, Y2, X3, Y3);

}

Measured memory_bytes: 3716
#include <iostream>

using namespace std;

typedef long long ll;

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

ll f(ll x, int c, int d) {
    ll res = x;
    res -= x / c;
    res -= x / d;
    res += x / lcm(c, d);
    return res;
}


int main() {
    ll A, B, C, D;
    cin >> A >> B >> C >> D;
    ll ans = f(B, C, D) - f(A-1, C, D);
    cout << ans << endl;
}
/**
 * a 以上 b 以下は
 * b 以下 - (a-1)以下
 * x 以下で a で割り切れる個数は
 * x / a で求まる
 * 
 * 最小公倍数 LCM(a, b) = a * b / gcd(a, b)
 * 割り切れるものを全体から引く
 * ベン図を書くとわかりやすい
 */

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

int main() {
    int R;
    cin >> R;
    if (R < 1200) {
        cout << "ABC" << endl;
    } else if (R < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
    return 0;
}

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

int main() {
	int N, M, Q;
	cin >> N >> M >> Q;
	int L, R;
	int nijigen[501][501] = {};
	repeat(i, M) {
		cin >> L >> R;
		nijigen[L][R] += 1;
	}
	int ruikei[502][502] = {};
	repeat(i, N) {
		repeat(ii, N) {
			ruikei[i + 1][ii + 1] = ruikei[i + 1][ii] + nijigen[i + 1][ii + 1];
		}
	}
	repeat(ii, N) {
		repeat(i, N) {
			ruikei[N - i][ii + 1] = ruikei[N - i + 1][ii + 1] + ruikei[N - i][ii + 1];
		}
	}
	int p, q;
	repeat(i, Q) {
		cin >> p >> q;
		cout << ruikei[p][q] << "\n";
	}
	Would you return 0;
}

Measured memory_bytes: 2944
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=2000;
long long dp[100][500*500+1];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    int sum=0;
    dp[0][0]=1;
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        sum+=x;
        for(int j=i;j>=1;j--)
        {
            for(int s=sum;s>=x;s--)
                dp[j][s]+=dp[j-1][s-x];
        }
    }
    long long ans=0;
    for(int i=1;i<=n;i++)
        ans+=dp[i][i*k];
    printf("%lld\n",ans);
}


Measured memory_bytes: 96512
import java.util.*;

public class Main{
	
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt(),k=sc.nextInt(),f=0;
    while(f<k){
      if(b<=a){
        b*=2;
        f++;
      }else if(c<=b){
        c*=2;
        f++;
      }else{
        break;
      }
    }
    if(f<k||(b>a&&c>b)){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Paste snippets here!!

//

void solve(long long N, long long K, std::vector<long long> p) {
  vector<__float128> E(N);
  rep(i,N){
    E[i] = (p[i]+1) / 2.0 ;
  }
  //vector<double> cum(N+1);
  vector<__float128> cum(N+1);
  cum[0] = 0.0;
  rep(i,N){
    cum[i+1] = E[i] + cum[i];
  }

  double ret = 0;
  for(int i=0;i<N-K+1;++i){
    if(ret<cum[i+K]-cum[i]) ret = cum[i+K]-cum[i];
  }
  cout << setprecision(12) << ret << endl;

}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  long long N;
  std::cin >> N;
  long long K;
  std::cin >> K;
  std::vector<long long> p(N);
  for (int i = 0; i < N; i++) {
    std::cin >> p[i];
  }
  solve(N, K, std::move(p));
  return 0;
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
//#include<iostream>
using namespace std;

int n,k;
#define maxn 200011
int a[maxn],cnt[maxn];
int main()
{
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),cnt[a[i]]++;
	sort(cnt+1,cnt+1+n);
	int i=1;while (cnt[i]==0) i++;
	if (n-i+1<=k) {puts("0");return 0;}
	int ans=0;
	for (;i<=n-k;i++) ans+=cnt[i];
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1664
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	string s;
	cin >> s;
	cout << s[0] << s.size() - 2 << *--s.end() << endl;

	return 0;
}

Measured memory_bytes: 256
def binary():
    # データを格納
    n = int(input())
    s = list(map(int, input().split()))
    q = int(input())
    t = list(map(int, input().split()))

    # 二分探索法
    count = 0
    for i in range(q):
        left = 0
        right = n - 1
        while left <= right:
            mid = (left + right) // 2
            if s[mid] == t[i]:
                count += 1
                break
            elif s[mid] > t[i]:
                right = mid - 1
            else:
                left = mid + 1
    print(count)

if __name__ == "__main__":
    binary()



Measured memory_bytes: 16712
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  int n,m,x;cin>>n>>m>>x;
  vector<int> C(n);
  vector<vector<int>> A(n);
  rep(i,n){
    cin>>C[i];
    A[i] = vector<int>(m);
    rep(j,m){
      cin>>A[i][j];
    }
  }

  int ans = INF;
  rep(bit, 1 << n){
    bitset<12> bs(bit);
    vector<int> rikaido(m, 0);
    int cost = 0;
    rep(i,n){
      if(!bs[i]) continue;
      cost += C[i];
      rep(j,m){
        rikaido[j] += A[i][j];
      }
    }
    bool ok = true;
    rep(j,m){
      if(rikaido[j] < x){
        ok = false;
        break;
      }
    }
    if(!ok) continue;
    ans = min(ans, cost);
  }

  if(ans == INF){
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

bool isMM(const string& str) {
    if('0' == str[0]) {
        if( '1' <= str[1] && str[1] <= '9') {
            return true; // 01 - 09
        }
    } else if('1' == str[0]) {
        if( '0' <= str[1] && str[1] <= '2') {
            return true; // 10-12
        }
    }
    return false;
}

bool isYY(const string& str) {
    if( '0' <= str[0] && str[0] <= '9') {
        if( '0' <= str[1] && str[1] <= '9') {
            return true;// 00-99
        }
    }
    return false;
}

int main(int argc, const char * argv[]) {
    string S;
    cin >> S;
    
    const string first = S.substr(0, 2);
    const string second = S.substr(2, 2);
    
    if(!isYY(first) || !isYY(second)) {
        cout << "NA" << endl;
        return 0;
    }
    
    if(isMM(first)) {
        if(isMM(second)) {
            cout << "AMBIGUOUS" << endl;
        } else {
            cout << "MMYY" << endl;
        }
    } else {
        if(isMM(second)) {
            cout << "YYMM" << endl;
        } else {
            cout << "NA" << endl;
        }
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
int main()
{
	std::string a,b,c;
	std::cin >> a;
	std::cin >> b;
	std::cin >> c;

	if(a.back()==b.front() && b.back() == c.front()){
		std::cout << "YES" << std::endl;
	}else{
		std::cout << "NO" << std::endl;
	}
}

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

int main(){
    char s[11], ans[11] = "";
    scanf("%s", s);

    for(int i = 0; s[i] != '\0'; i++){
        switch(s[i]){
            case '0':
                sprintf(ans, "%s0", ans);
                break;
            case '1':
                sprintf(ans, "%s1", ans);
                break;
            case 'B':
                if(i > 0) ans[strlen(ans) - 1] = '\0';
                break;
        }
    }
    printf("%s\n", ans);
    return 0;
}

Measured memory_bytes: 128
n, k = map(int, input().strip().split())
p = list(map(int, input().strip().split()))

e = []

for i in range(n):
  a = p[i] * (p[i] + 1) / 2
  e.append(a/p[i])

ans = sum(e[0:k])
s = ans

for i in range(k,n):
  aaa = s + e[i] - e[i-k]
  if ans < aaa:
    ans = aaa
  s = aaa
print(ans)

Measured memory_bytes: 25060
#include <stdio.h>
long long a [100010];
int main ()
{
int n;
scanf("%d",&n);
for(int i=0;i<n;i++) scanf("%lld",&a[i]);
int zero =0;
for(int i=0;i<n;i++)
  if(a[i]==0)
  	zero++;
if(zero >0)
{
printf("0\n");
return 0;
}
long long prod =1;
for(int i=0;i<n;i++){
if(a[i ] <=1000000000000000000/ prod )
{
prod *=a[i];
}else{
printf("-1\n");
return 0;
}
}
printf("%lld\n",prod );
}


Measured memory_bytes: 2480
a, b, h, m = list(map(int, input().split()))
import numpy as np

h_a = np.pi*(h+m/60)/6
m_a = np.pi*m/30

s = abs(h_a-m_a)

print(np.sqrt(a**2 + b**2 -2*a*b*np.cos(s)))

Measured memory_bytes: 27132
a = []
a = input().split()
H = int(a[0])
N = int(a[1])
A = input().split()
A = [int(i) for i in A]

#print('H=', H, 'N=', N)
#print('A=', A)

#for i in range(N):
#  n = A.index(max(A))
#  print('n=', n)
#  H = H - max(A)
#  A.remove(A[n])
#  print('A=', A)

T = sum(A)
H = H - T


if H <= 0:
  print('Yes')
if H > 0:
  print('No')



Measured memory_bytes: 14016
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define db long double
  #define PB push_back
  int32_t main()
  {         
    
    
    IOS
   
    map<char,int> mp;
    string s;
    cin>>s;
    
    for(int i=0;i<s.length();i++)
    {
        mp[s[i]]++;
        
    }
    
    if(mp.size()==2)
    {
        for(auto i:mp)
        {
            if(i.second !=2)
            {
                cout<<"No";
                return 0;
            }
        }
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
        return 0;
    }
    
    
    return 0;
  }           

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=2050;
//ここまでテンプレ
int main(){
	int N,X,Y,Z;
	cin>>N>>X>>Y>>Z;
	//DP[見ている文字][直前の状態]=その状態になる数列の数
	ll DP[41][1<<17]={};
	DP[0][0]=1;
	for(int i=0;i<N;i++){
		for(int j=0;j<(1<<17);j++){
			//1から10までの数列で、入れてもいいものを探す
			for(int k=1;k<=10;k++){
				//cout<<DP[i][j]<<endl;
				//X+Y+Z-k-1bit目、Y+Z-k-1bit目、Z-k-1bit目がすべて1になっているなら、kを入れてはいけない
				if(Z!=k && j&(1<<(X+Y+Z-k-1)) && j&(1<<(Y+Z-k-1)) && j&(1<<(Z-k-1)))
					continue;
				//Z==kのときは、Z-k-1bit目が立っている必要はない
				if(Z==k && j&(1<<(X+Y+Z-k-1)) && j&(1<<(Y+Z-k-1)))
					continue;
				//そうでないなら、kを入れてもいいので入れる
				int temp=(j<<k)|(1<<k-1);
				//16bit目までを取り出す
				int next=0;
				for(int l=0;l<17;l++)
					if(temp&(1<<l))
						next|=(1<<l);
				DP[i+1][next]+=DP[i][j];
				DP[i+1][next]%=MOD;
			}
		}
	}
	ll ans=0;
	for(int i=0;i<(1<<17);i++){
		ans+=DP[N][i];
		ans%=MOD;
	}
	ll ALL=1;
	for(int i=0;i<N;i++){
		ALL*=10;
		ALL%=MOD;
	}
	cout<<(ALL+MOD-ans)%MOD<<endl;
	return 0;
}

Measured memory_bytes: 42240