akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 104
#define W 300004
#define INF 1e12

using namespace std;

ll n,w,ans,total;
pi ar[N];
ll dp[N][W];

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

    cin >> n >> w;

    rep(i,1,n+1)
    {
        cin >> ar[i].first >> ar[i].second;
        total+=ar[i].second;
    }

    rep(j,0,total+1)
        dp[0][j] = INF;

    dp[0][0] = 0;

    rep(i,1,n+1)
    {
        rep(j,0,total+1)
            dp[i][j] = (j < ar[i].second) ? dp[i-1][j] : min(dp[i-1][j],dp[i-1][j-ar[i].second] + ar[i].first);
    }

    rep(j,0,total+1)
        if(dp[n][j] <= w)
            ans = j;

    cout << ans;

    return 0;
}


Measured memory_bytes: 234496
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <string>
using namespace std;

int inf = (1 << 30);
int mod = 1e9;
long long long_inf = (1LL << 60);

int main(){

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

    list<int> ans;
    for(int i = 0; i < n; i++){
        if(i % 2) ans.push_front(a[i]);
        else ans.push_back(a[i]);
    }

    if(n % 2) for_each(ans.crbegin(), ans.crend(), [](const int & x){cout << x << " ";});
    else for_each(ans.cbegin(), ans.cend(), [](const int & x){cout << x << " ";});
    cout << endl;

    return 0;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef pair<int,int> pair;
#define F first
#define S second
#define pb push_back
#define PB pop_back
#define MP make_pair
#define rep(i,a,b) for (i = a; i < b; i++)
bool isPrime(int n) 
{ 
    
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
  
    
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
} 
ll binaryToDecimal(ll n) 
{ 
    ll num = n; 
    ll dec_value = 0; 
  
    
    ll base = 1; 
  
    ll temp = num; 
    while (temp) { 
        ll last_digit = temp % 10; 
        temp = temp / 10; 
  
        dec_value += last_digit * base; 
  
        base = base * 2; 
    } 
  
    return dec_value; 
}    

int main(){
ios::sync_with_stdio(0);
cin.tie(0);
	
	 int a,b;
	 cin>>a>>b;
	 cout<<6-a-b<<endl;
	return 0;
	}

Measured memory_bytes: 256
#include<stdio.h>

#define min(a, b) ((a) < (b) ? (a) : (b))

long long f(long long b, long long n){
  long long ret = 0;
  while(n){
    ret += n % b;
    n /= b;
  }
  return ret;
}

int main(){
  long long n, s;
  scanf("%lld%lld", &n, &s);
  
  long long ans = -1;
  if(n == s) ans = n + 1;
  for(long long b = 2; b * b <= n; ++b){
    if(f(b, n) == s){
      ans = b;
      break;
    }
  }
  
  for(long long a1 = 1; a1 <= s && a1 * a1 <= n; ++a1){
    long long a0 = s - a1;
    
    if((n - a0) % a1) continue;
    
    long long b = (n - a0) / a1;
    if(a0 >= b || a1 >= b) continue;
    
    if(ans >= 0) ans = min((n - a0) / a1, ans);
    else ans = (n - a0) / a1;
  }
  
  printf("%lld\n", ans);
  
  return 0;
}

Measured memory_bytes: 1704
N, M, X, Y = map(int, input().split())
x = [0]*N
y = [0]*M
x = list(map(int,input().split()))
y = list(map(int,input().split()))

x.append(X)
y.append(Y)
if max(x) < min(y):
    print("No War")
else:
    print("War")


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include <algorithm>
 
using namespace std;
 
int main(){
  string s;
  cin >> s;
  
  if(s == "SUN"){
      cout << 7;
  } 
  if(s == "MON"){
      cout << 6;
  } 
  if(s == "TUE"){
      cout << 5;
  } 
  if(s == "WED"){
      cout << 4;
  }
  if(s == "THU"){
      cout << 3;
  }
  if(s == "FRI"){
      cout << 2;
  } 
  if(s == "SAT"){
      cout << 1;
  } 
  
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    A[i] -= (i + 1);
  }
  sort(A.begin(), A.end());
  ll b = A[N / 2], ans = 0;
  for (int i = 0; i < N; i++) {
    ans += abs(A[i] - b);
  }
  if (N % 2 == 0) {
    ll ans2 = 0;
    b = A[(N + 1) / 2];
    for (int i = 0; i < N; i++) {
      ans2 += abs(A[i] - b);
    }
    ans = min(ans, ans2);
  }
  cout << ans << endl;
}


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

int main(){
  long long N;
  cin>>N;
  long long sum=0;
  long long count=0;
  priority_queue<long long> power;
  for(long long i=0; i<3*N; i++){
    long long a;
    cin>>a;
    power.push(a);
  }
  while(count<N){
    count++;
    power.pop();
    sum+=power.top();
    power.pop();
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 6128
from sys import stdin
def main():
  readline = stdin.readline
  n, q = map(int, readline().split())
  s = input()
  c = [0] * (n + 1)
  pch = s[0]
  pc = 0
  for i in range(2, n + 1):
    cch = s[i - 1]
    if cch == 'C' and pch == 'A':
      t = pc + 1
    else:
      t = pc
    c[i] = t
    pc = t
    pch = cch
  for _ in range(q):
    l, r = map(int, readline().split())
    t = c[r] - c[l - 1]
    if l >= 2 and s[l - 2: l] == 'AC':
      t -= 1
    print(t)
main()


Measured memory_bytes: 6380
#include <iostream>
#include <vector>

using namespace std;

const int INF = 1e8;


void debug(vector<int> c, vector<int> x){
	for(int i=0;i<c.size();i++) cout<< " "<< c[i]; cout<< endl;
	for(int i=0;i<x.size();i++) cout<< " "<< x[i]; cout<< endl;
}

void debug(vector<vector<int>>& dp){
	cerr<< " -- debug -- "<< endl;
	for(int i=0;i<dp.size();i++){
		for(int j=0;j<dp[i].size();j++){
			if(dp[i][j] != INF) cerr<< "("<< i<< ","<< j<< ")"<< dp[i][j]<< " ";
		}
		cerr<< endl;
	}
}

int norm(int a, int b){
	return (a - b) * (a - b);
}

bool solve(){
	int n, m;
	cin>> n>> m;
	if(!n && !m) return false;

	vector<int> c(m), x(n+1);
	for(int i=0;i<m;i++) cin>> c[i];
	for(int i=0;i<n;i++) cin>> x[i];
	//debug(c, x);

	vector<vector<int>> dp(n+1, vector<int>(256, INF));
	dp[0][128] = 0;
	for(int i=0;i<dp.size()-1;i++){
		for(int j=0;j<dp[i].size();j++){
			if(dp[i][j] == INF) continue;
			for(int k=0;k<c.size();k++){
				int jj = j + c[k];
				jj = min(jj, 255); jj = max(jj, 0);
				dp[i+1][jj] = min(dp[i+1][jj], dp[i][j] + norm(x[i], jj));
			}
		}
	}
	//debug(dp);

	int ans = INF;
	for(int i=0;i<dp[n].size();i++) ans = min(ans, dp[n][i]);
	cout<< ans<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed); cout.precision(10);
	while(solve());
	return 0;
}

Measured memory_bytes: 22000
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;

struct node {
	bool done;
	vi to, cap;
	int id, from;
	int f;
};

class Max_Flow {
public:
	int fbuf, fret;
	int n, s, t;
	stack<int> f;
	stack<int> stk;
	vector<node> nodes;
	bool reset;
	Max_Flow(vector<node> A, int start, int goal) {
		nodes = A;
		n = A.size();
		s = start;
		t = goal;
		Loop(i, n) {
			Loop(j, A[i].to.size()) {
				nodes[A[i].to[j]].to.push_back(i);
				nodes[A[i].to[j]].cap.push_back(0);
			}
		}
		Loop(i, n) {
			int m = nodes[i].to.size();
			vector<P> p(m);
			Loop(j, m) p[j] = { nodes[i].to[j], nodes[i].cap[j] };
			sort(p.begin(), p.end());
			Loop(j, m) {
				nodes[i].to[j] = p[j].first;
				nodes[i].cap[j] = p[j].second;
			}
		}
		fret = 0;
		Loop(j, nodes[t].cap.size()) {
			fret += nodes[t].cap[j];
		}
	}
	void main_func() {
		//finding roots
		while (stk.size()) stk.pop();
		Loop(i, n) nodes[i].done = false;
		stk.push(s);
		reset = false;
		dfs();
		if (reset) {
			main_func();
		}
		else {
			int fbuf = 0;
			Loop(j, nodes[t].cap.size()) {
				fbuf += nodes[t].cap[j];
			}
			fret = fbuf - fret;
		}
		return;
	}
	//nodes[a]???nodes[b]????????????????????????
	int find_edge(int a, int b) {
		return lower_bound(nodes[a].to.begin(), nodes[a].to.end(), b) - nodes[a].to.begin();
	}
	void dfs() {
		if (stk.top() == t) {
			int flow = INF;
			while (f.size()) {
				flow = min(flow, f.top());
				f.pop();
			}
			int a = t, b;
			while (a != s) {
				b = nodes[a].from;
				nodes[b].cap[find_edge(b, a)] -= flow;
				nodes[a].cap[find_edge(a, b)] += flow;
				a = b;
			}
			reset = true;
		}
		else {
			int a = stk.top();
			nodes[a].done = true;
			Loop(i, nodes[a].to.size()) {
				if (nodes[a].cap[i] == 0) continue;
				int b = nodes[a].to[i];
				if (nodes[b].done) continue;
				stk.push(b);
				nodes[b].from = a;
				f.push(nodes[a].cap[i]);
				dfs();
				if (reset) break;
				f.pop();
			}
			stk.pop();
		}
		return;
	}
};

int main() {
	int n, m; cin >> n >> m;
	vector<node> nodes(n);
	Loop(i, m) {
		int a, b, c; cin >> a >> b >> c;
		nodes[a].to.push_back(b);
		nodes[a].cap.push_back(c);
	}
	Max_Flow mf(nodes, 0, n - 1);
	mf.main_func();
	cout << mf.fret << endl;
	return 0;
}

Measured memory_bytes: 3228
K = int(input())
numbers = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"
numbers = numbers.split(',')
print(numbers[K - 1])


Measured memory_bytes: 2940
'use strict';
(function(stdin) {
    var inputs = stdin.toString().trim().split('\n');
    var sorted = inputs
    .map(Number)
    .sort(function(a,b){
        return b - a;
    })
    .slice(0,3)
    .join('\n');
    console.log(sorted);

}(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7644
#include <bits/stdc++.h>
#include <algorithm>
#include <iterator>

using namespace std;

int main(int argc, const char *argv[]) {
  using ll = long long;
  ll x;
  cin >> x;

  vector<ll> memo;
  for (ll i = 0; i < 1000; ++i) {
    memo.push_back(pow(i, 5));
  }

  ll a, b;
  for (ll i = 0; i < memo.size(); ++i) {
    // i^5 + なにか = x
    auto add_it = lower_bound(memo.begin(), memo.end(), x - memo[i]);
    if (add_it != memo.end() && *add_it == x - memo[i]) {
      a = i;
      b = -distance(memo.begin(), add_it);
      break;
    }

    // i^5 - なにか = x
    auto sub_it = lower_bound(memo.begin(), memo.end(), memo[i] - x);
    if (sub_it != memo.end() && *sub_it == memo[i] - x) {
      a = i;
      b = distance(memo.begin(), sub_it);
      break;
    }

    // -i^5 + なにか = x
    auto add2_it = lower_bound(memo.begin(), memo.end(), x + memo[i]);
    if (add2_it != memo.end() && *add2_it == x + memo[i]) {
      a = -i;
      b = -distance(memo.begin(), add2_it);
      break;
    }

    // -i^5 - なにか = x
    auto sub2_it = lower_bound(memo.begin(), memo.end(), -memo[i] - x);
    if (sub2_it != memo.end() && *sub2_it == -memo[i] - x) {
      a = -i;
      b = distance(memo.begin(), sub2_it);
      break;
    }
  }

  cout << a << ' ' << b << '\n';

  return 0;
}

Measured memory_bytes: 4100
n = int(input())
vec = [list(map(int, input().split())) for _ in range(n-1)]

for i in range(n):
    t = 0
    for j in range(i,n-1):
        ci, si, fi = vec[j]
        if t <= si :
            t = si
        else :
            t = ((t+fi-1)//fi)*fi
        t += ci
    print(t)


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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

const ll MOD = 998244353;
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}

struct point {
	ll x, y;
	point operator-(point a) {
		return {x - a.x, y - a.y};
	}
	ll operator*(point a) {
		return x * a.y - y * a.x;
	}
	bool operator<(point a) {
		return make_pair(x, y) < make_pair(a.x, a.y);
	}
};

int n;
point a[300];


int main() {
	cin >> n;
	for (int i = 0; i < n; ++i)
		cin >> a[i].x >> a[i].y;
	ll ans = 1;
	for (int i = 0; i < n; ++i)
		ans = ans * 2 % MOD;
	ans = (ans - 1 + MOD) % MOD;
	ans = (ans - n + MOD) % MOD;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < n; ++j) {
			if (!(a[i] < a[j]))
				continue;
			int cc = 0;
			for (int k = 0; k < n; ++k)
				if (a[i] < a[k] && a[k] < a[j] && (a[k] - a[i]) * (a[j] - a[i]) == 0)
					++cc;
			ll mn = pw(2, cc);
			ans = (ans - mn + MOD) % MOD;
		}
	cout << ans << "\n";
	return 0;
}




Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author palayutm
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int X = in.nextInt(), Y = in.nextInt();
            if (X % Y == 0) out.println(-1);
            else out.println(X);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 23380
# -*- coding: utf-8 -*-
import sys;
import string;
sys.setrecursionlimit(20000) # 再起呼び出しの最大数をセット

import copy
import itertools

from functools import lru_cache
#@lru_cache(maxsize = None)

# 整数の入力
#n = int(input())

# スペース区切りの整数の入力
#a = [x for x in map(int, input().split())]
#n, a, b, c, d = map(int, input().split())
#print("sp", n, q, file=sys.stderr)
p, q, r = map(int, input().split())

# 改行区切りの整数の入力
#a = []
#for x in range(m):
#  a.append([int(x) for x in input().split()])
#p = [int(x) for x in input().split()]

# 文字列の入力
#s = input()

# 出力
#print("{} {}".format(a+b+c, s))
#a.sort()
#print(set(a), file=sys.stderr)
#print(len(set(a)))

#cache = dict()

import re

def doit():
  pq = p + q
  qr = q + r
  rp = r + p
  return min(min(pq, qr), rp)

#print(doit([0] * 4))
#doit(s)
try:
  print(doit())
except Exception as e:
  print("e", e, file=sys.stderr)


Measured memory_bytes: 4088
N = int(input())
P = list(map(int, input().split()))

res = 0
for i in range(1, N - 1):
    M = max(P[i - 1], P[i], P[i + 1])
    m = min(P[i - 1], P[i], P[i + 1])

    if M != P[i] and m != P[i]:
        res += 1

print(res)

Measured memory_bytes: 3316
H, W = map(int, input().split())
a = [list(input()) for i in range(H)]

del_H = []
del_W = []
for i in range(H):
  for j in range(W):
    if a[i][j] == '#':
      break
    if j == W - 1:
      del_H.append(i)
for j in range(W):
  for i in range(H):
    if a[i][j] == '#':
      break
    if i == H - 1:
      del_W.append(j)
for i in range(H):
  if i not in del_H:
    for j in range(W):
      if j not in del_W:
        print(a[i][j], end="")
    print()


Measured memory_bytes: 4596
#include <iostream>

using namespace std;

int main(void)
{
  int n;
  int p[20];
  int counter = 0;
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> p[i];
  for(int j = 1; j+1 < n; j++)
    if((p[j-1] < p[j]) && (p[j] <= p[j+1]))
      counter++;
    else if((p[j-1] >= p[j]) && (p[j] > p[j+1]))
      counter++;
  cout << counter;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define __ <<' '<<
#define ___ <<' '
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    cerr <<fixed<<setprecision(12);
}}IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}


signed main() {    

    int n;

    cin >> n;
    map<string, int> m;
    string s;
    ll c = 0;
    for(int i = 0; i < n; i++) {
        cin >> s;
        sort(ALL(s));
        c += m[s]++;
    }

    cout << c << endl;
  
    return 0;
}



Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
char n[100][100];int k[100][100],l[100][100],sum,H,W,i,j,m,s;
#define A(B,C) if(k[B][C]!=1){l[B][C]=1;}
int main(){while(true){s=0;memset(l,0,sizeof(l));cin>>W>>H;if(W==0){break;}for(i=1;i<=H;i++){for(j=1;j<=W;j++){cin>>n[i][j];if(n[i][j]=='.'){k[i][j]=0;}else if(n[i][j]=='@'){k[i][j]=2;l[i][j]=1;}else{k[i][j]=1;}}}
for(i=0;i<2500;i++){for(j=1;j<=H;j++){for(m=1;m<=W;m++){if(l[j][m]==1){A(j-1,m);A(j+1,m);A(j,m-1);A(j,m+1);}}}}
for(j=1;j<=H;j++){for(m=1;m<=W;m++){if(l[j][m]==1){s++;}}}cout<<s<<endl;}}

Measured memory_bytes: 3028
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;
    
#define EPS (1e-7)
#define INF (1<<30)
#define LLINF (1LL<<60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<int> tmp = a;
    sort(RALL(tmp));
    int mx = tmp[0];
    int semx = tmp[1];
    for(int i=0;i<n;i++){
        if(a[i]==mx){
            cout<<semx<<endl;
        }else{
            cout<<mx<<endl;
        }
    }
}

Measured memory_bytes: 3200
n,k = map(int, input().split())
num = [0] * 200000
an = list(map(int, input().split()))
for i in range(len(an)):
    num[an[i]] += 1
Ans = 0
num2 = [s for s in num if s != 0]
num2.sort()
length = len(num2)
if k < length:
    for i in range(length):
        Ans += num2[i]
        length = length - 1
        if length == k:
            break
print(Ans)

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

void Main() {
  long long a, b;
  cin >> a >> b;

  if ((a + b) % 2) cout << "IMPOSSIBLE" << endl;
  else cout << (a + b) / 2 << endl;
}

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

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n;
    int a[100003];
    Scd(n);
    Rep(i,n){
        Scd(a[i]);
    }
    sort(a,a+n);

    ll sum[100003] = {};
    Rep(i,n){
        sum[i] += a[i];
        sum[i+1] = sum[i];
        //printf ("%llu\n", sum[i]);
    }

    int cnt = 1;
    Repe(i,n,1){
        if( sum[n-i-1] * 2 >= a[n-i] ) cnt++;
        else break;
    }

    printf ("%d\n", cnt);

    return 0;
}



Measured memory_bytes: 1408
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iostream>

using namespace std;

struct Vec{
	int ind;
	int val;
};

bool valDesc( const Vec& left, const Vec& right ) {
    return left.val == right.val  ? left.val> right.val: left.val > right.val;
}

bool valAsc( const Vec& left, const Vec& right ) {
    return left.val == right.val  ? left.val <  right.val: left.val < right.val;
}
int main(void){
	long n,m,d;
	double ans;
	scanf("%ld%ld%ld",&n,&m,&d);
	
	if(d == long(0)){
		ans = (m-long(1))/double(n);
	}else{
		ans = 2*(m-1)*(n-d)/double(n*n);
	}
	printf("%2.12f\n",ans);
	fflush(stdout);

	return 0;
}

Measured memory_bytes: 256
a,b = map(int,input().split())

if 10 <= b < 100:
    c = a*100 + b
    for d in range(1,101):
        if d*d == c:
            print("Yes")
            exit()
            
    print("No")
    
elif b < 10:
    c = a*10 + b
    for d in range(1,101):
      if d*d == c:
          print("Yes")
          exit()
    
    print("No")
          
else:
    c = a*1000 + b
    for d in range(1,317):
      if d*d == c:
        print("Yes")
        exit()
    
    print("No")

Measured memory_bytes: 3064
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {

    String a,b;

    private void solve() {
        a = next();
        b = next();

        int c = Integer.parseInt(a + b);

        for(int i = 1;i * i <= c;i++) {
            if (i * i == c) {
                out.println("Yes");
                return;
            }
        }

        out.println("No");
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[2048];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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

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

typedef long long int in; 

in dp[105][100005],cp[105][100005];

int main() 
{
    in n,k,s=0,l=1000000007;
    cin>>n>>k;
    
    in a[n],i,j;
    
    for(i=0;i<n;++i)
    cin>>a[i];
    
    for(j=0;j<=a[0];++j)
    {
        dp[0][j]=1;
        cp[0][j]=1;
    }
    
    for(j=1;j<100005;++j)
    {
        cp[0][j]=(cp[0][j]+cp[0][j-1])%l;
    }
    
    for(i=1;i<n;++i)
    {
        for(j=0;j<=a[i];++j)
        {
            dp[i][j]=(dp[i-1][j])%l;
            cp[i][j]=(dp[i-1][j])%l;
        }
        
        for(j=1;j<=a[i];++j)
        {
            dp[i][j]=(dp[i][j]+dp[i][j-1])%l;
            cp[i][j]=(cp[i][j]+cp[i][j-1])%l;
        }
        
        for(j=a[i]+1;j<100005;++j)
        {
            dp[i][j]=((cp[i-1][j]-cp[i-1][j-a[i]-1])%l+l)%l;
            cp[i][j]=(dp[i][j])%l;
        }
        
        for(j=1;j<100005;++j)
        cp[i][j]=(cp[i][j]+cp[i][j-1])%l;
    }
    
    // for(i=0;i<n;++i)
    // {
    //     for(j=0;j<=10;++j)
    //     cout<<dp[i][j]<<" ";
    //     cout<<"\n";
    // }
    
    // for(i=0;i<n;++i)
    // {
    //     for(j=0;j<=10;++j)
    //     cout<<cp[i][j]<<" ";
    //     cout<<"\n";
    // }
    
    cout<<dp[n-1][k];
    
	return 0;
}


Measured memory_bytes: 160000
n,y=gets.split.map(&:to_i)
a,b,c=-1,-1,-1
(0..n).each do |i|
  (0..n).each do |j|
    next if n-i-j<0
    a,b,c=n-i-j,j,i if i*1000+j*5000+(n-i-j)*10000==y
  end
end
puts [a,b,c].join ' '


Measured memory_bytes: 14316
module M = Map.Make(struct type t = int let compare = (-) end)
let find_default k m v = try M.find k m with Not_found -> v

let () =
  Scanf.scanf "%d %d" @@ fun n t ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x)) in
  let d = Array.fold_left (fun (d, l) e -> (max d (e-l), min e l)) (0, a.(0)) a |> fst in
  a |> Array.fold_left (fun (z, m) v ->
    let p = find_default (v-d) m 0 in
    let c = find_default v m 0 in
    (z+p, M.add v (c+1) m)) (0, M.empty)
  |> fst |> Printf.printf "%d\n"

Measured memory_bytes: 11904
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define ll long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
ll cl(ll a,ll b)
{
    return (a/b)+(!(!(a%b)));
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;cin >> n;string ans;ll t=1;
    while(n)
    {
    	//trace(n);
    	ll d=n%26;
    	d--;d+=26;d%=26;
    	ans+=('a'+d);
    	if(n%26)n-=(t*(n%26));
    	else n-=(t*26);
    	n/=26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
    }

Measured memory_bytes: 3636
s = input()
 
for i in range(len(s)):
    if s[i] == '?':
        if i == 0 and len(s) == 1:
            s = s.replace('?','D',1)
        elif i == 0 and s[1] == 'D':
            s = s.replace('?','P',1)
        elif i == 0 and s[1] == 'P':
            s = s.replace('?','D',1)
        elif i == 0 and s[1] == '?':
            s = s.replace('?','D',1)
        elif s[i-1] =='P':
            s = s.replace('?','D',1)
        elif s[i-1] =='D' and (i ==len(s)-1):
            s = s.replace('?','D',1)
        elif s[i-1] =='D' and (i <len(s)-1 and(s[i+1] == 'P' or s[i+1] == '?')):
            s = s.replace('?','D',1)
        else:
            s = s.replace('?','P',1)


print(s)

Measured memory_bytes: 9416
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string a,b,c;
    int d,e;
    cin>>a>>b>>d>>e>>c;
    if(a==c){
        cout<<d-1<<' '<<e<<endl;
    }
    else{
        cout<<d<<' '<<e-1<<endl;
    }
}

Measured memory_bytes: 256
from sys import stdin

N= int(stdin.readline().rstrip())
values = list(range(1,N+1))

c = 1000000007

count = dict()
for i, v in enumerate(values):
  if v > 1:
    count[v] = count.get(v, 0) + 1
    for j in range(i+1, N):
      if (values[j] % v == 0):
          values[j] /= v
          count[v] += 1

result = 1
for v in count.values():
  result = (result * (v + 1)) % c
print(result)

Measured memory_bytes: 70244
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
    	int K = sc.nextInt();
        String S = sc.next();
      
      	int len = S.length();
        if(len > K){
            String tmp = S.substring(0,K);
            System.out.println(tmp + "...");            
        }else{
            System.out.println(S);
        }
    }
}


Measured memory_bytes: 27088
#include <cstdio>
int main() {
	int sum,book,books;
	while(scanf("%d",&sum),sum) {
		books=0;
		for(int i=1;i<10;i++) {
			scanf("%d",&book);
			books+=book;
		}
		printf("%d\n",sum-books);
	}
}

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

int main() {
  int h, w;
  cin >> h >> w;

  vector<string> a(h);
  for (int i = 0; i < h; i++) cin >> a.at(i);

  cout << "#";
  for (int i = 0; i < a.at(0).size(); i++) {
    cout << "#";
  }
  cout <<  "#" << endl;

  for (int i = 0; i < h; i++) {
    cout << "#" << a.at(i) << "#" << endl;
  }

  cout << "#";
  for (int i = 0; i < a.at(0).size(); i++) {
    cout << "#";
  }
  cout <<  "#" << endl;
}


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

using namespace std;
typedef long long ll;

int main(){
    ll n, m;
    cin >> n >> m;
    vector<tuple<ll, ll, ll>> cake;
    for(int i = 0; i < n; ++i){
        ll x, y, z;
        cin >> x >> y >> z;
        cake.push_back(make_tuple(x, y, z));
    }

    ll ans = 0;
    for(int i = 0; i < 8; ++i){
        const ll s1 = 1 - 2 * (i & 1);
        const ll s2 = 1 - 2 * ((i / 2) & 1);
        const ll s3 = 1 - 2 * ((i / 4) & 1);

        sort(cake.begin(), cake.end(), [s1, s2, s3](auto &l, auto &r) {
            ll tmp1 = s1 * get<0>(l) + s2 * get<1>(l) + s3 * get<2>(l);
            ll tmp2 = s1 * get<0>(r) + s2 * get<1>(r) + s3 * get<2>(r);
            return tmp1 > tmp2;
        });

        ll tmp = 0;
        for(int j = 0; j < m; ++j){
            const auto c = cake.at(j);
            tmp += s1 * get<0>(c) + s2 * get<1>(c) + s3 * get<2>(c);
        }
        ans = max(tmp, ans);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    int n;
    int m[3001];
    long long dp[3001][3001][2];
    long long solve(int start,int end,int k)
    {
        //System.out.println(start+" "+end+" "+k);
        if(start>end)
            return 0;
        if(dp[start][end][k]!=-1)
            return dp[start][end][k];
        if(k==0)
        {
            dp[start][end][k]=max(solve(start+1,end,1)+m[start],solve(start,end-1,1)+m[end]);
        }
        else
        {
            dp[start][end][k]=min(solve(start+1,end,0)-m[start],solve(start,end-1,0)-m[end]);
        }
        return dp[start][end][k];
    }
    int main()
    {
        cin>>n;
        for(int i=1;i<=n;i++)
        cin>>m[i];
        for(int i=0;i<=n;i++)
        {
            for(int j=0;j<=n;j++)
            {
                for(int k=0;k<=1;k++)
                    dp[i][j][k]=-1;
            }
        }
        cout<<solve(1,n,0)<<endl;
        return 0;
    }

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

using namespace std;

const int maxn = 3e5 + 5;
typedef pair < long long, long long > ii;

int a, n;

int b[maxn];

ii expon[maxn];
ii exponn[maxn];

long long res[maxn];

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

    cin >> a;

    n = (1<<a);

    for(int i=0;i<n;++i) cin >> b[i];

    for(int i=0;i<n;++i)
    {
        int tung = (1<<i);
        expon[i].first = b[i];
        expon[i].second = tung;
    }

	for(int i=0;i<a;++i)
    for(int j=0;j<n;++j)
    {
        int tung = (1<<i);
        if( (tung & j) )
        {
            int newval = tung ^ j;
            if( expon[j].first == expon[newval].first ) /// TH ==
            {
                if( exponn[j].first < expon[newval].first )
                if( expon[j].second != expon[newval].second )
                {
                    exponn[j] = expon[newval];
                    continue;
                }
            }

            if( expon[j].first < expon[newval].first ) /// TH <
            {
                exponn[j] = expon[j];
                expon[j] = expon[newval];
                continue;
            }
            if( exponn[j].first < expon[newval].first ) /// TH >
                exponn[j] = expon[newval];
        }
    }

    res[1] = max(expon[0].first + exponn[0].first, expon[1].first + exponn[1].first );
    for(int i=2;i<n;++i) res[i] = max(res[i-1], expon[i].first + exponn[i].first);

    for(int i=1;i<n;++i) cout << res[i] << '\n';

}




Measured memory_bytes: 14880
import sys
input = sys.stdin.readline

A,B,C,D=map(int,input().split())
mod=998244353

DP=[[0]*(D+1) for i in range(C+1)]
DP[A][B]=1

for i in range(A,C+1):
    for j in range(B,D+1):
        if i==A and j==B:
            continue
        DP[i][j]=(DP[i-1][j]*j+DP[i][j-1]*i-DP[i-1][j-1]*(i-1)*(j-1))%mod

print(DP[C][D]%mod)


Measured memory_bytes: 134020
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;

int main()
{
    int X, Y;
    cin >> X >> Y;
    bool ans = false;

    for (int i = 0; i <= X; ++i){
        int j = X - i;
        if( i*2 + j*4 == Y )
            ans = true;
    }

    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

        return 0;
}

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

using namespace std;

long long A, B, ans = ans;

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

	cin >> A >> B;
	if(A == B)
	{
		cout << 1 << endl;
		return 0;
	}
	long long T = 1ll << 62;
	while(T && (A & T) == (B & T))
		T >>= 1;
	A &= (T << 1) - 1, B &= (T << 1) - 1;

	long long K = T >> 1;
	while(K && !(B & K))
		K >>= 1;
	K = max(0ll, (K << 1) - 1);
	// cerr << T << ' ' << K << endl;
	if(T + K < T + A)
		ans = (T + K) - A + 1 + (2 * T - 1) - (T + A) + 1;
	else
		ans = (2 * T - 1) - A + 1;
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			final int n = scn.nextInt();
			final String s = scn.next();
			final String t = scn.next();

			for (int i = 0; i < n; i++) {
				System.out.print(s.charAt(i));
				System.out.print(t.charAt(i));
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 21204
use strict;
use warnings;


#=== input ===================================
# N の入力
my $num_n = <STDIN>;

# A_N の入力
my $str_a = <STDIN>;
chomp $str_a;
my @num_arr_a = split / /, $str_a;

#=== main ====================================
my $flg_exist_odd = 0;	# 奇数フラグ：1 … 奇数、0 … 偶数
my $num_div_cnt = 0;	# 2で割り切れる回数
while ( 1 )
{
	for ( my $num_cnt = 0; $num_cnt < $num_n; $num_cnt++ )
	{
		if ( ( $num_arr_a[$num_cnt] % 2 ) != 0 )	# 2で割り切れない場合
		{
			$flg_exist_odd = 1;
		}
	}

	if ( $flg_exist_odd == 1 )	# 2で割り切れない場合
	{
		last;
	}

	for ( my $num_cnt = 0; $num_cnt < $num_n; $num_cnt++ )
	{
		$num_arr_a[$num_cnt] /= 2;
	}

	$num_div_cnt++;	# 2で割り切れる回数をカウント
}




#=== output ==================================
printf "%d\n", $num_div_cnt;

#=== sub routine =============================


Measured memory_bytes: 768
n, t = gets.chomp!.split(' ').map(&:to_i)
min_cost = 1000000

n.times do |i|
    c_i, t_i = gets.chomp!.split(' ').map(&:to_i)
    next if t_i > t

    min_cost = [min_cost, c_i].min
end

puts min_cost == 1000000 ? "TLE" : min_cost


Measured memory_bytes: 1788
N = gets.to_i
E = 10 ** 9 + 7
C = %w(A C G T)

$memo = Array.new(N + 1) { Hash.new }

def ok?(last4)
  4.times do |i|
    t = last4.chars
    t[i-1], t[i] = t[i], t[i-1] if i >= 1
    return false if t.join.include?('AGC')
  end
  true
end

def dfs(cur, last3)
  return $memo[cur][last3] if $memo[cur][last3]
  return 1 if cur == N

  ret = 0
  C.each do |c|
    ret += dfs(cur + 1, last3[1, 3] + c) if ok?(last3 + c)
  end

  $memo[cur][last3] = ret
  return ret
end

puts dfs(0, 'TTT') % E

Measured memory_bytes: 3452
#include "bits/stdc++.h"
 
using namespace std;
 
#define int long long
 
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define FORR(i, a, b) for (int i = (a); i >= (b); i--)
 
#define pb push_back
#define VDEL(v, n) v.erase(v.begin() + (n))
#define ALL(v) v.begin(), v.end()
 
#define INT_INF 200000000
 
#define TINT(str) atoi(str.c_str())
#define TSTR(num) to_string(num)
 
typedef long long ll;
typedef pair<int, int> PINT;
typedef vector<int> VI;
typedef vector<vector<int>> VII;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
 
//the end of library zone
 
int X[200000];

int D[200000];

signed main(){
	int N, M;

	cin >> N >> M;
	
	REP(i, M){
		cin >> X[i];
	}

	if(N >= M){
		cout << 0 << endl;
		return 0;
	}

	sort(X, X + M);

	REP(i, M - 1){
		D[i] = X[i + 1] - X[i];
	}

	sort(D, D + M - 1);

	int ans = 0;

	REP(i, (M - N)){
		ans += D[i];
	}

	cout << ans << endl;

    return 0;
}



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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  int i, sum;
  sum = 0;
  for (i=1; ; i++) {
    sum += a;
    if (i%7 == 0) sum += b;
    if (sum >= c) break;
  }
  
  cout << i << endl;
  
  return 0;
}


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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define int long long
#define itn int
#define pb push_back
#define m_p make_pair
#define m_t meke_tuple
#define p_p(a,b) pb(m_p(a,b))
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a));reverse(all(a))
#define UNIQUE(a) a.erase(unique(all(a)),a.end())
#define SZ(a) (ll)(a.size())
#define ENDL cout<<endl
#define debg(a) cout<<#a<<" "<<a<<endl;
#define call(a) for(auto i:a)cout<<i<<" ";cout<<endl
#define show(a) rep(ghf,SZ(a)){rep(kjh,SZ(a[ghf])){cout<<(a[ghf][kjh]<10?" ":"")<<a[ghf][kjh]<<" ";}ENDL;}
#define out(a) cout<<(a)<<endl
#define fi first
#define se second
#define Vec vector
#define P pair
typedef long long ll;
typedef string str;
typedef vector<ll> V;
typedef pair<ll,ll> Pi;
typedef vector<Pi> VP;
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int max(int a,int b){if(a>b)return a; return b;}
int min(int a,int b){if(a>b)return b; return a;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}

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

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll h,w;
  cin>>h>>w;
  Vec<str> s(h);
  rep(i,h)cin>>s[i];
  Vec<V> cost=Vec<V>(h,V(w,INF));
  VP Black;
  rep(i,h){
    rep(j,w){
      if(s[i][j]=='#'){
        Black.p_p(i,j);
        cost[i][j]=0;
      }
    }
  }
  priority_queue<P<ll,P<ll,ll>>,Vec<P<ll,P<ll,ll>>>,greater<P<ll,P<ll,ll>>>> que;
  for(const auto&black:Black){
    rep(i,4){
      if(black.fi+dy[i]==-1||black.fi+dy[i]==h)continue;
      if(black.se+dx[i]==-1||black.se+dx[i]==w)continue;
      que.push( m_p( 1,m_p(black.fi+dy[i],black.se+dx[i]) ) );
    }
  }
  while(!que.empty()){
    P<ll,P<ll,ll>> next=que.top();
    que.pop();
    int nx=next.se.se,ny=next.se.fi;
    //cout<<ny<<" "<<nx<<" "<<next.fi<<endl;
    if( chmin(cost[ny][nx],next.fi) ){
      rep(i,4){
        if(ny+dy[i]==-1||ny+dy[i]==h)continue;
        if(nx+dx[i]==-1||nx+dx[i]==w)continue;
        int ncost=next.fi+1;
        if(s[ny+dy[i]][nx+dx[i]]=='#')ncost=0;
        que.push( m_p(ncost,m_p(ny+dy[i],nx+dx[i])) );
      }
    }
  }
  //show(cost);
  int ans=0;
  rep(i,h)rep(j,w)chmax(ans,cost[i][j]);
  out(ans);
  
  
  return 0;
}



Measured memory_bytes: 137308
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
using ll = long long;
ll mod = 1000000007;
ll power(ll base, ll x)
{
  if (x == 0)
  {
    return 1;
  }
  else
  {
    ll a = power(base, x / 2);
    a = a * a % mod;
    if (x % 2 == 1)
      a *= base;
    return a % mod;
  }
}
vector<ll> memoFact = vector<ll>(200000, 0);
ll fact(ll a)
{
  if (a == 0)
    return 1;
  else if (memoFact[a] != 0)
    return memoFact[a];
  else
    return memoFact[a] = a * fact(a - 1) % mod;
}
ll inv(ll a)
{
  return power(a, mod - 2);
}
ll combi(ll n, ll a)
{
  return fact(n) * inv(fact(n - a) * fact(a) % mod) % mod;
}
int main()
{
  ll n, k;
  cin >> n >> k;
  if (k > n - 1)
    k = n - 1;
  ll ans = 0;
  for (int i = 0; i <= k; i++)
  {
    ll add = combi(n, i) * combi(n - 1, i) % mod;
    // cout << "k=" << i << ", combi(n, k)=" << combi(n, i) << ", power(n - i, i)=" << power(n - i, i) << ",total=" << add << endl;
    ans += add;
    ans %= mod;
  }
  cout << ans << endl;
}

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

long long mod = 1000003;
long long f[1000010], inv[1000010];

long long Calc(long long A, long long B) {
	if (B==0) return 1;
	if(B%2==0){
		long long C=Calc(A,B/2);
		return(C*C)%mod;
	}
	return (A*Calc(A,B-1))%mod;
}

int main() {
	f[0]=f[1]=inv[0]=inv[1]=1;
	for (int i=2;i<mod;i++) {
		f[i]=f[i-1]*i;
		f[i]=f[i]%mod;
		inv[i]=Calc(f[i],mod-2);
	}

	int q;
	cin >> q;
	for (int i=0;i<q;i++){
		long long x,d,n;
		cin>>x>>d >>n;
		if (d==0){
			cout<<Calc(x,n)<< endl;
			continue;
		}
		x=(x*Calc(d,mod-2))%mod;
		if(x+n-1>=mod || x==0) {
			cout<<0<<endl;
			continue;
		}
		cout<<((f[x+n-1]*inv[x-1])%mod*Calc(d,n))%mod<<endl;
	}
}


Measured memory_bytes: 16512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds; 
using ll = long long int;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order() - 0 indexing
// order_of_key() - number of elements strictly smaller
ll power(ll x, ll y, ll m){
    ll res=1;x=x%m;
    while(y>0){
        if(y&1)
            res = (res*x)%m;
        y = y>>1;
        x = (x*x)%m;
    }
    return res%m;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
//---------------------------------------GL HF------------------------------------------------------
// -------------------------------------ManavJ07----------------------------------------------------
void solve(string s, int x, ll N, ll count,ll val){
	if(s[x]!='1'){
		s[x]='1';
		count++;
		val+=power(2,N-x-1,count);
		val%=count;
	}
	else{
		s[x]='0';
		count--;
		val-=power(2,N-x-1,count);
		val+=count;
		val%=count;
	}
	ll ans=1;
	while(val!=0){
		ll digits=__builtin_popcountll(val);
		val%=digits;
		ans++;
	}
	cout<<ans<<endl;
}
signed main()
{
	fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
	int t=1;
	//cin>>t;
	while(t--)
	{
		ll N;
		cin>>N;
		string s;
		cin>>s;
		ll count=0;
		for(ll i=0;i<N;i++){
			count+=(s[i]-'0');
		}
		ll valplus=0;
		for(ll i=0;i<N;i++){
			if(s[i]=='0')
				continue;
			valplus+=power(2,N-i-1,count+1);
			valplus%=(count+1);
		}
		ll valminus=0;
		if(count==1){
			valminus=-1;
		}
		else{
			for(ll i=0;i<N;i++){
				if(s[i]=='0')
					continue;
				valminus+=power(2,N-i-1,count-1);
				valminus%=(count-1);
			}
		}
		//cout<<valplus<<" "<<valminus<<endl;
		for(ll i=0;i<N;i++){
			if(s[i]=='1'){
				if(valminus==-1)
					cout<<0<<endl;
				else
					solve(s,i,N,count,valminus);
			}
			else
				solve(s,i,N,count,valplus);
		}
	}
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int X;
    Scd(X);

    int N = X/100;
    int C = X%100;

    printf ("%d\n", N*5>=C );

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
using namespace std;

typedef long long ll;

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



    return 0;
}

Measured memory_bytes: 256