akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <chrono> 
 
using namespace std;
using namespace std::chrono; 
 
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
// #pragma optimization_level 3
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define f0r(a, b) for (long long a = 0; a < (b); ++a)
#define f1r(a, b, c) for (long long a = (b); a < (c); ++a)
#define f0rd(a, b) for (long long a = (b); a >= 0; --a)
#define f1rd(a, b, c) for (long long a = (b); a >= (c); --a)
#define ms(arr, v) memset(arr, v, sizeof(arr))
#define pb push_back
#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL); cout.tie(NULL);}
#define fix(prec) {cout << setprecision(prec) << fixed;}
#define mp make_pair
#define f first
#define s second
#define presum(p, a, n) {p[0] = a[0]; for (int i = 1; i < (n); i++) p[i] = a[i] + p[i-1];}
#define all(v) v.begin(), v.end()
#define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());}
#define readgraph(list, edges) for (int i = 0; i < edges; i++) {int a, b; cin >> a >> b; a--; b--; list[a].pb(b); list[b].pb(a);}
#define ai(a, n) for (int ele = 0; ele < n; ele++) cin >> a[ele];
#define ain(a, lb, rb) for (int ele = lb; ele <= rb; ele++) cin >> a[ele];
#define ao(a, n) {for (int ele = 0; ele < (n); ele++) { if (ele) cout << " "; cout << a[ele]; } cout << '\n';}
#define aout(a, lb, rb) {for (int ele = (lb); ele <= (rb); ele++) { if (ele > (lb)) cout << " "; cout << a[ele]; } cout << '\n';}
typedef long long ll;
typedef double ld;
typedef long double lld;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
 
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
  cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
  cin >> p.first;
  return cin >> p.second;
}
 
mt19937 rng(steady_clock::now().time_since_epoch().count());
// mt19937 rng(61378913);
/* usage - just do rng() */
 
void usaco(string filename) {
  // #pragma message("be careful, freopen may be wrong")
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}
 
const lld pi = 3.14159265358979323846;
const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;

ll n, m;

void solve(int tc) {
  cin >> m >> n;
  ll x = 0;
  f0r(i, n) {
    ll y; cin >> y; x += y;
  }
  cout << (x >= m ? "Yes\n" : "No\n");
}
 
int main() {
  send help
 
  // usaco("file");

  
 
  int tc;
  tc = 1;
  // cin >> tc;
  for (int t = 0; t < tc; t++) solve(t);
} 

Measured memory_bytes: 3624
n,m,k=map(int,open(0).read().split())
p=998244353
'''
c=[1]*(k+1)
for i in range(1,k+1):
  c[i]=c[i-1]*(n-i)//i
  c[i-1]%=mod
'''
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 998244353
N = n  # N は必要分だけ用意する
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
ans=0
for i in range(k+1):
  ans+=m*pow(m-1,n-1-i,p)*cmb(n-1,i, p)
  ans%=p
print(ans)

Measured memory_bytes: 32776
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define MOD 1000000007

using namespace std;

ll N;
#define N1 51

void mul(ll res[N1][N1], ll m1[N1][N1], ll m2[N1][N1])
{
    ll temp[N1][N1];
    memset(temp,0,sizeof(temp));
    for(ll i=0;i<N;i++)
        for(ll j=0;j<N;j++)
            for(ll k=0;k<N;k++)
            {
                temp[i][j]+=(m1[i][k]*m2[k][j])%MOD;
                temp[i][j]%=MOD;
            }
    for(ll i=0;i<N;i++)
        for(ll j=0;j<N;j++)
            res[i][j] = temp[i][j];
                
}

void powa(ll mat[N1][N1], ll n)
{
   ll res[N1][N1];
   memset(res,0,sizeof(res));
   for(ll i=0;i<N;i++)
        for(ll j=0;j<N;j++)
            if(i == j)
                res[i][j] = 1;
   
   while(n>0)
   {
       if(n%2 == 1)
           mul(res,res,mat);
       
       n>>=1;
       mul(mat,mat,mat);
   }
   
   for(ll i=0;i<N;i++)
        for(ll j=0;j<N;j++)
            mat[i][j] = res[i][j];
    
}

int main()
{
   FAST/**/
   
   ll n,k;
   cin>>n>>k;
   
   N = n;
   
   ll mat[51][51];
   
   for(ll i=0;i<n;i++)
        for(ll j=0;j<n;j++)
            cin>>mat[i][j];
            
   
   powa(mat,k);
   ll ans = 0;
   for(ll i=0;i<n;i++)
        for(ll j=0;j<n;j++)
            ans+=mat[i][j], ans%=MOD;
   
   cout<<ans;            
               
   
   return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <tuple>
#include <queue>
#include <stack>
#include <functional>
#include <utility>
#include <complex>
#include <bitset>
#include <numeric>
#include <random>
using namespace std;

//make_tuple emplace_back next_permutation
#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define SE second
#define FI first
#define DBG(...) string s999;s999=#__VA_ARGS__;replace(ALL(s999),',',' ');stringstream ds999; ds999<<s999; debug(ds999,__VA_ARGS__);
inline void debug(stringstream& ds){cerr<<endl;return;}
template<typename F, typename... R>void debug(stringstream& ds,const F& f, const R&... r){string n; ds>>n; cerr<< n <<' '<<f<<' '; debug(ds,r...);}
#define ALL(v) (v).begin(),(v).end()
#define SI(v) (int)(v).size()
typedef long long LL;  typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
typedef pair<int,int>PI; typedef vector<int> VI;
const LL LINF=334ll<<53; const int INF=15<<26; const LL MOD=1E9+7;
struct Edge{
    int from,to;
    Edge(int from,int to)
        : from(from),to(to) {};
};
typedef vector<vector<Edge>> Graph;
int k;

int defineDepth(Graph &T, vector<int> &p, vector<int> &dep,int root,int root2){
    int ret =0;
    queue<int> Q;
    Q.push(root);
    Q.push(root2);
    p[root]=root;
    p[root2]=root2;
    while(!Q.empty()){
        int nex=Q.front();
        Q.pop();
        for(auto &x: T[nex]){
            if(p[x.to]==-1){
                p[x.to]=x.from;
                Q.push(x.to);
                dep[x.to]=dep[x.from]+1;
                if(dep[x.to]>k/2) ++ret;
            }
        }
    }
    return ret;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n >> k;
    Graph t(n);
    REP(i,n-1){
        int a,b;
        cin >> a >> b;
        --a;--b;
        t[a].push_back(Edge(a,b));
        t[b].push_back(Edge(b,a));
    }
    int ans=INF;
    REP(i,n){
        REP(j,t[i].size()+1){
            vector<int> vis(n,-1),dep(n);
            if(k%2==0 and j==t[i].size()){
                ans=min(ans,defineDepth(t,vis,dep,i,i));
            }else if(k%2==1 and j<t[i].size() and i<t[i][j].to){
                ans=min(ans,defineDepth(t,vis,dep,i,t[i][j].to));
            }
            //DBG(i,j,ans)
        }
    }
    cout << ans <<endl;

    return 0;
}


Measured memory_bytes: 384
import sys

def f(s):
    if s=="A":
        return 0
    elif s=="B":
        return 1
    else:
        return 2

S=list(map(f,input()))
N=len(S)

if N<=2:
    print(0)
    sys.exit()

T=0
U=0

I=0
K=0
while I<N-2:
    if (S[I]==0) and (S[I+1]==1) and (S[I+2]==2):
        U+=1
        T+=U
        I+=3
    elif S[I]==0:
        U+=1
        I+=1
    elif (S[I]==1) and (S[I+1]==2):
        T+=U
        I+=2
    else:
        U=0
        I+=1

if (S[-2]==1 and S[-1]==2) and S[-3]!=0:
    T+=U
    
print(T)


Measured memory_bytes: 54112
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

int gcd(int a, int b){
	if (b == 0)return a;
	return gcd(b, a % b);
}


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

    vector<int> l(n);

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

    sort(l.begin(), l.end(), greater<int>());

    int total = 0;
    for(int i = 1; i < n; i++){
        total += l[i];
    }

    if(l[0] < total){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    
}



Measured memory_bytes: 256
from collections import defaultdict, deque

d = defaultdict(int)

n = int(input())

count = 0
for i in range(n):
    a = int(input())
    if d[a] == 1:
        count = max(count - 1, 0)
        d[a] = 0
    else:
        d[a] = 1
        count += 1

print(count)



Measured memory_bytes: 15460
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N,A,B;

signed main(){
	cin>>N>>A>>B;
	int R=A+B;
	int m=N%R,r=N/R;
	if(m<=A){
		cout<<r*A+m<<endl;
	}
	else{
		cout<<r*A+A<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <cctype>
#include <string>
#include <vector>
#include <algorithm>

using MinMax = std::pair<int, int>;

constexpr int INF=1<<29;
constexpr MinMax INIT(INF, -INF);

std::vector<std::vector<MinMax>> memo;

MinMax rec(const std::string& s, size_t left, size_t right) {
  MinMax& res=memo[left][right];
  if (res != INIT) return res;

  if (right == left+1) {
    int v=s[left]-'0';
    return (res = {v, v});
  }
  if (s[left] == '(' && right-left > 3) {
    MinMax p=rec(s, left+1, right);
    res.first = std::min(res.first, p.first);
    res.second = std::max(res.second, p.second);
  }
  if (s[right-1] == ')' && right-left > 3) {
    MinMax p=rec(s, left, right-1);
    res.first = std::min(res.first, p.first);
    res.second = std::max(res.second, p.second);
  }
  for (size_t i=left+1; i+1<right; ++i) {
    char op=s[i];
    if (op == '+' || op == '-') {
      MinMax pl=rec(s, left, i);
      MinMax pr=rec(s, i+1, right);
      if (op == '+') {
        res.first = std::min(res.first, pl.first+pr.first);
        res.second = std::max(res.second, pl.second+pr.second);
      } else {
        res.first = std::min(res.first, pl.first-pr.second);
        res.second = std::max(res.second, pl.second-pr.first);
      }
    }
  }
  return res;
}

int main() {
  char buf[256];
  scanf("%s", buf);
  std::string S=buf;

  size_t n=S.length();
  memo.assign(n+1, std::vector<MinMax>(n+1, INIT));
  
  printf("%d\n", rec(S, 0, n).second);
}



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

typedef int_fast32_t int32;
typedef int_fast64_t int64;

const int32 inf = 1e9+7;
const int32 MOD = 1000000007;
const int64 llinf = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define all(obj) (obj).begin(),(obj).end()
#define rall(obj) (obj).rbegin(),(obj).rend()
#define fi first
#define se second
#define pb(a) push_back(a)
typedef pair<int32,int32> pii;
typedef pair<int64,int64> pll;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n;
  cin >> n;
  int32 cnt = 0;
  REP(i,n){
    int32 d1,d2;
    cin >> d1 >> d2;
    if(d1 == d2){
      ++cnt;
    }else{
      cnt = 0;
    }
    if(cnt >= 3){
      Yes(true);
      return 0;
    }
  }
  Yes(false);
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  int N;cin>>N;vi x(N),y(N),t(N);rep(i,N)cin>>t[i]>>x[i]>>y[i];
  vi z(N);z[0]=x[0]+y[0];
  for(int i=1;i<N;i++){
    z[i]=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
  }
  vi tt(N);tt[0]=t[0];f(i,1,N)tt[i]=t[i]-t[i-1];
  bool ok=true;
  for(int i=0;i<N;i++){
    if(z[i]>tt[i] || z[i]%2!=tt[i]%2){
      ok=false;
    }
  }
  if(ok)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}







Measured memory_bytes: 2176
import sys, array, re, functools
input = lambda: sys.stdin.readline()
@functools.lru_cache(maxsize = 10000)

def Main():
  a, b = map(int, input().split())
  ans  = a + b
  if( ans < 24):
    print(ans)
  elif ans  == 24:
    print(0)
  else:
    print(ans - 24)
  
if __name__ == '__main__':
  Main()

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

typedef vector<double> Vect;
typedef vector<Vect> Matrix;
const double EPS = 1e-8;

int rank_of_matrix(Matrix M){
    int H = M.size();
    int W = M[0].size();
    int cy, cx;
    for(cy = 0, cx = 0; cy < H && cx < W; cy++, cx++){
        for(int y = cy + 1; y < H; y++){
            if(abs(M[cy][cx]) < abs(M[y][cx])){
                swap(M[cy], M[y]);
            }
        }
        if(abs(M[cy][cx]) < EPS){
            cy--;
            continue;
        }
        for(int y = cy + 1; y < H; y++){
            double p = M[y][cx] / M[cy][cx];
            for(int x = cx; x < W; x++){
                M[y][x] -= p * M[cy][x];
            }
        }
    }
    return cy;
}

int main(){
    int N, M;
    while(cin >> N >> M){
        Matrix Mat(N, Vect(M));
        for(int i = 0; i < M; i++){
            int s, t;
            cin >> s >> t;
            s--; t--;
            Mat[s][i] += 1.0;
            Mat[t][i] -= 1.0;
        }
        cout << M - rank_of_matrix(Mat) << endl;
    }
    return 0;
}

Measured memory_bytes: 24492
#!/usr/bin/env python
import math

def main():
    t8, t10 = map(int, input().split())

    notax = math.ceil(max(t8 / 0.08, t10 / 0.1))
    nt_max = min((t8 + 1) / 0.08, (t10 + 1) / 0.1)

    if notax < nt_max:
        print(notax)
    else:
        print(-1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#include<ctype.h>
int main() {
	int i, len, c, flag = 0;;
	char S[11];
	scanf("%s", S);
	len = strlen(S);
	if (S[0] == 'A') {
		for (i = 2; i <= (len - 2); i++) {
			if (S[i] == 'C') {
				flag = 1;
				c = i;
				break;
			}
		}
		if (flag == 1) {
			for (i = 1; i <= len; i++) {
				if (i == c) {
					continue;
				}
				if (isupper(S[i]) != 0) {
					printf("WA\n");
					return 0;
				}
			}
			printf("AC\n");
			return 0;
		}
	}
	printf("WA\n");
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
Q = int(input())
prime = [0] + [1] * 10**5
prime[1] = 0
c = [0]
for i in range(1, 10**5 + 1):
    if prime[i]:
        c.append(c[-1] + prime[(i + 1) // 2])
        if i <= 10**2.5:
            for j in range(2, 10**5 // i+1):
                prime[j * i] = 0
    else:
        c.append(c[-1])
for i in range(Q):
    l, r = map(int, input().split())
    print(c[r] - c[l-1])


Measured memory_bytes: 81180
#include<bits/stdc++.h>
#define N 100000010
//#define int long long
#define INF 1e9
#define rep(i, l, r) for(register int i = l; i <= r; ++ i)
using namespace std;
inline int read()
{
	register char cc = getchar();register int cn(0), flus(1);
	while(cc > '9' || cc < '0') {if(cc == '-') flus = -flus; cc = getchar();}
	while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - '0'; cc = getchar();}
	return cn * flus;
}
signed main()
{
	int n = read(), k = read(), s = read();
	rep(i, 1, k) printf("%d ",s);
	if(s < 1e9)
	{
		rep(i, k + 1, n) printf("1000000000 ");
	}
	else rep(i, k + 1, n) printf("1 ");
	putchar(10);
	return 0;
}

Measured memory_bytes: 1280
package main

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

const mod = 1000000007
var sc = bufio.NewScanner(os.Stdin)

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

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

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

	x := nextInt()
	for {
		if isPrime(x) {
			fmt.Println(x)
			return
		}
		x++
	}
}

func isPrime(x int) bool {
	for i := 2; i*i <= x; i++ {
		if x % i == 0 {
			return false
		}
	}
	return true
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <queue>
#include <list>
#include <string>
using namespace std;

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

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

int main()
{
    string s;
    int min = 753;
    cin >> s;
    for(int i=0;i<s.size()-2;i++){
        int range = abs(ctoi(s[i])*100 + ctoi(s[i+1])*10 + ctoi(s[i+2]) - 753);
        if(range < min) min = range;
    }
    cout << min;
}


Measured memory_bytes: 256
if __name__ == "__main__":

    n, m = map(int, raw_input().split())

    b = [0] * m
    A = [0] * m * n

    for i in xrange(n):
        A[i*m:i*m+m] = map( int, raw_input().split())

    for i in xrange(m):
        b[i] = int(raw_input())

    c = [0] * n
    for i in xrange(n):
        for j in xrange(m):
            c[i] += A[i*m + j] * b[j]

    for i in xrange(n):
        print c[i]

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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, op_cnt;
  cin >> n >> op_cnt;
  vector<int> va(n);
  for (auto &a : va) {
    cin >> a;
  }

  for (int i = 0; i < op_cnt; ++i) {
    vector<int> vaa(va.size(), 0);
    for (int j = 0; j < va.size(); ++j) {
      int a = va[j];
      int l_idx = max(0, j - a);
      vaa[l_idx]++;
      int r_idx = j + a + 1;
      if (r_idx < vaa.size()) {
        vaa[r_idx]--;
      }
    }

    va[0] = vaa[0];
    for (int j = 1; j < vaa.size(); ++j) {
      va[j] = va[j - 1] + vaa[j];
    }

    int min_el = *min_element(va.begin(), va.end());
    if (min_el >= n) {
      break;
    }
  }

  for (int j = 0; j < va.size(); ++j) {
    cout << va[j];
    if (j == va.size() - 1) {
      cout << '\n';
    } else {
      cout << ' ';
    }
  }
  return 0;
}

Measured memory_bytes: 4840
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;

int main(void) {

	int w;
	string s;

	cin >> s >> w;

	for (int i = 0; i < s.size(); i+=w)
	{
		cout << s[i];
	}

	cout << "\n";


	return 0;
}

Measured memory_bytes: 256
l = 12
def island(f,x,y,m):
    rf = f[:][:]
    if rf[y][x] == 1:
        rf[y][x] = m
        for i in [-1,1]:
            if 0 <= x+i <= l-1:
                rf = island(rf,x+i,y,m)
            if 0 <= y+i <= l-1:
                rf = island(rf,x,y+i,m)
    return rf

while True:
    f = []
    m = 2
    for i in range(l):
        f.append(map(int, list(raw_input())))
    for y in range(l):
        for x in range(l):
            f = island(f,x,y,m)
            m += 1

    ans = []
    for i in range(l):
        for j in range(l):
            ans.append(f[i][j])
    ans = list(set(ans))
    if ans.count(0) == 1:
        print len(ans) - 1
    else:
        print len(ans)
    try   : raw_input()
    except: break

Measured memory_bytes: 4336
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000001
using namespace std;
vector<int> arr(MAXX);
void trozen()
{
    int n,m;
    cin>>n>>m;
   if((n-2>=0&&(m-2)>=0)) cout<<((n-2)*(m-2))<<endl;
   else
   {
       n=max(1ll,n-2);
       m=max(1ll,m-2);
       cout<<(n*m)<<endl;
   }

}
int32_t main()
{
    op1;op2;op3;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    trozen();
    return 0;
}


Measured memory_bytes: 11000
n, x = map(int, input().split())
A = list(map(int, input().split()))

A.sort()
RA = []
q = 0
for i in range(n):
    q += A[i]
    RA.append(q)

if RA[-1] < x:
    ans = n - 1
elif RA[-1] == x:
    ans = n
elif RA[0] > x:
    ans = 0
else:
    for i in range(n):
        if RA[i] == x:
            ans = i + 1
            break
        elif RA[i] > x:
            ans = i
            break

print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
int main(void){
	int len1,len2,i,a,b;
	char o[51],e[51];
	scanf("%s %s",o,e);
	len1=strlen(o);
	len2=strlen(e);
	a=0; b=0;
	for(i=1;i<=len1+len2;i++){
		if(i%2==1){
			printf("%c",o[a]);
			a++;
		}
		else{
			printf("%c",e[b]);
			b++;
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        d: usize
    }
    println!("{}", (n - 1) / (2 * d + 1) + 1);
}


Measured memory_bytes: 4352
//AtCoder ABC082 C - Good Sequence
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;

int main() {
#if LOCAL&0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N;
    cin>>N;
    vector<ll> atbl(N);
    unordered_map<ll,ll> anums;
    for(auto&& a:atbl){
        cin>>a;
        ++anums[a];
    }
    ll ans=0;
    for(auto&& t:anums){
        if(t.first>t.second){
            ans+=t.second;
        } else if(t.first<t.second){
            ans+=(t.second-t.first);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5028
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();
		int[] X = new int[N];

		for(int i=0;i<N;i++) {
			X[i]=sc.nextInt();
		}
		Arrays.sort(X);

		int min=Integer.MAX_VALUE;
		for(int i=0;i<=X[N-1]+10;i++) {
			int d=0;
			for(int j=0;j<N;j++) {
				d+=(X[j]-i)*(X[j]-i);
			}
			if(d<min) {
				min=d;
			}
		}
		System.out.println(min);
	}
}


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

using namespace std;

string s1;
string s2;

int gcd(int a, int b)
{
	return a%b ? gcd(b,a%b) : b;
}

int main(void)
{
	int n,m; cin >> n >> m;
	cin >> s1 ; cin >> s2;
	int dvd = gcd(n,m);
	n /= dvd; m/=dvd;
	int pos1 = 1, pos2 = 1;
	bool check = true;
	while(pos1<=n*dvd)
	{
		if(s1[pos1-1]!=s2[pos2-1])
		{
			cout << -1;
			return 0;
		}
		pos1+=n; pos2+=m;
	}
	cout << (long long)n*m*dvd;
	return 0;
}

Measured memory_bytes: 512
s = str(input())
t = str(input())

ds = {}
dt = {}

for i in range(len(s)):
    if s[i] not in ds:
        ds[s[i]] = 1
    else:
        ds[s[i]] += 1

for i in range(len(t)):
    if t[i] not in dt:
        dt[t[i]] = 1
    else:
        dt[t[i]] += 1

vs = list(ds.values())
vt = list(dt.values())

vs.sort()
vt.sort()
#print(vs)
#print(vt)

if vs == vt:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 41676
// https://atcoder.jp/contests/diverta2019-2/tasks/diverta2019_2_b
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<pii> v(N);
    REP(i, N) cin >> v[i].first >> v[i].second;
    sort(ALL(v));
    int ans = N;
    for (int i = 0; i < N - 1; i++) {
        for (int j = 0; j < N; j++) {
            if (i == j)
                continue;
            int p = v[i].first - v[j].first;
            int q = v[i].second - v[j].second;
            int cnt = 0;
            for (int k = 0; k < N; k++) {
                for (int l = k + 1; l < N; l++) {
                    if (v[k].first - v[l].first == p &&
                        v[k].second - v[l].second == q) {
                        cnt++;
                    }
                }
            }
            ans = min(ans, N - cnt);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,l;
    cin>>n>>l;
    vector<string>s(n);
    for(i=0;i<n;i++)
    {
        cin>>s[i];
    }
    sort(s.begin(),s.end());
    for(i=0;i<n;i++)
    {
        cout<<s[i];
    }
    cout<<endl;
    return 0;
}


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

int main(){
	string s ; cin >> s ;
	for(int i=s.size()-3;i>=0;i--){
		if(i%2==0) continue ;
		bool ok = true ;
		for(int j=i;j>=(i+1)/2;j--){
			if(s.at(j)!=s.at(j-(i+1)/2)){
				ok = false ;
				break ;
			}
		}
		if(ok){
			cout << i+1 << endl ;
			return 0 ;
		}
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
int tmp[200000];
vector<int>G[200000];
void dfs(int v){
    for(int i=0;i<G[v].size();i++){
        if(tmp[G[v][i]]==0){
            tmp[G[v][i]]=-tmp[v];
            dfs(G[v][i]);
        }
    }
}
signed main(){
    int n,a,b;
    cin>>n;
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        a--,b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    tmp[0]=1;
    dfs(0);
    vector<int>odd,even;
    for(int i=0;i<n;i++)
        if(tmp[i]==1)
            odd.push_back(i);
        else
            even.push_back(i);
    int ans[200000];
    vector<int>odd2,even2;
    if(odd.size()<=n/3)
        for(int i=1;i<=n;i++)
            (i%3==0&&i/3<=odd.size()?odd2:even2).push_back(i);
    else if(even.size()<=n/3)
        for(int i=1;i<=n;i++)
            (i%3==0&&i/3<=even.size()?even2:odd2).push_back(i);
    else
        for(int i=1;i<=n;i++)
            (i%3==1||i%3==0&&i/3<=odd.size()-(n+2)/3?odd2:even2).push_back(i);
    for(int i=0;i<odd.size();i++)
        ans[odd[i]]=odd2[i];
    for(int i=0;i<even.size();i++)
        ans[even[i]]=even2[i];
    for(int i=0;i<n;i++)
        cout<<ans[i]<<(i+1==n?'\n':' ');
}


Measured memory_bytes: 23788
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s = in.nextString().toCharArray();

			Map<Character, Integer> map = new HashMap<>();
			for (char c : s) {
				map.merge(c, 1, Integer::sum);
			}

			boolean ok = true;
			for (char c : map.keySet()) {
				if (map.get(c) % 2 == 0) continue;
				ok = false;
			}

			out.println(ok ? "Yes" : "No");
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 27220
package main

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

var N int
var A int
var B int

func main() {
	N = nextInt()
	A = nextInt()
	B = nextInt()

	maxSub := Min(A, B)
	minSub := 0
	if (A + B) > N {
		minSub = A + B - N
	}
	fmt.Printf("%v %v", maxSub, minSub)
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

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

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

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

func Abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(void){
  int W,H,N;
  cin>>W>>H>>N;
  int P[110][110]={};
  for(int i=1;i<=W;i++){
      for(int j=0;j<H;j++)
          P[i][j]=1;
  }
  for(int i=0;i<N;i++){
      int x,y,a;
      cin>>x>>y>>a;
      if(a==1){
          for(int j=1;j<=x;j++){
              for(int k=0;k<H;k++)
                  P[j][k]=0;
          }
      }
      else if(a==2){
           for(int j=x+1;j<=W;j++){
              for(int k=0;k<H;k++)
                  P[j][k]=0;
          }
      }
      else if(a==3){
           for(int j=1;j<=W;j++){
              for(int k=0;k<y;k++)
                  P[j][k]=0;
          }
      }
      else{
           for(int j=1;j<=W;j++){
              for(int k=y;k<H;k++)
                  P[j][k]=0;
          }
      }
  }
  int count=0;
  for(int i=0;i<=W;i++){
      for(int j=0;j<=H;j++){
          if(P[i][j]==1)
              count+=1;
      }
  }
  cout<<count<<endl;
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
count=0
minNum=1000000001
for i in range(N):
    if A[i]<0:
        count+=1
        A[i]*=-1
    minNum=min(minNum,A[i])
if count%2==1:
    print(sum(A)-minNum*2)
else:
    print(sum(A))

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

int main() {

	ll n, m, d; cin >> n >> m >> d;
	double ans;
	if (d == 0) {
		ans = (double)1 / n * (m - 1);
	}
	else {
		ans = (double)2 * (n - d) / n / n * (m - 1);
	}
	cout << fixed << setprecision(11) << ans << endl;
    return 0;
}

Measured memory_bytes: 3740
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://agc001.contest.atcoder.jp/tasks/agc001_b>
問題文============================================================
 高橋君は 1 辺の長さが N の 3 枚の鏡を正三角形状に組み合わせました。 三角形の頂点をそれぞれ a,b,c とします。
 
 高橋君は、辺 ab 上の頂点 a から X の点から、辺 bc と平行に不思議な光を発射しました。
 不思議な光は、普通の光と同じように真っすぐ進み、鏡に当たると反射するのですが、
 不思議な光がすでに通った点に当たったときにも反射をします。
 
 不思議な光を発射した時、不思議な光は必ず発射した点に戻ってくることが証明できます。
 このとき、光の軌跡の長さが全体でいくらになるかを求めて下さい。

=================================================================

解説=============================================================

 制約から値が大きいので、貪欲に行うと部分点は得ることができるかもしれないが、
 満点は難しい
 
 よって頑張って規則性を見出す
 
 問題の図をよく見ると、軌跡の道中で光の開始点が等しい、いくつかの平行四辺形ができているのがわかる
 
 例えば 光が一回反射して、次の壁に当たった時（移動距離がNの時)
 光の開始点が右下で 上(下）辺が X , 斜辺が N - X の平行四辺形ができる
 
 そして、その次、光が最初から4回反射した時
 光の開始点が右下で 上(下）辺が X , 斜辺が N - X - (N - (N - X)) の平行四辺形ができる
 
 
 ここでこういった平行四辺形について考察を進めると
 上(下)辺が a , 斜辺が b とした時
 
 if a <= b then
     次の平行四辺形に映るまでの光の移動距離 = (b/a) * 2 * a
     次の平行四辺形の形 : a = a , b = b - b/a * a
 else
     a <= b の場合の条件式を a,bに関した逆転させた式
 
 ということがわかる
 
 最後に、最初の光の発射点に戻るということは a or b が 0になることであり
 各々の条件式において b%a == 0 となることであるため、これで終端の判定ができる
 また、その時の移動距離は 平行四辺形の光の開始点が右下なため、 1本分光の距離が長いので
 その分を考慮してやれば答えになる
================================================================
*/
ll solve(){
    ll ret = 0;
    ll N,X; cin >> N >> X;
    
    ret += N;
    ll a = X;
    ll b = N - X;
    while(true){
        if(a <= b){
            ret += b/a * 2 * a;
            if(b%a == 0){
                ret -= a;
                break;
            }
            b = b - b/a*a;
        }else{
            ret += a/b * 2 * b;
            if(a%b == 0){
                ret -= b;
                break;
            }
            a = a - a/b*b;
        }
    }
    return ret;
}
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

#ifdef DEBUG
mt19937 mrand(300); 
#else
mt19937 mrand(chrono::steady_clock::now().time_since_epoch().count()); 
#endif

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = 1005;
int n, m;
char c[maxn][maxn];

bool read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%s", c[i]);
  }
  return true;
}

const int gox[] = {1, 0, -1, 0};
const int goy[] = {0, 1, 0, -1};
int d[maxn][maxn];
vector<pair<int, int>> q;

bool inside(int x, int y) {
  return 0 <= x && x < n && 0 <= y && y < m;
}

void solve() {
  q.clear();
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      d[i][j] = inf;
      if (c[i][j] == '#') {
        d[i][j] = 0;
        q.push_back(make_pair(i, j));
      }
    }
  }
  int res = 0;
  for (int l = 0; l < sz(q); l++) {
    int x = q[l].first, y = q[l].second;
    res = max(res, d[x][y]);
    for (int dir = 0; dir < 4; dir++) {
      int nx = x + gox[dir], ny = y + goy[dir];
      if (!inside(nx, ny) || d[nx][ny] < inf) {
        continue;
      }
      d[nx][ny] = d[x][y] + 1;
      q.push_back(make_pair(nx, ny));
    }
  }
  printf("%d\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 14956
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    string s;
    cin >> s;
    sort(begin(s), end(s));
    string ans;
    if((s[0] == s[1]) && (s[1] != s[2]) && (s[2] == s[3])){
        ans = "Yes";
    }else{
        ans = "No";
    }
    cout << ans << endl;
    return 0;
}


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

template<typename T1,typename T2> void chmin(T1 &a,T2 b){if(a>b) a=b;};
template<typename T1,typename T2> void chmax(T1 &a,T2 b){if(a<b) a=b;};


Int n;
Int a[55][55];
signed main(){
  while(cin>>n,n){
    for(Int i=0;i<n;i++)
      for(Int j=0;j<n;j++)
	cin>>a[i][j];

    vector<vector<Int> > G(n+10000);
    Int x=0,y=0;
    for(Int i=0;i<n;i++)
      for(Int j=0;j<n;j++)
	if(a[x][y]<a[i][j]) x=i,y=j;

    auto add_edge=[&](Int x,Int y){
      G[x].emplace_back(y);
      G[y].emplace_back(x);
    };
    
    Int m=n;
    {
      Int lst=x;
      for(Int k=0;k+1<a[x][y];k++){
	add_edge(lst,m);
	lst=m++;
      }
      add_edge(lst,y);
    };
    vector<Int> dist,dp;
    auto bfs=[&](Int x){
      dp.assign(m,-1);
      queue<Int> q;
      dp[x]=0;
      q.emplace(x);
      while(!q.empty()){
	Int v=q.front();q.pop();
	for(Int u:G[v]){
	  if(~dp[u]) continue;
	  dp[u]=dp[v]+1;
	  q.emplace(u);
	}
      }
    };

    vector<Int> fin({x,y});
    for(Int t=0;t<n;t++){
      if(t==x||t==y) continue;
      bfs(x);
      dist=dp;
      for(Int z:fin){
	bfs(z);
	for(Int i=0;i<m;i++){
	  if(dist[i]<0) continue;
	  if(a[t][x]-dist[i]!=a[t][z]-dp[i]) dist[i]=-2;
	}
      }

      Int lst=-1;
      for(Int i=0;i<m;i++) if(dist[i]>=0) lst=i;
      Int di=a[t][x]-dist[lst];
      for(Int k=0;k+1<di;k++){
	add_edge(lst,m);
	lst=m++;
      }
      add_edge(lst,t);
      fin.emplace_back(t);
    }
    vector<Int> ans;
    for(Int i=n;i<m;i++)
      ans.emplace_back(G[i].size());
    sort(ans.begin(),ans.end());
    for(Int i=0;i<(Int)ans.size();i++){
      if(i) cout<<" ";
      cout<<ans[i];
    }
    cout<<endl;
  }
  return 0;
}




Measured memory_bytes: 3432
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define en "\n"
#define ITER(i,a) for( typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define mod 1000000007
#define mpp make_pair
#define mes(a,b) memset((a),(b),sizeof((a))
typedef map<int,int> MI;
typedef pair<int,int>   PI;
typedef vector<int> VI;
typedef long long int LL;
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s,r;
    cin>>s>>r;
    int ans=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]!=r[i])
        ans++;
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 3860
#include <stdio.h>
 
int main(void) {
  int dice[6],i,j,upside,front,q,diceside[5];
  for(i = 0; i < 6; i++)scanf("%d",&dice[i]);
  scanf("%d",&q);
 
  for(i = 0; i < q; i++){
    scanf("%d %d",&upside,&front);
    if(upside == dice[0] || upside == dice[5]){
      diceside[0] = dice[1]; diceside[4] = dice[1];
      diceside[1] = dice[2];
      diceside[2] = dice[4];
      diceside[3] = dice[3];
    }
    else if(upside == dice[1] || upside == dice[4]){
      diceside[0] = dice[0]; diceside[4] = dice[0];
      diceside[1] = dice[3];
      diceside[2] = dice[5];
      diceside[3] = dice[2];
    }
    else{
      diceside[0] = dice[0]; diceside[4] = dice[0];
      diceside[1] = dice[1];
      diceside[2] = dice[5];
      diceside[3] = dice[4]; 
    }
 
    if(upside <= dice[2]){
      for(j = 0; j < 4; j++){
        if(diceside[j] == front)printf("%d\n",diceside[j + 1]);
      }
    }
    else{
      for(j = 4; j > 0; j--){
        if(diceside[j] == front)printf("%d\n",diceside[j - 1]);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 2064
<?php
// Here your code !
$input = explode(" ",trim(fgets(STDIN)));
$a = $input[0];
$b = $input[1];

if($a < $b){
    $result = "a < b";
} elseif($a > $b){
    $result = "a > b";
} else {
    $result = "a == b";
}
echo $result;
?>

Measured memory_bytes: 15348
import java.lang.*;
import java.util.*;

public class Main
{
    static Scanner sc = new Scanner(System.in);

    public static void main(String args[])
    {
        boolean[] isPrime = new boolean[1000001];
        Arrays.fill(isPrime, true);
        isPrime[0] = false;
        isPrime[1] = false;
        for(int i=2; i*i<=1000000; i++){
            if(isPrime[i]) {
                for(int j=i*2; j<=1000000; j+=i){
                    isPrime[j] = false;
                } 
            }
        }
        
        while(true){
            int N = sc.nextInt();
            int x = sc.nextInt();
            if(N==0 && x==0) break;
            
            int[] p = new int[N+1];
            for(int i=0; i<N;i++){
                p[i] = sc.nextInt();
            }
            
            boolean[] dp = new boolean[x+1];
            dp[0]=true;
            for(int i=0; i<N; i++){
                for(int j=0; j<=x-p[i]; j++){
                    dp[j+p[i]] = dp[j] || dp[j+p[i]];
                    
                }
            }
            int ans = 0;
            for(int i=x; i>0; i--){
                if(isPrime[i] && dp[i]){
                    ans = i;
                    break;
                }
            }
            System.out.println(ans==0 ? "NA" : ans);
            
        }
    }
}

	    
	    

Measured memory_bytes: 59508
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

map<ll,ll> pfact(ll n) {
  map<ll,ll> ret;
  while(n%2==0) {ret[2]++;n/=2;}
  for(ll i=3;i*i<=n;i+=2) while(n%i==0) {ret[i]++;n/=i;}
  if(n!=1) ret[n]=1;
  return ret;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,ans=0;cin>>a>>b;
  map<ll,ll> fact,afact,bfact;
  afact=pfact(a),bfact=pfact(b);
  for(auto p:afact) fact[p.first]=min(p.second,bfact[p.first]);
  for(auto p:fact) if(p.second!=0) ans++;
  print(ans+1);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	a--; b--; c--; d--;
	string s; cin >> s;
	auto moveb = [&](){
		if(b+1 < n && s[b+1] != '#') b++;
		else if(b+2 < n && s[b+2] != '#') b += 2;
		else return false;
		return true;
	};
	if(c < d){
		while(b < d) if(!moveb()) break;
	}
	while(a < c){
		bool doOne = a+1 < n && s[a+1] != '#';
		bool doTwo = a+2 < n && s[a+2] != '#';
		if(doOne){
			if(a+1 == b){
				if(doTwo) a += 2;
				else {
					if(!moveb()) break;
					a += 1;
				}
			} else {
				a += 1;
			}
		} else if(doTwo) {
			if(a+2 == b){
				if(!moveb()) break;
			}
			a += 2;
		} else {
			break;
		}
	}
	while(b < d) if(!moveb()) break;
	if(a == c && b == d) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 640