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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------

//main
//------------------------------------------
signed main(){
  int H, W;
  cin >> H >> W;
  VS s(H);
  REP(i, H) cin >> s[i];
  VVI cnt(H, VI(W));

  //行に関する点灯をカウント
  REP(i, H){//i行目について見ていく
    VI done(W);
    REP(j, W){//j列目について
      if(s[i][j] == '#') continue;
      if(done[j]) continue;
      int l = 0;
      while(j+l < W){//次の障害物まで長さを測る
        if(s[i][j+l]=='#') break;
        l++;
      }
      REP(k, l){
        cnt[i][j+k] += l;
        done[j+k] = 1;
      }
    }
  }

  //列に関する点灯をカウント
  REP(j, W){//j列目について見ていく
    VI done(H);
    REP(i, H){//i行目について
      if(s[i][j] == '#') continue;
      if(done[i]) continue;
      int l = 0;
      while(i+l < H){//次の障害物まで長さを測る
        if(s[i+l][j]=='#') break;
        l++;
      }
      REP(k, l){
        cnt[i+k][j] += l;
        done[i+k] = 1;
      }
    }
  }

  int ans = 0;
   REP(i, H){
     REP(j, W){
       ans = max(ans, cnt[i][j]-1);
     }
   }

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


Measured memory_bytes: 35712
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;
using ull = unsigned long long;

ull nc2(ull n) {
 return n * (n - 1) / 2;
}

int main(int argc, const char *argv[])
{
  int size;
  cin >> size;
  vector<int> a(size);
  vector<int> cnts(size + 1, 0);
  for (auto &n : a) {
    cin >> n;
    cnts[n]++;
  }

  ull sum = accumulate(cnts.begin(), cnts.end(), 0ull,
      [] (ull acc, ull n) { return acc + nc2(n); });
  for (auto n : a) {
    cout << sum - nc2(cnts[n]) + nc2(cnts[n] - 1) << "\n";
  }

  return 0;
}


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
int mod;
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
void solve() {
	string s;
	cin >> s;
	cout << s.substr(0, 3) << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}







Measured memory_bytes: 3656
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();
      if (x>=400 && x<=599)
      {
        System.out.println(8);
      }
      if (x>=600 && x<=799)
      {
        System.out.println(7);
      }if (x>=800 && x<=999)
      {
        System.out.println(6);
      }if (x>=1000 && x<=1199)
      {
        System.out.println(5);
      }if (x>=1200 && x<=1399)
      {
        System.out.println(4);
      }
      if (x>=1400 && x<=1599)
      {
        System.out.println(3);
      }
      if (x>=1600 && x<=1799)
      {
        System.out.println(2);
      }
      if (x>=1800 && x<=1999)
      {
        System.out.println(1);
      }
      
      
      
    }
}

Measured memory_bytes: 35696
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9+7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;


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

struct Edge {
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}

void Dijkstra(Graph& G, ll s, Array& d) {//O(|E|log|V|)
	d.resize(G.size());
	REP(i, d.size())d[i] = INF;
	d[s] = 0;
	priority_queue<P, vector<P>, greater<P>> q;
	q.push(make_pair(0, s));
	while (!q.empty()) {
		P a = q.top();
		q.pop();
		if (d[a.second] < a.first)continue;
		REP(i, G[a.second].size()) {
			Edge e = G[a.second][i];
			if (d[e.to] > d[a.second] + e.cap) {
				d[e.to] = d[a.second] + e.cap;
				q.push(make_pair(d[e.to], e.to));
			}
		}
	}
}

Graph map2graph(vector<string>& s) {
	ll h = s.size();
	ll w = s[0].size();
	Graph g(h * w);

	REP(i, h) {
		REP(j, w) {
			
			if (i + 1 < h) {
				if (s[i + 1][j] != s[i][j])add_edge(g, i * w + j, (i + 1) * w + j, 1, false, 0);
				else add_edge(g, i * w + j, (i + 1) * w + j, 0, false, 0);
			}

			if (j + 1 < w) {
				if (s[i][j + 1] != s[i][j])add_edge(g, i * w + j, i * w + j + 1, 1, false, 0);
				else add_edge(g, i * w + j, i * w + j + 1, 0, false, 0);
			}

		}
	}

	return g;

}

void solve() {
	ll h, w;
	cin >> h >> w;

	vector<string> s(h);
	REP(i, h) cin >> s[i];
	Graph g = map2graph(s);

	Array d;
	Dijkstra(g, 0, d);
	ll ans = d[h * w - 1];
	if (s[0][0] == '#') ans++;
	if (s[h - 1][w - 1] == '#') ans++;
	cout << ans/2 <<en;

}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


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

int main() {
  int X, Y;
  cin >> X >> Y;
  
  cout << X + Y/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <string>

using namespace std;
typedef pair<int, int> P;

#define pi 3.141592653589793)
#define mod 1000000007

#define MAX_N 100002

int N, A[MAX_N];
int sum;

void solve() {
    for(int i = 0; i <= N; i++) {
        sum += abs(A[i+1] - A[i]);
    }
    
    for(int i = 1; i <= N; i++) {
        int ans = sum + abs(A[i+1] - A[i-1]) - abs(A[i] - A[i-1]) - abs(A[i+1] - A[i]);
        cout << ans << endl;
        
    }
}

int main() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> A[i];
    solve();
    return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
typedef long long ll;


int main(void){
  int n,i,j,t,a[10005],u[10003][200]={},jmax[200]={};
  ll fac[200][22]={},inv[1000005];
  const int mod=1e9+7;
  vector<int> p,lp;
  set<int> ps;
  
  for (t=2;t<1000;t++){
    i=0;
    while (i<p.size() && t>=p[i]*p[i]){
      if (t%p[i]==0) break;
      i++;
    }
    if (i==p.size() || t<p[i]*p[i]) p.push_back(t);
  }
  
  for (i=0;i<p.size();i++){
    fac[i][0]=1;
    for (j=1;j<21;j++){
      fac[i][j]=fac[i][j-1]*p[i]%mod;
    }
  }
  
  inv[1]=1;
  for (i=2;i<1000000;i++){
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
  }
  
  cin >> n;
  for (i=0;i<n;i++){
    cin >> a[i];
    for (j=0;j<p.size();j++){
      while (a[i]%p[j]==0){
        u[i][j]++;
        a[i]/=p[j];
      }
      jmax[j]=max(jmax[j],u[i][j]);
      if (a[i]==1) break;
    }
    if (a[i]!=1 && ps.find(a[i])==ps.end()){
      lp.push_back(a[i]);
      ps.insert(a[i]);
    }
  }
  
  ll fm=1;
  for (i=0;i<ps.size();i++) fm=fm*lp[i]%mod;
  
  int ans=0;
  for (i=0;i<n;i++){
    ll r=fm;
    for (j=0;j<p.size();j++){
      r=r*fac[j][jmax[j]-u[i][j]]%mod;
    }
    if (a[i]!=1) r=r*inv[a[i]]%mod;
    ans=(ans+r)%mod;
  }
  
  cout << ans << endl;
  
  return 0;
}

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

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

    if(k % 2 == 0) cout << k/2 * k/2 << endl;
    if(k % 2 == 1) cout << (k+1)/2 * (k/2) << endl;
    return 0;
}

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

int main() {
    int X, N;
    cin >> X >> N;
    map<int, int> p;
    for (int i = 0; i < N; ++i) {
        int k;
        cin >> k;
        p[k] = 1;
    }
    for (int j = 0; j <= 100; ++j) {
        if (p[X - j] == 0) {
            cout << X - j << endl;
            return 0;
        }
        if (p[X + j] == 0) {
            cout << X + j << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

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

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll N;
const ll MAX_N = 100000;
ll A[MAX_N];

int main(){
  cin >> N;
  REP(i, N) cin >> A[i];
  ll B[N + 1];
  B[0] = 0;
  REP(i, N) {
    B[i + 1] = 2 * A[i] - B[i];
  }

  B[0] = (B[0] + B[N]) / 2;
  REP(i, N - 1) {
    B[i + 1] = 2 * A[i] - B[i];
  }
  REP(i, N) {
    cout << B[i];
    if(i != N - 1) cout << " ";
    else cout << endl;
  }


  return 0;
}


Measured memory_bytes: 2816
//go:generate echo "https://atcoder.jp/contests/dp/tasks/dp_c"
package main

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

type scanner struct{ *bufio.Scanner }

func newScanner(r io.Reader) *scanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	s.Buffer(nil, 100000000)
	return &scanner{s}
}

func (s *scanner) Int() int {
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	return n
}

func (s *scanner) IntSlice(l int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := range sl {
		sl[i] = s.Int()
	}
	return sl
}

func (s *scanner) IntSlice2(l, n int) []int {
	if l == 0 {
		return []int{}
	}
	sl := make([]int, l, l)
	for i := 0; i < n; i++ {
		sl[i] = s.Int()
	}
	return sl
}

func solve(n int, u [][]int) int {
	t := make([][]int, n+1, n+1)
	for i := range t {
		t[i] = make([]int, 3, 3)
	}
	for i := 0; i < n; i++ {
		for j := 0; j < 3; j++ {
			for k := 0; k < 3; k++ {
				if j == k {
					continue
				}
				if v := t[i][j] + u[i][k]; t[i+1][k] < v {
					t[i+1][k] = v
				}
			}
		}
	}
	max := math.MinInt64
	for _, v := range t[n] {
		if max < v {
			max = v
		}
	}
	return max
}

func main() {
	scan := newScanner(os.Stdin)
	n := scan.Int()
	u := make([][]int, n+1, n+1)
	for i := 0; i <= n; i++ {
		u[i] = []int{scan.Int(), scan.Int(), scan.Int()}
	}
	fmt.Println(solve(n, u))
}


Measured memory_bytes: 13704
#include <iostream>
#include <string>
using namespace std;
int main() {
	int w,h,x,y,r;
	cin >>w>>h>>x>>y>>r;
	if(x>=r&&y>=r&&(x+r)<=w&&(y+r)<=h){
		cout <<"Yes"<< endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3104
def san(x):
    y=q/2
    while True:
        y=y-(y**3-x)/(3*y**2)
        if abs(y**3-x)<0.00001*x:
            break
    print(f'{y:.6f}')
while True:
    q=int(input())
    if q==-1:
        break
    san(q)


Measured memory_bytes: 5676
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int op = 0b000;
  string s;
  cin >> s;
  int A, B, C, D;
  A = s[0] - '0';
  B = s[1] - '0';
  C = s[2] - '0';
  D = s[3] - '0';
  for(;op<=0b111;op++){
    int a,b,c,d;
    char ops[3] = {'+', '+', '+'};
    a = A; b=B; c=C;d=D;
    if(op%2==1) {d *= -1; ops[2] = '-';}
    if((op>>1)%2==1) {c *= -1; ops[1] = '-';}
    if((op>>2)%2==1) {b *= -1; ops[0] = '-';}
    if(a+b+c+d==7){
      cout << A << ops[0] << B << ops[1] << C << ops[2] << D << "=7" << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define inf1 LONGLONG_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define deb(x) cout<<#x<<"is "<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
vector<int>adj [T];
			/*brownsands IIITA*/

void solve()
{  int k,x;
   cin >>k >>x;
   if((k*500)>=x)
   cout<<"Yes";else cout<<"No";
}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
            //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
               }		
} 
               
			
 

				
		
		




Measured memory_bytes: 23680
#include <stdio.h>

int main(void)
{
	int a,i;
	scanf("%d",&a);
	for(i=1;i<=a;i++){
		if(i%3==0){
			printf(" %d",i);
		}else if(i%10==3 || (30<=i%100 && i%100<=39) || (300<=i%1000 && i%1000<=399) || (3000<=i%10000 && i%10000<=3999)){
			printf(" %d",i);
		}
	}
	printf("\n");
	return 0;
}


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

LL a[2 * mx5], fs[2 * mx5], bs[2 * mx5];

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

    for(int i = 1; i <= n; i++)
        cin >> a[i], bs[i] = a[i] + bs[i - 1];

    for(int i = n; i; i--)
        fs[i] = a[i] + fs[i + 1];

    LL ans = 1e18;
    for(int i = 1; i < n; i++)
        ans = min(ans, abs(bs[i] - fs[i + 1]));

    cout << ans << '\n';
    return 0;
}


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

const int INF=1e9;
int main() {
    int n,m,r;
    cin >> n >> m >> r;
    vector<vector<int>> G(n+1, vector<int>(n+1,INF));
    vector<int> R(r);
    for ( int i=0; i<r; i++ ) {
        cin >> R[i];
        // R[i]--;
    }
    for ( int i=0; i<=n; i++ ) G[i][i]=0;
    for ( int i=0; i<m; i++ ) {
        int a,b,c;
        cin >> a >> b >> c;
        // --a; --b;
        G[a][b]=c;
        G[b][a]=c;
    }
    for ( int k=1; k<=n; k++ ) 
        for ( int i=1; i<=n; i++ )
            for ( int j=1; j<=n; j++ )
                G[i][j]=min(G[i][j],G[i][k]+G[k][j]);

    vector<vector<int>> dp(1<<r, vector<int>(n+1,INF));
    // for ( int i=0; i<n; i++ ) dp[1<<i][i]=0;
    for ( int i=0; i<=n; i++ ) dp[0][i]=0;
    for ( int i=0; i<r; i++ ) dp[1<<i][R[i]]=0;
    for ( int mask=1; mask<(1<<r); mask++ ) {
        for ( int i=0; i<r; i++ ) {
            if ( mask>>i&1 ) {
                for ( int j=0; j<r; j++ ) {
                    dp[mask][R[i]]=min(dp[mask][R[i]],dp[mask^(1<<i)][R[j]]+G[R[j]][R[i]]);
                }                
            }
        }
    }
    int mi=INF;
    for ( int i=1; i<=n; i++ ) {
        mi=min(mi,dp[(1<<r)-1][i]);
    }
    cout << mi << '\n';
    return 0;
}


Measured memory_bytes: 640
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    # N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    A, B, M = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    a_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    b_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]
    grid = [[int(x) for x in sys.stdin.readline().split()]
            for _ in range(M)]  # int grid

    logger.debug('{}'.format([]))

    _min = min(a_list) + min(b_list)

    for x, y, c in grid:
        a = a_list[x - 1]
        b = b_list[y - 1]

        t = a + b - c
        if _min > t:
            _min = t

    print(_min)


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 3 1
3 3
3 3 3
1 2 1"""
        output = """5"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1 1 2
10
10
1 1 5
1 1 10"""
        output = """10"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """2 2 1
3 5
3 5
2 2 2"""
        output = """6"""
        self.assertIO(input, output)


Measured memory_bytes: 92832
<?php

//標準入力
class Scanner {
  private $arr = [];
  private $count = 0;
  private $pointer = 0;
  public function next() {
      if($this->pointer >= $this->count) {
          $str = trim(fgets(STDIN));
          $this->arr = explode(' ', $str);
          $this->count = count($this->arr);
          $this->pointer = 0;
      }
      $result = $this->arr[$this->pointer];
      $this->pointer++;
      return $result;
  }
  public function hasNext() {
      return $this->pointer < $this->count;
  }
  public function nextInt() {
      return (int)$this->next();
  }
  public function nextDouble() {
      return (double)$this->next();
  }
}

//標準出力
class out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}

/* 標準入力からの受取
$sc = new Scanner();

#数値(スペース区切り対応)
$n = $sc->nextInt();

#文字(スペース区切り対応)
$str = $sc->next();

#改行込みの文字列を配列に格納
$str=[];
$str[] = $sc->next();
$str[] = $sc->next();
var_dump($str);

*/



$sc = new Scanner();
$s = $sc->next();


$a = substr($s, 0, 2);
$b = substr($s, 2, 2);
$ans = "";


if($a === "00" || $b === "00"){
  $ans = "NA";
}

if ((int)$a > 0 and (int)$a <= 12){
  $a_MM = 1;
}elseif ((int)$a > 0 and (int)$a <= 99){
  $a_MM = 0;
}
if ((int)$b > 0 and (int)$b <= 12){
  $b_MM = 1;
}elseif ((int)$b > 0 and (int)$b <= 99){
  $b_MM = 0;
}

if($a_MM and $b_MM){
  $ans = "AMBIGUOUS";
}elseif($a_MM){
  $ans = "MMYY";
}elseif($b_MM){
  $ans = "YYMM";
}else{
  $ans = "NA";
}


echo $ans.PHP_EOL;

?>


Measured memory_bytes: 4728
#include <stdio.h>

int main(void)
{
	int n;
	int i;
	long beki;
	
	scanf("%d", &n);
	
	beki = 1;
	for (i = 1; i <= n; i++){
		beki *= i;
	}
	
	printf("%ld\n", beki);
	
	return (0);
}

Measured memory_bytes: 592
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int x;
  while(cin>>x,x) {
    int ans = 0;
    FOR(i,0,185) {
      FOR(j,i,185) {
        if(i * i + j * j > x) break;
        FOR(k,j,185) {
          if(i * i + j * j + k * k > x) break;
          FOR(l,k,185) {
            if(i * i + j * j + k * k + l * l > x) break;
            if(i * i + j * j + k * k + l * l == x) ans++;
          }
        }
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <functional>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second


int main() {
	ll n, a[300010], sum = 0, ma[300010] = { 0 }, ans = 0, s = 0;
	cin >> n;
	for (int i = 1;i <= 3 * n;i++)cin >> a[i];
	if (n == 1) {
		cout << max(a[1] - a[2], max(a[1] - a[3], a[2] - a[3])) << endl;
		return 0;
	}

	priority_queue<ll>p;
	for (int i = 3 * n;i > 2 * n;i--) {
		s += a[i];
		p.push(a[i]);
	}
	ma[2 * n + 1] = s;
	for (int i = 2 * n;i > n;i--) {
		s += a[i];
		p.push(a[i]);
		ll b = p.top();p.pop();
		s -= b;
		ma[i] = s;
	}

	priority_queue<ll, vector<ll>, greater<ll>>pq;
	for (int i = 1;i <= n;i++) {
		sum += a[i];
		pq.push(a[i]);
	}
	ans = sum - ma[n + 1];
	for (int i = n + 1;i <= 2 * n;i++) {
		sum += a[i];
		pq.push(a[i]);
		ll b = pq.top(); pq.pop();
		sum -= b;
		ans = max(ans, sum - ma[i + 1]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 7284
#include <iostream>

using namespace std;

int main()
{
    int n,m,cnt=0,sum=0;
    cin>>n>>m;
    float arr[n];

    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
        sum=sum+arr[i];
    }
    float c=(1.0/(4*m))*sum;
    for(int i=0;i<n;i++)
    {
        if(arr[i]>=c)
            cnt++;
    }
    if(cnt>=m)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

}


Measured memory_bytes: 256
import java.io.*;
import java.util.Scanner;

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

		    String str1 = scanner.next();
            String str2 = scanner.next();
            int A = Integer.parseInt(str1);
            int B = Integer.parseInt(str2);
            
            int num1 = A + B;
        	int num2 = A - B;
        	int num3 = A * B;
        	
        	if(num1 <= num2) {
        		if(num2 <= num3) {
        			System.out.println(num3);
        		} 
        		else {
        			System.out.println(num2);
        		}
        	}
        	else {
        		if(num3 <= num1) {
        			System.out.println(num1);
        		}
        		else {
        			System.out.println(num3);
        		}
        	}scanner.close();
		  }
        	
        	
        }


Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
	string s;
	cin >> s;
	int result = 0;
	for (char asdasd : s)
	{
		result += asdasd - 48;
	}
	if (result % 9 == 0)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int64_t> vec(N);
  for(int i=1; i<=N; i++){
    int temp = i;
    int j=2;
   while(j<=temp){
      if(temp %j == 0){
        vec.at(j-1)++;
        temp /= j;
        j = 2;
      }
      else{
        j++;
      }
    }
  }
  
  int64_t ans = 1;

  for(int i=0; i<N; i++){
    ans *= (vec.at(i)+1);
    ans %= 1000000007;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace AOJ.Volume11
{
    class AreaOfPolygones
    {
        public static void Main()
        {
            int n;
            for (var count = 1; (n = int.Parse(System.Console.ReadLine().Trim())) != 0; ++count){
                var points = new int[n].Select(v => System.Console.ReadLine().Trim().Split(' ').Select(_ => int.Parse(_)).ToArray()).Select(_ => new Point(_[0], _[1])).ToArray();
                var sum = points.Last().AreaOfTrapezoidX2(points.First());
                for (var i = 1; i < points.Count(); ++i)
                    sum += points[i - 1].AreaOfTrapezoidX2(points[i]);
                System.Console.Write(count);
                System.Console.Write(' ');
                System.Console.WriteLine(Math.Abs(sum / 2).ToString("F1"));
                System.Console.ReadLine();
            }
        }
        class Point
        {
            public Point(int x, int y)
            {
                this.X = x; this.Y = y;
            }
            public int X { get; private set; }
            public int Y { get; private set; }
            public Decimal AreaOfTrapezoidX2(Point other)
            {
                return (Y + other.Y) * (X - other.X);
            }
        }
    }
}

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

using namespace std;

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

  for (int i = S.size() - 1; i >= 0; --i) {
    switch (S.at(i)) {
      case 'e':
        if ((i - 4 >= 0) && (S.substr(i - 4, 5) == "erase")) {
          i -= 4;
        } else {
          cout << "NO" << endl;
          return 0;
        }
        break;
      case 'm':
        if ((i - 4 >= 0) && (S.substr(i - 4, 5) == "dream")) {
          i -= 4;
        } else {
          cout << "NO" << endl;
          return 0;
        }
        break;
      case 'r':
        if (i - 6 >= 0 && S.at(i - 2) == 'm' && S.substr(i - 6, 7) == "dreamer") {
          i -= 6;
        } else if (i - 5 >= 0 && S.at(i - 2) == 's' && S.substr(i - 5, 6) == "eraser") {
          i -= 5;
        } else {
          cout << "NO" << endl;
          return 0;
        }
        break;
      default:
        cout << "NO" << endl;
        return 0;
    }
  }
  cout << "YES" << endl;

  return 0;
}

Measured memory_bytes: 3744
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,M = inpl()
S = list(map(int,list(input())))

cnt = 1
tmp = []
for i in range(1,N+1):
    if S[i] == 0:
        if cnt > M:
            print(-1)
            exit()
        tmp.append(cnt)
        cnt = 1
    else:
        cnt += 1


cnt = 0
ans = []
for d in reversed(tmp):
    if cnt + d <= M:
        cnt += d
    else:
        ans.append(cnt)
        cnt = d

ans.append(cnt)
ans.reverse()

print(' '.join(map(str,ans)))


Measured memory_bytes: 13064
package main

import "fmt"

func main() {
	var N int

	fmt.Scanf("%d", &N)

	if N == 1 || N == 2 || N == 3 || N == 5 || N == 6 || N == 9 || N == 10 || N == 13 || N == 17 {
		fmt.Println("No")
	} else {
		fmt.Println("Yes")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); ++i)

ll GCD(ll x, ll y) {
  if (x > y) swap(x, y);
  while (x) {
    ll z = x;
    x = y%x;
    y = z;
  }
  return y;
}

ll LCM(ll x, ll y) {
  ll g = GCD(x, y);
  return x / g * y;
}

int main() {

  ll N, ans, t;
  cin >> N >> t;
  ans = t;
  REP (i, N-1) {
    cin >> t;
    ans = LCM(ans, t);
  }
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
import java.util.Arrays;

public class Main {
  private static void solve() {
    int n = ni();
    int k = ni();
    int[] h = na(n);

    Arrays.sort(h);
    long ret = 0;

    for (int i = 0; i < n - k; i++) {
      ret += h[i];
    }
    System.out.println(ret);

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 52268
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
void YN(int a){if(a==1)printf("Yes\n");if(a==0)printf("No\n");}
LL lpow(LL a,LL n){LL ans=pow(a,n)*10;if(ans%10<5)return ans/10;return ans/10+1;}
LL dup(LL a,LL d){if(a%d==0)return a/d;else return a/d+1;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
int scmpr(const void* a,const void* b){return strcmp(*(char**)b,*(char**)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}

int main(){
  LL A,B,i,ans=0;
  char S[11],T[11],U[11];
  scanf("%s%s%lld%lld%s",S,T,&A,&B,U);
  if(strcmp(S,U)==0)A--;
  else B--;

  printf("%lld %lld\n",A,B);
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <complex>
#include <algorithm>

using namespace std;

typedef complex<int> P;

bool isSame(vector<P> &vp1, vector<P> &vp2){
	if(vp1.size()!=vp2.size()) return false;
	P rot = P(1,0);
	for(int i=0;i<8;i++){
		bool ok = true;
		for(int j=0;j+1<vp1.size();j++)
			if(vp1[j+1]-vp1[j]!=rot*(vp2[j+1]-vp2[j])) ok = false;
		if(ok) return true;
		rot *= P(0,1);
		if(i==3) reverse(vp2.begin(), vp2.end()); 
	}
	return false;
}

int main(){
	int n;
	while(cin >> n, n){
		int m; cin >> m;
		vector<P> vp1(m);
		for(int i=0;i<m;i++) cin >> vp1[i].real() >> vp1[i].imag();
		for(int i=1;i<=n;i++){
			cin >> m;
			vector<P> vp2(m);
			for(int j=0;j<m;j++) cin >> vp2[j].real() >> vp2[j].imag();
			if(isSame(vp1, vp2)) cout << i << endl;
		}
		puts("+++++");
	}
}

Measured memory_bytes: 0
function Main(s) {
  s = s.split("\n");
  s[0] = s[0].split(" ").map(a => +a);
  s[1] = +s[1];
  var m = Math.max(...s[0]);
  console.log(s[0][0] + s[0][1] + s[0][2] + (m << s[1]) - m);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define N 100

int main(void)
{
    int n, a[N+1];
    cin >> n;
    for (int i = 1; i <= n; i++){
        cin >> a[i];
    }
    
    int cnt = 0;
    for (int i = 1; i <= n; i++){
        if( i&1 && a[i]&1 ){
            cnt++;
        }
    }
    
    cout << cnt << endl;

    return 0;
}


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

int main(){
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  
  while(true){
    C -= B;
    if(C<=0){
      cout << "Yes" << endl;
      return 0;
    }
    A -= D;
    if(A<=0){
      cout << "No" << endl;
      return 0;
    }
  }
  
  return 0;
}


Measured memory_bytes: 3592
' C + T = X
' 2 * C + 4 * T = Y
' T = X - C
' 2 * C + 4 * (X - C) = Y
' - 2 * C = Y - 4 * X
' C = 2 * X - Y / 2
' T = -X + Y / 2

' Imports System.Collections.Generic
' Imports System.Text.RegularExpressions

Class Main
    Public Shared Sub Main()
        Dim X, Y As Integer
        Dim arr() As String
        arr = Split(Console.ReadLine())
        X = arr(0) : Y = arr(1)
        Dim C As Integer = 2 * X - Math.Floor(Y / 2)
        Dim T As Integer = -X + Math.Floor(Y / 2)
        Console.WriteLine(
            If(0 <= C AndAlso 0 <= T AndAlso C + T = X AndAlso 2 * C + 4 * T = Y,
             "Yes", "No"))
        Return
    End Sub
End Class


Measured memory_bytes: 28344
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const primeFactorize = (target: bigint) => {
  let n = target;
  const res = new Map<bigint, bigint>();

  for (let i = 2n; i * i <= n; i++) {
    if (n % i !== 0n) {
      continue;
    }

    let ex = 0n;
    while (n % i === 0n) {
      ex += 1n;
      n /= i;
    }

    res.set(i, ex);
  }

  if (n !== 1n) {
    res.set(n, 1n);
  }

  return res;
};

const main = (input: string[][]) => {
  const N = BigInt(input[0][0]);

  const pf = primeFactorize(N);

  let answer = 0;

  pf.forEach((ex) => {
    let usedEx = 1;
    let usedCount = 0;

    while (usedEx <= ex) {
      usedCount += 1;
      usedEx += usedCount + 1;
    }

    answer += usedCount;
  });

  return answer;
};

console.log(main(read()));


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

vector< vector<int> > to(200005);
vector<int> ans;
void dfs(int v,int p=-1){
  for(int u : to.at(v)){
    if(u==p) continue;
    ans.at(u) += ans.at(v);
    dfs(u,v);
  }
}

int main(){
  int n,q;
  cin >> n >> q;
  for(int i=0;i<n-1;i++){
    int a,b;
    cin >> a >> b;
    a--; b--;
    to.at(a).push_back(b);
    to.at(b).push_back(a);
  }
  ans.resize(n);
  for(int i=0;i<q;i++){
    int p,x;
    cin >> p >> x;
    p--;
    ans.at(p)+=x;
  }
  dfs(0);
  for(int i=0;i<n;i++){
    cout << ans.at(i) << endl;
  }
  return 0;
}


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

 using namespace std;

 int main() {
   int N;

   cin >> N;

   string ans = "No";

   for (int i = 0; i <= N / 4; i++) {
     for (int j = 0; j <= N /7; j++) {
       if (4 * i + 7 * j == N) {
         ans = "Yes";
         break;
       }
     }
     if (ans == "Yes") break;
   }

   cout << ans << endl;
}


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

using namespace std;

int H, W;
int dist[1024][1024];
list<pair<int, pair<int, int>>> up;

void Add(int d, int h, int w) {
  if (h < 0 || H <= h || w < 0 || W <= w) return;
  if (dist[h][w] >= 0) return;
  up.push_back(make_pair(d, make_pair(h, w)));
}

int main() {
  while (cin >> H >> W) {
    memset(dist, -1, sizeof(dist));
    up.clear();
    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
	char p;
	cin >> p;
	if (p == '#') {
	  Add(0, i, j);
	}
      }
    }
    int ans = 0;
    while (!up.empty()) {
      int d = up.front().first;
      int h = up.front().second.first;
      int w = up.front().second.second;
      up.pop_front();
      if (h < 0 || H <= h || w < 0 || W <= w) continue;
      if (dist[h][w] >= 0) continue;
      dist[h][w] = d;
      ans = max(ans, d);
      Add(d+1, h-1, w);
      Add(d+1, h+1, w);
      Add(d+1, h, w-1);
      Add(d+1, h, w+1);
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 98048
# ABC140B - Buffet
def main():
    N, *ABC = map(int, open(0).read().split())
    A, B, C = ABC[:N], ABC[N : N * 2], ABC[N * 2 :]
    ans = sum(B)
    for i, j in zip(A, A[1:]):
        if i + 1 == j:
            ans += C[i - 1]
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
using System;

class Program {
    public static void Main() {
        var s = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        var strs = new string[s[0]];
        for (int i = 0; i < s[0]; i++) {
            strs[i] = Console.ReadLine();
        }

        Array.Sort(strs);
        Console.WriteLine(string.Join("", strs));
    }
}

Measured memory_bytes: 13408
#include <stdio.h>

int main( void )
{
	int aNumber[4];
	int bNumber[4];
	int i;
	int j;
	int hit;
	int blow;
	
	while( scanf( "%d", &aNumber[0] ) != EOF )
	{
		hit = 0;
		blow = 0;
		for( i = 1; i < 4; i++ )
		{
			scanf( "%d", &aNumber[i] );
		}
		for( i = 0; i < 4; i++ )
		{
			scanf( "%d", &bNumber[i] );
		}
		
		for( i = 0; i < 4; i++ )
		{
			if( aNumber[i] == bNumber[i] )
			{
				hit++;
			}
		}
		for( i = 0; i < 4; i++ )
		{
			for( j = 0; j < 4; j++ )
			{
				if( aNumber[i] == bNumber[j] && i != j )
				{
					blow++;
				}
			}
		}
		printf( "%d %d\n", hit, blow );
	}
	return (0);
}

Measured memory_bytes: 596
N, K = map(int, input().split())
dts = []
for _ in range(N):
    t, d = map(int, input().split())
    dts.append((d, t-1))

dts.sort(reverse=True)

tops = []
rests = []
isFounds = [False] * N
for d, t in dts:
    if isFounds[t]:
        rests.append(d)
    else:
        tops.append(d)
        isFounds[t] = True

tops.sort(reverse=True)
rests.sort(reverse=True)

xFr = max(1, K-len(rests))
xTo = min(K, len(tops))
iTop = xFr
iRest = K-xFr
sumD = sum(tops[:iTop]) + sum(rests[:iRest])
ans = sumD + xFr**2
for x in range(xFr+1, xTo+1):
    iRest -= 1
    sumD += tops[iTop] - rests[iRest]
    score = sumD + x**2
    ans = max(ans, score)
    iTop += 1

print(ans)


Measured memory_bytes: 18656
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef long long ll;
ll sum;
int len;
char str[15];
bool map[15];
void dfs(int pre, int now, int need,bool add);
ll calc(int pre, int now);
int main(void)
{
	scanf("%s", str);
	len = strlen(str);
	sum = calc(0, len - 1);
	//dfs(-1, 0, 1, true);
	//dfs(-1, 0, 2, true);
	for (int i = 1; i <= len - 1; i++)
		dfs(-1, 0, i, true);
	//dfs(-1, 0, 2, true);
	printf("%lld\n", sum);
	return 0;
}
void dfs(int pre, int now, int need,bool add)//125//1+25//12+5//1+2+5
{
	if (need < 0)return;
	if (now > len)return;
	if (len - now <= need)return;
	if (pre == -1) {
		dfs(0, 0, need, true);
		dfs(0, 0, need, false);
		return;
	}
	if (!add)
		map[now] = false;
	else {
		map[now] = true;
		need--;
		if (!need) {
			int p = 0;
			for(int i=0;i<len;i++)
				if (map[i] || i==len-1)
				{
					sum += calc(p, i);
					p = i + 1;
				}
			return;
		}
	}
	dfs(0, now + 1, need, true);
	dfs(0, now + 1, need, false);
	map[now] = false;
}
ll calc(int pre, int now)
{
	ll res = 0;
	for (int i = pre; i <= now; i++)
		res = res * 10 + str[i] - '0';
	return res;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

using namespace std;

int cls[15];

void solve() {
    int n;
    int cnt=0;
    cin >> n;
    for (int i=0; i<n; ++i) {
        int ai;
        cin >> ai;
        if (ai >= 3200)
            ++cnt;
        else
            ++cls[ai/400];
    }
    int ans = 0;
    for (int r: cls)
        if (r)
            ++ans;
    if (ans == 0) {
        ans = 1;
        --cnt;
    }
    cout << ans << " " << (ans + cnt);

}

int main() {

	solve();
    return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("abc177/abc177_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int D, T, S;
  cin >> D >> T >> S;
  
  cout << (ceil((float)D / S) <= T ? "Yes" : "No") << endl;
}

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

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

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

const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

int32_t main(){
    boost;

   
    //code

    int n;
    cin >> n;
    cout << n*800 - (n/15)*200;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <tuple>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <unordered_map>

using namespace std;
using str = string;

#define rep(a,l,r) for(int a=(l);a<(r);a++)
#define get cin>>
#define put cout<<

void run() {

	int h; get h;
	int w; get w;

	vector<str> rows(h);

	for(auto& row:rows){
		get row;
	}

	auto it = rows.begin();
	while(it!=rows.end()){
		if(count(it->begin(), it->end(),'#') == 0){
			rows.erase(it);
		} else {
			++it;
		}
	}

	vector<bool> columns(w,false);
	rep(i,0,w){
		for(auto& row: rows){
			if(row[i] == '#'){
				columns[i] = true;
				break;
			}
		}
	}

	for(auto& row: rows){
		rep(i,0,w){
			if(columns[i]){
				put row[i];
			}
		}
		put endl;
	}

}
int main() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);run();return 0;}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main(){
    int a, b, valor=0;
    scanf("%d", &a);
    scanf("%d", &b);
    if((a==1 && b==2) || (a==2 && b==1))
        printf("%d", 3);
    else if((a==2 && b==3) || (a==3 && b==2))
        printf("%d", 1);
    else if((a==1 && b==3) || (a==3 && b==1))  
        printf("%d", 2);
    printf("\n");
    return 0;
}

Measured memory_bytes: 1728
# -*- coding: utf-8 -*-

"""
参考：https://img.atcoder.jp/keyence2019/editorial.pdf
"""

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, M = MAP()
# 二分探索用にソートしておく
# (どの行に何が来るかの具体的な位置は今回必要ないのでソートしていい)
A = sorted(LIST())
B = sorted(LIST())
MAX = N * M

# 同じリストに同じ値がいたら論外
# (各値1回ずつしか使えないのに、違う行で最大値が同じとか不可能)
if len(A) != len(set(A)) or len(B) != len(set(B)):
    print(0)
    exit()

# 1: Aにある, 2: Bにある, 3: 両方にある, 0: どちらにもない
flags = [0] * (MAX+1)
for i in range(N):
    flags[A[i]] += 1
for i in range(M):
    flags[B[i]] += 2

ans = 1
for i in range(MAX, 0, -1):
    tmp = 1
    # どちらにもない
    if flags[i] == 0:
        # Aで自分以上の数 * Bで自分以上の数 - 自分以上の数
        tmp = (N-bisect_left(A, i)) * (M-bisect_left(B, i)) - (N*M-i)
        if tmp <= 0:
            print(0)
            exit()
    # Aにある
    elif flags[i] == 1:
        # 自分の行が決まっているので、列を調べに行く
        tmp = (M-bisect_left(B, i))
    # Bにある
    elif flags[i] == 2:
        tmp = (N-bisect_left(A, i))
    ans = (ans * tmp) % MOD
print(ans)


Measured memory_bytes: 13208