akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){
	int i,j;
	int H,W;
	
	for(;scanf("%d%d",&H,&W),H,W;){
		
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				if(i==0 ||i==H-1 || j==0 ||j==W-1){
					printf("#");
				}else{
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	
	
	return 0;
}

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

int main(){
    int a, b, out;
    cin >> a >> b;
    if ((a + b) % 2 != 0) {
        out = (a + b + 1) / 2;
    } else {
        out = (a + b) / 2;
    }
    cout << out << endl;
}

Measured memory_bytes: 256
using namespace std;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    string s;
    cin >> s;

    int sum = 0;
    for (int i = 0; i < 3; i++){
        if (s[i] == 'o'){
            sum+=100;
        }
    }
    cout << 700 + sum << endl;
}


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

typedef long long ll;
 
using tpl = tuple<int, int, int>;
typedef pair<int,int> pii;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

const ll mod = 1000000000 + 7;

// 以下コピー
const int MAX_FACT = 2000000;
ll fact[MAX_FACT];
ll pow_mod(ll a,ll n){
  ll cur=1;
  ll mul=a;
  while(n){
    if(n%2)cur=(cur*mul)%mod;
    mul=(mul*mul)%mod;
    n/=2;
  }
  return cur;
}

ll div_mod(int a){
  return pow_mod(a,mod-2);
}

// factを前計算
void calcFact(){
  fact[0]=1;
  for(int i=1;i<MAX_FACT;i++)
    fact[i]=(fact[i-1]*i)%mod;
}

// aCbのmodを計算
// 計算量はO(log(fact[a])+log(fact[a-b]))程度
ll comb(ll a,ll b){
  if(a<0||b<0)return 0;
  else if(a<b)return 0;
  else if(b==0)return 1;
  ll res=fact[a];
  res=(res*div_mod(fact[b]))%mod;
  res=(res*div_mod(fact[a-b]))%mod;
  return res;
}


int N;
int A[100010];
ll anss[100010];
int prv[100010];
ll ones_no_bet[100010];
ll ones[100010];

int main(){

    cin >> N;
    for(int i = 0; i <= N; i++) cin >> A[i];
    calcFact();
    memset(prv, -1, sizeof(prv));
    int from = -1;
    int to = -1;
    for(int i = 0; i <= N; i++){
        if(prv[A[i]] != -1){
            from = prv[A[i]];
            to = i;
            break;
        }
        else{
            prv[A[i]] = i;
        }
    }
    // [from, to]の範囲とそれ以外で場合わけ
    ll prv_from = from;
    ll nxt_to = N - to;

    // Aを使わないパターン
    for(int i = 1; i <= N - 1; i++){
        (anss[i] += comb(N + 1 - 2, i)) %= mod;
    }
    // Aを2つ使うパターン
    for(int i = 2; i <= N + 1; i++){
        (anss[i] += comb(N + 1 - 2, i - 2)) %= mod;
    }
    // Aを1つ使うパターン、どちらを使うかは問わない
    for(int i = 1; i <= N; i++){
        (ones[i] = comb(N + 1 - 2, i - 1) * 2) %= mod;
    }
    // Aを1つ使うパターンで、間の要素を使わない
    for(int i = 1; i <= N; i++){
        ones_no_bet[i] = comb(prv_from + nxt_to, i - 1);
        (anss[i] += ones_no_bet[i]) %= mod;
    }
    // Aを1つ使うパターンで、間の要素を使う
    for(int i = 1; i <= N; i++){
        (anss[i] += (ones[i] - ones_no_bet[i] * 2 + mod * 2)) %= mod;
    }
    
    for(int i = 1; i <= N + 1; i++){
        cout << anss[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 19968
#include<bits/stdc++.h>
using namespace std;
#define fastIO std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
const int INF = 0x3f3f3f3f;
const double pi = acos(-1.0);
//int rnd(int x) { return mrand() % x;}
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;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

const int maxn = 2e5 + 10; 

int main()
{
	//fastIO;
	double r; cin >> r;
	printf("%.3f",2.0 * pi * r);
	return 0;
}


Measured memory_bytes: 3788
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n,k;
    cin>>n>>k;
    VL a(n);
    REP(i,n)cin>>a[i];
    SORT(a);
    LL sum = 0;
    REP(i,n)sum += a[i];

    LL ans = 1;
    for(LL i = 1; i * i <= sum; i++){
        if(sum % i != 0)continue;
        LL x[] = {i, sum / i};
        REP(d,2){
            VL r(n);
            REP(j,n)r[j] = a[j] % x[d];
            SORT(r);

            VL cusum(n+1);
            cusum[0] = 0;
            REP(j,n)cusum[j+1] = cusum[j] + r[j];

            bool able = false;
            REP(j,n-1){
                LL neg = cusum[j+1];
                LL pos = (x[d] * (n - j - 1)) - (cusum[n] - cusum[j+1]);
                LL y = abs(neg - pos);
                if(y % x[d] == 0 && max(neg, pos) <= k){
                    able = true;
                    break;
                }
            }
            if(able)ans = max(ans, x[d]);
        }
    }
    PUTS(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int d,t,s;
    cin>>d>>t>>s;
    float x=(float)d/s;
    if(x<=t)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    
}

Measured memory_bytes: 3644
n=int(input())

selist=[]
for i in range(n):
    tmpx,tmpl = map(int,input().split())
    selist.append([tmpx-tmpl,tmpx+tmpl])

selist.sort(key=lambda x:x[1])


maeindex=0
maeza=selist[0][0]-1
robnum=0
finishflag=True



while finishflag:
	for i in range(maeindex,n):
		if selist[i][0] >= maeza:
			maeindex=i
			robnum+=1
			maeza=selist[i][1]
			break
		if i == n-1:
			finishflag=False


print(robnum)

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

#define dump(...) DUMPOUT<<"  ";DUMPOUT<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<std::endl;DUMPOUT<<"    ";dump_func(__VA_ARGS__)
#define PI 3.14159265358979323846
#define EPS 1e-10
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(j) (j).begin(), (j).end()
#define SZ(j) ((int)(j).size())

int D = 365;
const int T = 26;

vector<int> c(T);
vector<vector<int>> s(D, vector<int>(T)); 

long long eval(vector<int> out, int k) {
    long long score = 0;
    vector<int> last(T, 0);
    REP(d, (int)out.size()) {
        last[out[d]-1] = d+1;
        REP(i, T) {
            score -= (long long)(d+1 - last[i]) * c[i];
        }
        score += s[d][out[d]-1];
    }
    FOR(d, (int)out.size(), min(D, (int)out.size()+k)) {
        REP(i, T) {
            score -= (long long)(d+1 - last[i]) * c[i];
        }
    }

    return score;
}

long long compute_score(vector<int> out) {
    long long score = 0;
    vector<int> last(T, 0);
    REP(d, (int)out.size()) {
        last[out[d]-1] = d+1;
        REP(i, T) {
            score -= (long long)(d+1 - last[i]) * c[i];
        }
        score += s[d][out[d]-1];

        // cout << score << endl;
    }

    return score;
}

vector<int> solve(int k) {
    vector<int> out;
    REP(_, D) {
        int best_i = 1;
        long long max_score = -(1e18);
        FOR(i, 1, T+1) {
            out.emplace_back(i);
            long long score = eval(out, k);
            if (max_score < score) {
                max_score = score;
                best_i = i;
            }

            out.pop_back(); 
        }
        out.emplace_back(best_i);
    }

    return out;
}

void test_score() {
    vector<int> t(D);
    REP(i, D) cin >> t[i];
    compute_score(t);
}

int main(int argc, char const *argv[])
{
    int d_;
    cin >> d_;
    D = d_;
    
    REP(i, T) cin >> c[i];
    REP(i, D) REP(j, T) cin >> s[i][j];

    vector<int> out = solve(13);
    long long max_eval = eval(out, 13);
    REP(k, 26) {
        vector<int> o = solve(k);
        long long eval_v = eval(o, k);
        if (max_eval < eval_v) {
            out = o;
            max_eval = eval_v;
        }
    }
    
    assert(out.size() == D);
    for (int t : out) {
        cout << t << endl;
    }

    return 0;
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t n;
  cin>>n;
  int64_t x=0;
  for(int i=1;i<=n;i++){
    if(i%3!=0&&i%5!=0){
      x+=i;}
  }
    cout<<x<<endl;
}

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

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

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

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

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

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

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

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

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll cnt=0;
  string S;
  cin >> S;
  rep(i, 4){
    if(S[i]=='2')cnt++;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3640
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var S string
	fmt.Scanf("%s", &S)

	a, _ := strconv.Atoi(S[5:7])

	if a <= 4 {
		fmt.Println("Heisei")
	} else {
		fmt.Println("TBD")
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
signed main() {

#ifdef LOCAL_DEFINE
	FILE* fp;
	freopen("input.txt", "rt", stdin);
#endif

	string s;
	cin >> s;

	if (s[0] != 'A') {
		cout << "WA" << endl;
		return 0;
	}

	bool flag = false;
	int cnt = 0, pos;

	for (int i = 2; i < s.size() - 1; i++) {
		if (s[i] == 'C') {
			if (cnt == 0) {
				flag = true;
				cnt++;
				pos = i;
			}
			else flag = false;
		}
	}

	if (!flag) {
		cout << "WA" << endl;
		return 0;
	}

	flag = true;

	string alph = "abcdefghijklmnopqrstuvwxyz";

	for (int i = 1; i < s.size(); i++) {
		if (i != pos) {
			if (alph.find(s[i]) == string::npos) {
				flag = false;
				break;
			}
		}
	}

	if (!flag) cout << "WA" << endl;
	else cout << "AC" << endl;

#ifdef LOCAL_DEFINE
	cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif

	return 0;
}

Measured memory_bytes: 256
import numpy as np


H, W = map(int, input().split())
a = [list(input()) for _ in range(H)]
a = np.array(a)

lst = []
for i, row in enumerate(a):
    if np.all(row=='.'):
        lst.append(i)
a = np.delete(a, lst, 0)
b = a.T
lst = []
for i, row in enumerate(b):
    if np.all(row=='.'):
        lst.append(i)
b = np.delete(b, lst, 0)
ans = b.T
for i in ans:
    print(''.join(i))

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

int main(){
  int N;
  cin >> N;
  while(N--){
    int s,d;
    cin >> s >> d;
    int ans = 0;
    for(int i = 0; i < 30; i++){
      if(s & (1 << i)){
	ans++;
	s += (1<<i);
      }
      if(d & (1 << i)){
	ans++;
	d -= (1<<i);
      }
      if(s == d) break;
    }
    
    cout << ans << endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <iostream>
using namespace std;


int n;
int a;
bool tong[1000000005];


int main()
{
	scanf("%d",&n);
	for(int i=1; i<=n; ++i){
		scanf("%d",&a);
		if(!tong[a])
		tong[a]=1;
		else 
		{
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	return 0;
}

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

int main() {
	long long x;
	cin >> x;
	long long y = x%500;
	long long z = x/500;
	long long w = y-y%5;
	long long ans = z*1000 + w;
	cout << ans << endl;
	return 0;
}


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

const int MOD = 1000000007;

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int x, a;
    cin >> x >> a;
    if (x < a) {
        cout << 0 << endl;
    } else {
        cout << 10 << endl;
    }
}

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

int main() {
	char c;
	int count,flag;
	stack<char> sta;
	while(1){
		count = 0;
		flag = 0;
		while(1){
			scanf("%c",&c);
			if(c == '.')break;
			if(flag == 1)continue;
			if(c == '('){
				sta.push(')');
			}
			else if(c == '['){
				sta.push(']');
			}
			else if(c == ')' || c == ']'){
				if(sta.size() == 0)flag = 1;
				else if(sta.top() != c)flag = 1;
				if(sta.size() > 0)sta.pop();
			}
			count++;
		}
	if(count == 1)break;
	if(flag == 0 && sta.size() == 0)cout << "yes" <<endl;
	else if(flag == 1 || sta.size() > 0)cout << "no" <<endl;
	while(sta.size() != 0){
		sta.pop();
	}
	}
	return 0;
}

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


void solve() {
  int N;
  scanf("%d", &N);
  int arr[N];
  rep(i,N) {
    scanf("%d", &arr[i]);
  }
  int ans=100000;
  int sum1=0;
  int sum2=0;
  for (size_t i = 0; i < N-1; i++) {
    for (size_t j = 0; j <=i; j++) {
      sum1=sum1+arr[j];
    }
    for (size_t j = i+1; j < N; j++) {
      sum2 = sum2 + arr[j];
    }
    if (ans>abs(sum1-sum2)) {
      ans = abs(sum1-sum2);
    }
    sum1 = 0;
    sum2 = 0;
  }
  cout << ans << "\n";
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef long long ull;
typedef pair<int, int> ii;

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
/*#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("pyramid.in", "r", stdin);
#endif*/
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 5e3 + 15;
int dx[8] = { -1, 0, 0, 1, 1, -1, 1, -1 };
int dy[8] = { 0, -1, 1, 0, 1, -1, -1, 1 };


int main()
{
	fast();
	ll a, b, c;
	cin >> a >> b >> c;
	cout << 0.5*(a + b) * c << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
L = []
for i in range(n):
  a,b = map(int,input().split())
  L.append([a+b,a-b])
L.sort()
ans = 0
right = -10**10
for i in range(n):
  if L[i][1] >= right:
    ans += 1
    right = max(right,L[i][0])
print(ans)

Measured memory_bytes: 20092
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

const int INF = 1000000010;

int K,N; vector<int> h;
void input()
{
    cin >> N >> K;
    h.resize(N);
    for(int i=0; i<N; ++i) cin >> h[i];
}

void solve()
{
    sort(h.begin(),h.end());
    int MIN = INF;
    for(int i=0; i<=N-K; ++i){
        MIN = min(MIN,h[i+K-1]-h[i]);
    }
    cout << MIN << endl;
}

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

Measured memory_bytes: 3692
#include<bits/stdc++.h>
#define int long long 
using namespace std;
signed main(){
  int a,b,k;
  cin>>a>>b>>k;
  if(a-k<=0){
    cout<<"0 ";
    b = b - abs(a-k);
    if(b<0){
      cout<<"0\n";
    }else{
      cout<<b<<"\n";
    }
  }else{
    cout<<a-k<<" "<<b<<"\n";
  }
  return(0);
}


Measured memory_bytes: 256
// Problem : B - Substring
// Contest : AtCoder - AtCoder Beginner Contest 177
// URL : https://atcoder.jp/contests/abc177/tasks/abc177_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)


#include<bits/stdc++.h>
#define 	ll		    long long
#define 	rep(i,a,n)  for(int i=a;i<n;i++)
#define 	MOD 		1000000007
#define 	vp 			vector<pair<int,int> >
#define 	ff 			first
#define 	ss 			second
#define 	pb 			push_back
#define 	all(x) 		(x).begin(),(x).end()
#define 	dg(x)		cerr<<"--- x = "<<x<<"\n"
#define 	endl		"\n"


using namespace std;
const int N = 1e5;
ll ar[N];

void solve(){
	string s, t; 
	cin >> s >> t;
	int n1 = s.length();
	int n2 = t.length();
	int f = 1;
	if(n1 < n2)
		f = 0;
	int cost = 10000;
	
	rep(i, 0, n1 - n2 + 1){
		int cur = 0;
		rep(j , 0, n2 )
			if(s[i + j] != t[j])
				cur++;
		cost = min(cost, cur);
	}
	cout << cost * f;
}

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        cout<<endl;
    }
}


Measured memory_bytes: 3660
#!/usr/bin/env python3
import sys


def solve(N: int, S: str):
    left = 0
    left_max = 0
    for i in range(N):
        if S[i] == ')':
            left += 1
        elif S[i] == '(':
            left -= 1
        if left > left_max:
            left_max = left
    
    right = 0
    right_max = 0
    for i in range(N-1, -1, -1):
        if S[i] == '(':
            right += 1
        elif S[i] == ')':
            right -= 1
        if right > right_max:
            right_max = right
    print('(' * left_max + S + ')' * right_max)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)

if __name__ == '__main__':
    main()


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



int main() {
  int D, G;
  cin >> D >> G;
  vector<int> p(D);
  vector<int> c(D);
  vector<int> solved(D,0);
  int min_problem = 0;
  
  for (int i=0; i<D;i++){
    cin >> p.at(i) >> c.at(i);
    min_problem += p.at(i);
  }

  int total_point = 0;
  int total_problem = 0;

  for (int tmp=0; tmp<(1<<D); tmp++){
    bitset<10> s(tmp);  // complete or not
    
    total_point = 0;
    total_problem = 0;
    
    // コンプリートボーナスをカウント
    for (int i=0;i<D;i++){
      if (s.test(i)) {
        total_point += c.at(i) + 100*(i+1)*p.at(i);
        total_problem += p.at(i);
      } 
    }
    if (total_point >= G) {
      min_problem = min(min_problem, total_problem);
      continue;
    }
    
    int tmp_problem;
    for (int i=D-1;i>=0;i--) {
      if (!s.test(i)) {
        /*
        if (100*(i+1)*(p.at(i)-1) < G-total_point) {
          tmp_problem = p.at(i)-1;
        }
        else {
          tmp_problem = (G-total_point)/(100*(i+1));
        }
        */
        tmp_problem = min(p.at(i)-1, (G-total_point)/(100*(i+1)));
        total_problem += tmp_problem;
        total_point += 100*(i+1)*tmp_problem;
      }
      //cout << total_problem << endl;
    }
    if (total_point >= G) {
      min_problem = min(min_problem, total_problem);
    }
    //cout << min_problem << endl;
     
  }
  cout << min_problem << endl;
}


Measured memory_bytes: 256
using System;
using System.IO.Pipes;

class Lucky7
{
    static void Main(string[] args)
    {
        var answer = "";


        var input = Console.ReadLine();
        if (input.Contains("7"))
        {
            answer = "Yes";
        }
        else
        {
            answer = "No";
        }

        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 17448
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define PB push_back
#define MP make_pair
using ll = long long;
using Pii = pair<int, int>;
const int MOD = 1000000007;
const int INF = 1000000000;

struct edge{
    int from, to;
    edge(int From, int To) : from(From), to(To){};
};
int n, m;
vector<edge> es;
vector<vector<bool>> G;
vector<bool> visited;

void dfs(int cur){
    visited[cur] = true;
    REP(nxt, n){
        if(!G[cur][nxt]) continue;
        if(visited[nxt]) continue;
        dfs(nxt);
    }
}

int main(){
    cin >> n >> m;
    visited.resize(n, false);
    G.resize(n, vector<bool>(n, false));
    REP(i, m){
        int a, b; cin >> a >> b;
        --a; --b;
        es.PB(edge(a, b));
        G[a][b] = G[b][a] = true;
    }
    int cnt = 0;
    REP(i, m){
        G[es[i].from][es[i].to] = G[es[i].to][es[i].from] = false;
        REP(j, n) visited[j] = false;
        dfs(0);

        bool brdg = false;
        REP(j, n) if(!visited[j]) brdg = true;
        if(brdg) ++cnt;
        G[es[i].from][es[i].to] = G[es[i].to][es[i].from] = true;
    }
    cout << cnt << "\n";
    return 0;
}


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

using namespace std;

const int N = 101;

short f[N][N][N][N];
char s[N][N];
int row[N][N], col[N][N];

int main() {
  int h, w;
  scanf("%d %d", &h, &w);
  int x = -1, y = -1;
  for (int i = 0; i < h; i++) {
    scanf("%s", s[i]);
    for (int j = 0; j < w; j++) {
      if (s[i][j] == 'E') {
        x = i;
        y = j;
      }
    }
  }
  for (int i = 0; i < h; i++) {
    row[i][0] = 0;
    for (int j = 0; j < w; j++) {
      row[i][j + 1] = row[i][j] + (s[i][j] == 'o');
    }
  }
  for (int j = 0; j < w; j++) {
    col[0][j] = 0;
    for (int i = 0; i < h; i++) {
      col[i + 1][j] = col[i][j] + (s[i][j] == 'o');
    }
  }
  memset(f, 0, sizeof(f));
  for (int i = x; i >= 0; i--) {
    for (int j = y; j >= 0; j--) {
      for (int p = x; p < h; p++) {
        for (int q = y; q < w; q++) {
          short ft = f[i][j][p][q];
          if (i > 0) {
            int from = max(j, q - y);
            int to = min(q, w - 1 - (y - j));
            short add = (i - 1 < p - x ? 0 : (from > to ? 0 : (row[i - 1][to + 1] - row[i - 1][from])));
            f[i - 1][j][p][q] = max(f[i - 1][j][p][q], (short) (ft + add));
          }
          if (j > 0) {
            int from = max(i, p - x);
            int to = min(p, h - 1 - (x - i));
            short add = (j - 1 < q - y ? 0 : (from > to ? 0 : (col[to + 1][j - 1] - col[from][j - 1])));
            f[i][j - 1][p][q] = max(f[i][j - 1][p][q], (short) (ft + add));
          }
          if (p < h - 1) {
            int from = max(j, q - y);
            int to = min(q, w - 1 - (y - j));
            short add = (p + 1 > h - 1 - (x - i) ? 0 : (from > to ? 0 : (row[p + 1][to + 1] - row[p + 1][from])));
            f[i][j][p + 1][q] = max(f[i][j][p + 1][q], (short) (ft + add));
          }
          if (q < w - 1) {
            int from = max(i, p - x);
            int to = min(p, h - 1 - (x - i));
            short add = (q + 1 > w - 1 - (y - j) ? 0 : (from > to ? 0 : (col[to + 1][q + 1] - col[from][q + 1])));
            f[i][j][p][q + 1] = max(f[i][j][p][q + 1], (short) (ft + add));
          }
        }
      }
    }
  }
  printf("%d\n", (int) (f[0][0][h - 1][w - 1]));
  return 0;
}


Measured memory_bytes: 203648
#include <iostream>
#include <vector>
using namespace std;
int main(void) {
	int n;
	string s;
	cin >> n >> s;
	vector<long long> cnt(26, 0);
	for (int i = 0; i < s.size(); ++i) {
		++cnt[s[i] - 97];
	}
	long long MOD = 1e9 + 7;
	long long res = 1;
	for (int i = 0; i < 26; ++i) {
		if (cnt[i] > 0) {
			if (cnt[i] == 1) res *= 2;
			else res *= (cnt[i] + 1);
			res = res % MOD;
		}
	}
	cout << res - 1 << endl;
	return 0;
}

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

int n;
char s[3];

int main() {
    scanf("%s", s);
    int x = 1;
    if (strcmp(s, "MON") == 0)
        printf("6\n");
    if (strcmp(s, "TUE") == 0)
        printf("5\n");
    if (strcmp(s, "WED") == 0)
        printf("4\n");
    if (strcmp(s, "THU") == 0)
        printf("3\n");
    if (strcmp(s, "FRI") == 0)
        printf("2\n");
    if (strcmp(s, "SAT") == 0)
        printf("1\n");
    if (strcmp(s, "SUN") == 0)
        printf("7\n");

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, i, j, cnt[1000001]={0}, x[1000001]={0}, a;

    cin >> N;

    for(i=1; i<=N; i++){
        cin >> a;

        cnt[a]++;
    }

    for(i=1; i<=1000000; i++){
        if(cnt[i]>=1) x[i] = 1;
        if(cnt[i]>=2) cnt[i] = 0;
    }

    for(i=1; i<=1000000; i++){
        if(x[i]==1){
            for(j=i*2; j<=1000000; j+=i){
                cnt[j] = 0;
            }
        }
    }

    ll ans = 0;

    for(i=1; i<=1000000; i++){
        ans += cnt[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 19304
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
int main(){
    i64 a,b,c;
    cin>>a>>b>>c;
    if(a==5&&b==7&&c==5) cout<<"YES"<<endl;
    else if(a==7&&b==5&&c==5)cout<<"YES"<<endl;
    else if(a==5&&b==5&&c==7)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  int check = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'a') check |= 1;
    if (S[i] == 'b') check |= 2;
    if (S[i] == 'c') check |= 4;
  }
  if (check == 7) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
# your code goes here
N,T = map(int,input().split())

ans = -1
for i in range(N):
	c,t = map(int,input().split())
	if t <= T:
		if ans == -1:
			ans = c
		else:
			ans = min(ans,c)

if ans == -1:
	print('TLE')
else:
	print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

cat mod = 998244353;

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N, MX = 1000000;
	cin >> N;
	vector<cat> SA(MX+1, 0);
	for(int i = 0; i < N; i++) {
		int a;
		cin >> a;
		SA[a]++;
	}
	vector<cat> SD(MX+1, 0);
	for(int i = 1; i <= MX; i++) {
		for(int j = 1; j <= MX/i; j++) SD[i] += SA[i*j] * j;
		SD[i] %= mod;
	}
	vector<cat> sums(MX+1, 0);
	cat ans = 0, mod2 = mod*mod*4;
	for(int d = MX; d >= 1; d--) {
		cat sum_dif = 0;
		for(int i = 2*d; i <= MX; i += d) {
			sum_dif += sums[i] * (i/d);
			if(sum_dif >= mod2) sum_dif -= mod2;
		}
		sum_dif %= mod;
		sums[d] = (SD[d] * SD[d] % mod * d - sum_dif) % mod;
		ans = (ans + sums[d]) % mod;
	}
	ans -= SD[1];
	ans %= mod;
	ans = ans * 499122177LL % mod;
	if(ans < 0) ans += mod;
	cout << ans << "\n";
	return 0;
}

// look at my code
// my code is amazing


Measured memory_bytes: 23680
#include <stdio.h>
#include <stdlib.h>
#define NIL -1
typedef struct Node
{
    int root;
    struct Node* parent;
    struct Node* leftchild;
    struct Node* rightchild;
}Node;
Node* insertTree(Node* Tree, int data)
{
    Node* y = NULL;
    Node* x = Tree;
    Node* temp = (Node*)malloc(sizeof(Node));
    temp->root = data;
    temp->leftchild=temp->rightchild=temp->parent=NULL;
    while(x!=NULL)
    {
        y = x;
        if(temp->root < x->root){x = x->leftchild;}
        else{x = x->rightchild;}
    }
    temp->parent = y;
    if(y == NULL){Tree = temp;}
    else if(temp->root < y->root){y->leftchild = temp;}
    else{y->rightchild = temp;}
    return Tree;
}
void Preorder(Node* Tree)
{
    if(Tree==NULL)return;
    printf(" %d", Tree->root);
    Preorder(Tree->leftchild);
    Preorder(Tree->rightchild);
}
void inorder(Node* Tree)
{
    if(Tree==NULL)return;
    inorder(Tree->leftchild);
    printf(" %d", Tree->root);
    inorder(Tree->rightchild);
}
int main() {
    int n;
    int node;
    char str[10];
    Node* Tree = NULL;
    scanf("%d", &n);
    for(int i=0;i<n;i++)
    {
        scanf("%s ", str);
        if(str[0]=='i')
        {
            scanf("%d", &node);
            Tree = insertTree(Tree, node);
        }
        else if(str[0]=='p')
        {inorder(Tree);printf("\n");Preorder(Tree);printf("\n");}
    }
    return 0;
}



Measured memory_bytes: 25212
import java.util.*;
import java.io.*;

public class Main{
	public static void main(String[] args)  throws IOException,NumberFormatException{
		try {
		FastScanner sc=new FastScanner();
		char a[]=sc.next().toCharArray();
		int count[]=new int[26];
		for(int i=0;i<a.length;i++) {
			count[a[i]-'a']++;
		}
		boolean ans=true;
		for(int i=0;i<count.length;i++) {
			if(count[i]>1) {
				ans=false;
				break;
			}
		}
		System.out.println(ans?"yes":"no");
		}
		catch(Exception e) {
			return ;
		}
		
	}
	static final Random random=new Random();
	
	static void ruffleSort(int[] a) {
		int n=a.length;
		for(int i=0;i<n;i++) {
			int oi=random.nextInt(n),temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
	
	public static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try { 
                                      st=new StringTokenizer(br.readLine());				               
                              } catch (IOException e) {}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		
		long nextLong() {
			return Long.parseLong(next());
		}
		
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		
		long[] readLongArray(int n) {
			long[] a=new long[n];
			for(int i=0; i<n ; i++) a[i]=nextLong();
			return a;
		}
		
		String nextLine() 
        { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
        } 
	}

}


Measured memory_bytes: 32592
#include<iostream>
using namespace std;
#include<cmath>
#include<map>
#include<set>
#define int long long int
#define mod 1000000007
int function(int arr[],int initial,int final)
{
	if(initial>final)
	    return 0;
	else
	{
		if(arr[initial]==0)
		{
			return function(arr,initial+1,final);
		}
		else
		{
			int x=arr[initial]-1+9*(final-initial);
			int y=arr[initial]+function(arr,initial+1,final);
			return max(x,y);
		}
	}
}
int32_t main()
{ 
     string str;
     cin>>str;
     int l=str.size();
     int arr[l],j;
     for(j=0;j<l;j++)
         arr[j]=str[j]-48;
     int answer=function(arr,0,l-1);
     cout<<answer<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> 
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#include <string>
#include <iostream>
using namespace std;

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A - B >= C) {
		cout << 0 << endl;
	}
	else {
		cout << C - A + B << endl;
	}
	
	}
	

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
using namespace std;

int n, k, d, a;
int counter = 0;


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

    vector<int> num(n);
    for(int i=0;i<n;i++){
        num[i] = 0;
    }

    for(int i=0;i<k;i++){
        cin >> d;
        for(int j=0;j<d;j++){
            cin >> a;
            num[a-1] += 1;
        }
    }

    for(int i=0;i<n;i++){
        if(num[i] == 0) counter ++;
    }

    cout << counter << endl;
}   

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	string s, t;
	cin >> s >> t;
	
	int n = s.size();
	vector<int> cnt_s(26, 0), cnt_t(26, 0);
	for(int i = 0; i < n; ++i) {
		cnt_s[s[i] - 'a']++;
		cnt_t[t[i] - 'a']++;
	}
	
	sort(cnt_s.begin(), cnt_s.end());
	sort(cnt_t.begin(), cnt_t.end());

	if( cnt_s == cnt_t ) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 776
#include<bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k, a, in; cin >> n >> k;
    for(int i = 1; cin >> a; i++) if(a == 1) in = i;
    cout << ((n - 1) / (k - 1) + int((n - 1) % (k - 1) != 0));
}
    


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int a,b,c,k,x;
	scanf("%d %d %d %d", &a,&b,&c,&k);
	if((a>b && (a>c || a==c))||(a>c && (a>b || a==b))){ 
		while(k--){
			a=a*2;
			}
		printf("%d\n", a+b+c);}
	else if((b>a && (b>c || b==c))||(b>c && (b>a || a==b))){
		while(k--){
			b=b*2;
			}
		printf("%d\n", a+b+c);
		}
	else if ((c>b && (c>a || a==c))||(c>a && (c>b || c==b))){
		while(k--){
			c=c*2;
			}
		printf("%d\n", a+b+c);
		}
	else{ 
		while(k--){
			a=a*2;
			}
		printf("%d\n", a+b+c);
		}
	return 0;}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
int main() {
  int64_t N,K;
  cin >> N >> K;
  int64_t max = 0,min = 0;
  int64_t sum = 0;
  for(int64_t i = K; i < N + 2 ; i++){
    min = int64_t(i * (i - 1) /2);
    max = int64_t(i * (N + N - i + 1)/2);
    sum += int64_t(max - min + 1);
  }
  cout << int64_t(sum % (1000000000 + 7))  << endl;
  return 0;
}

Measured memory_bytes: 3648
def bi(x):
  global N
  y = []
  for _ in range(N):
    y.append(x%2)
    x = x//2
  return y
N,M = map(int,input().split())
k,s = [],[]
for _ in range(M):
  a = list(map(int,input().split()))
  k.append(a[0])
  s.append(a[1:])
p = list(map(int,input().split()))
ans = 0
for i in range(2**N):
  x = bi(i)
  k = 0
  for j in range(M):
    y = 0
    for z in s[j]:
      y += x[z-1]
    if y%2!=p[j]:
      break
    k += 1
  ans += 1 if k==M else 0
print(ans)

Measured memory_bytes: 3064
/// meowa 

#pragma GCC optimize("O3")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;

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

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

void stndrtn() {
#ifdef hitorie
    freopen(".in", "r", stdin);
#endif        
}

const bool flag = 0;

void maincode() {
    ll x;
    cin >> x;
    ll ans = 0;
    for (int i = 2; i <= sqrt(x); ++i) {
        int cnt = 0;
        while (x % i == 0) {
            cnt++;
            x /= i;
        }
        if (cnt > 0) {
            ll j = 1;
            while (j*(j+1)/2 < cnt) {
                j++;
            }
            if (j*(j+1)/2 == cnt) {
                j++;
            }
            ans += j-1;
        }
    }        
    if (x > 1) {
        ans++;
    }
    cout << ans;
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        maincode(); 
    }
    return 0;
}

Measured memory_bytes: 3692
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from collections import deque

H,W = map(int,readline().split())
H += 2; W += 2
grid = '#' * W
for _ in range(H-2):
    grid += '#' + readline().rstrip().decode() + '#'
grid += '#' * W

def bfs(start):
    INF = 10 ** 9
    dist = [INF] * (H*W)
    dist[start] = 0
    q = deque([start])
    while q:
        v = q.popleft()
        dv = dist[v]
        for move in (-1,1,W,-W):
            w = v + move
            if grid[w] == '#':
                continue
            dw = dv + 1
            if dw >= dist[w]:
                continue
            dist[w] = dw
            q.append(w)
    return max(x for x in dist if x < INF)

answer = max(bfs(v) for v in range(H*W) if grid[v] != '#')
print(answer)

Measured memory_bytes: 3316
# include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const int N = 105;
const i64 INF = 1e9;
const int MOD = 323232323;

vector<int> E[N];
int edge[N][2], dep[N], dee[N];
i64 ans = INF, node;

int dfs(int x, int fa, int d) {
    int sz = 0;
    for (auto i: E[x]) {
        if (i == fa) continue;
        ++sz;
        dfs(i, x, d + 1);
    }
    dep[d] = max(dep[d], sz);
}
int main ()
{
    int n, u, v;
    scanf("%d", &n);
    for (int i = 1; i < n; ++i) scanf("%d %d", &edge[i][0], &edge[i][1]), E[edge[i][0]].push_back(edge[i][1]), E[edge[i][1]].push_back(edge[i][0]), ++dee[edge[i][0]], ++dee[edge[i][1]];
    for (int i = 1; i <= n; ++i) {
        memset(dep, -1, sizeof(dep));
        dfs(i, 0, 1);
        i64 tmp = 1;
        int p = -1;
        for (int i = n; i >= 1; --i) {
            if (dep[i] != -1 && p == -1) p = i;
            if (dep[i] != -1 && p != -1 && i < p) {
                tmp = tmp * dep[i];
            }
        }
        if (dee[i] == 1) ++tmp;
        if (ans > p) ans = p, node = tmp;
        else if (ans == p) node = min(node, tmp);
    }
    for (int i = 1; i < n; ++i) {
        u = edge[i][0]; v = edge[i][1];
        memset(dep, -1, sizeof(dep));
        dfs(u, v, 1); dfs(v, u, 1);
        i64 tmp = 1;
        int p = -1;
        for (int i = n; i >= 1; --i) {
            if (dep[i] != -1 && p == -1) p = i;
            if (dep[i] != -1 && p != -1 && i < p) {
                tmp = tmp * dep[i];
            }
        }
        if (ans > p) ans = p, node = tmp * 2;
        else if (ans == p) node = min(node, tmp * 2);
    }
    printf("%lld %lld", ans, node);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int dp[2][3001][50];
const int mod=100000;
int n,m,s;

int main(){
    while(cin>>n>>m>>s&&(n|m|s)){
        memset(dp,0,sizeof(dp));
        for(int i=0;i<2;i++)dp[i][0][n*n]=1;
        for(int i=m;i>=0;i--){
            for(int j=0;j<=s;j++){
                for(int k=n*n;k>=0;k--){
                    int cur=(i+1)%2;
                    int nxt=i%2;
                    int res=0;
                    if(k==n*n){
                        if(j==0)res=1;
                        else res=0;
                    }
                    else{
                        res+=dp[cur][j][k];
                        if(j-i>=0)res+=dp[cur][j-i][k+1];
                    }
                    dp[nxt][j][k]=res%mod;
                }
            }
        }
        cout<<dp[1][s][0]%mod<<endl;
    }
    return 0;
}

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

using ll = long long;

int main() {
    int X, A;
    cin >> X >> A;
    if (X < A) cout << 0 << endl;
    else cout << 10 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <sstream>
using namespace std;
#define ll long long
#define ff first
#define ss second
#define clr(a) memset(a, 0, sizeof(a))
#define set(a) memset(a, -1, sizeof(a))
#define pb push_back
#define sz(a) ((ll)a.size())
#define all(a) a.begin(), a.end()
#define mp make_pair
#define rep(i, a, y) for (ll i = a; i <= y; i++)
#define rep2(i, b) for (ll i = 0; i < b; i++)
#define repl(i, a, b) for (ll i = a; i <= b; i++)
#define ppi pair<int, int>
#define scl(x) scanf("%d", &x)
#define pcl(x) printf("%d", x)
#define FastRead                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0)
/*
 
     ██╗██╗   ██╗██╗  ██╗ █████╗ ███╗   ██╗
     ██║██║   ██║██║  ██║██╔══██╗████╗  ██║
     ██║██║   ██║███████║███████║██╔██╗ ██║
██   ██║██║   ██║██╔══██║██╔══██║██║╚██╗██║
╚█████╔╝╚██████╔╝██║  ██║██║  ██║██║ ╚████║
 ╚════╝  ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝  ╚═══╝
 
*/
map<string,int> p;
int main()
{
    FastRead;
    int n;
    cin>>n;
    string a,b;
    cin>>a>>b;
    for(int i=0;i<n;i++)
    {
        cout<<a[i]<<b[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 100000 + 10000;

int n;
int a[MAXN], fa[MAXN];
long long b[MAXN];
vector<int> edg[MAXN];

void yes()
{
	cout << "YES" << endl;
	exit(0);
}

void no()
{
	cout << "NO" << endl;
	exit(0);
}

void dfs(int x, int father)
{
	fa[x] = father;
	b[x] = edg[x].size() > 1 ? 2 * a[x] : a[x];
	for(int i = 0; i < edg[x].size(); i++)
		if(edg[x][i] != fa[x])
		{
			int y = edg[x][i];
			dfs(y, x);
			b[x] -= b[y];
		}
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	for(int i = 1; i <= n - 1; i++)
	{
		int x, y;
		cin >> x >> y;
		edg[x].push_back(y), edg[y].push_back(x);
	}
	dfs(1, 0);
	if(b[1] != 0)
		no();
	for(int i = 1; i <= n; i++)
		if(b[i] < 0)
			no();
	for(int i = 1; i <= n; i++)
		if(edg[i].size() > 1)
		{
			if(b[i] > a[i]) no();
			for(int j = 0; j < edg[i].size(); j++)
				if(edg[i][j] != fa[i])
					if(b[edg[i][j]] > a[i])
						no();
		}
	yes();

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> x(n), y(n);
  REP(i,n) cin >> x[i] >> y[i];
  auto dist = [&](int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return sqrt(dx*dx + dy*dy);
  };
  vector<int> p(n);
  REP(i,n) p[i] = i;
  int cnt = 0;
  double ren = 0;
  do {
    REP(i,(n-1)){
      ren += dist(p[i],p[i+1]);
    }
    cnt++;
  } while(next_permutation(p.begin(), p.end()));

  double ans = ren/cnt;
  printf("%.8f\n", ans);
  return 0;
}


Measured memory_bytes: 3816
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
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

C = input()

print(chr(ord(C)+1))

Measured memory_bytes: 59500
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K;
  cin >> K;
  int A, B;
  cin >> A >> B;
  if ((A - 1) / K == B / K){
    cout << "NG" << endl;
  } else {
    cout << "OK" << endl;
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

signed main() {
    int n;
    cin >> n;
    vector<pair<int, int> > v(n);
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        v[i] = make_pair(x, i);
    }
    sort(v.begin(), v.end());
    vector<int> res(n);
    for (int i = 0; i < n; i++) {
        if (i < n / 2) {
            res[v[i].second] = v[n / 2].first;
        }
        else {
            res[v[i].second] = v[n / 2 - 1].first;
        }
    }
    for (auto&& x : res) {
        cout << x << "\n";
    }
}

Measured memory_bytes: 6912