akhauriyash/Code-Regression huggingface dataset:
using System;

class D
{
	static void Main()
	{
		var s = Console.ReadLine();
		var n = s.Length;

		var k = (n + 1) / 2;
		if (n % 2 == 0)
		{
			var m = (n - 1) / 2;
			if (s[m] == s[m + 1])
			{
				k++;
				var c = s[m];
				for (int i = 1; i <= m; i++)
				{
					if (s[m - i] == c && s[m + 1 + i] == c) k++;
					else break;
				}
			}
		}
		else
		{
			var m = (n - 1) / 2;
			var c = s[m];
			for (int i = 1; i <= m; i++)
			{
				if (s[m - i] == c && s[m + i] == c) k++;
				else break;
			}
		}
		Console.WriteLine(k);
	}
}


Measured memory_bytes: 26256
using System.Text;
using System;

public class BIT
{
    private int[] data;
    public BIT(int n)
    {
        data = new int[n + 1];
    }
    public int getSum(int i)
    {
        var s = 0;
        while (i > 0)
        {
            s += data[i];
            i -= i & -i;
        }
        return s;
    }
    public void addix(int i, int x, int n)
    {
        while (i <= n)
        {
            data[i] += x;
            i += i & -i;
        }
    }
}

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var q = int.Parse(line[1]);
        getAns(n, q);
    }
    static void getAns(int n, int q)
    {
        var sb = new StringBuilder();
        var n2 = n + 2;
        var bit = new BIT(n2);
        for (int i = 0; i < q; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            if (line[0] == "0")
            {
                var s = int.Parse(line[1]);
                var t = int.Parse(line[2]);
                var x = int.Parse(line[3]);
                bit.addix(s, x, n2);
                bit.addix(t + 1, -x, n2);
            }
            else
            {
                var s = int.Parse(line[1]);
                var ans = bit.getSum(s);
                sb.Append(bit.getSum(s).ToString() + "\n");
            }
        }
        Console.Write(sb);
    }
}



Measured memory_bytes: 22240
#include <bits/stdc++.h>
#define rep(i,x,n) for(int i=x; i<(int)(n); i++)
#define rep_eq(i,x,n) for(int i=x; i<=(int)(n); i++)
using namespace std;

int main() {
  string s,t; cin >>s >>t;
  sort(s.begin(),s.end());
  sort(t.rbegin(),t.rend());
  cout <<(s<t ? "Yes":"No") <<endl;
  return 0;
}


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

using namespace std;
/*
int gcd (int *ar,int n,int sml)
{
    int i,f=1;
    for (i=0;i<n;++i){

        if (ar[i]%sml != 0){

            f=0;
            break;

        }
    }

    if (f==0){

        sml-=1;
        return gcd(ar,n,sml);

    }
    else return sml;

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

}


int findGCD(int arr[], int n)
{
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}

int main()
{
    int n,i,ar[200000];
    scanf ("%d",&n);
    for (i=0;i<n;++i){

        scanf ("%d",&ar[i]);

    }
    sort (ar,ar+n);
    printf ("%d\n",(findGCD(ar,n)));

    return 0;

}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n;
    cin >> n;
    vector<string> vc(n);
    rep(i,n)
    {
        cin >> vc[i];
    }
    sort(vc.begin(),vc.end());
    vc.erase(unique(vc.begin(), vc.end()), vc.end());
    cout << sz(vc) << endl;
}

Measured memory_bytes: 9520
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
#include <cctype>

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; }

const long long MAX = 5100000;
const long long INF = 1LL << 60;
const long long mod = 1000000007LL;
//const long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


vector<pair<char, ll>> RLE(string& s) {
	ll cnt = 0;
	vector<pair<char, ll>> res;
	for (ll i = 0; i < s.size(); i++) {
		cnt++;
		if (i == (ll)s.size() - 1) {
			res.push_back(make_pair(s[i], cnt));
			break;
		}
		if (s[i] != s[i + 1]) {
			res.push_back(make_pair(s[i], cnt));
			cnt = 0;
		}
	}
	return res;
}

int main()
{
	/*
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	*/
	ll n; scanf("%lld", &n);
	vector<vector<char>> c(11);
	c[1] = { '.',',','!','?',' ' };
	c[2] = { 'a','b','c' };
	c[3] = { 'd','e','f' };
	c[4] = { 'g','h','i' };
	c[5] = { 'j','k','l' };
	c[6] = { 'm','n','o' };
	c[7] = { 'p','q','r','s' };
	c[8] = { 't','u','v' };
	c[9] = { 'w','x','y','z' };
	while (n--) {
		string s; cin >> s;
		vector<pair<char, ll>> vp = RLE(s);
		string res;
		for (auto p : vp) {
			if (p.first == '0') continue;
			ll cnt = (p.second - 1) % c[p.first - '0'].size();
			res += c[p.first - '0'][cnt];
		}
		cout << res << "\n";
	}
	return 0;
}


Measured memory_bytes: 3240
s = int(input())
bit = [0] * 1000000

bit[s] = 1
i = 1
while True:
    i += 1
    if s % 2 == 0:
        s //= 2
    else:
        s = 3 * s + 1
    if bit[s] == 1:
        print(i)
        break
    else:
        bit[s] = 1


Measured memory_bytes: 10868
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

ll dijkstra(ll from, ll to, const vector<vector<pair<ll, ll>>> & nodes){
    ll N = nodes.size();
    vector<ll> costs(N, numeric_limits<ll>::max());
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<>> pq;
    pq.push(make_pair(0LL, from));
    costs.at(from) = 0LL;
    while(!pq.empty()){
        ll shortest_path, now;
        tie(shortest_path, now) = pq.top();
        pq.pop();
        for (auto &&p: nodes.at(now)){
            ll cost, next;
            tie(cost, next) = p;
            ll alt_shortest = shortest_path + cost;
            if (costs.at(next) > alt_shortest){
                costs.at(next) = alt_shortest;
                pq.push(make_pair(alt_shortest, next));
            }
        }
    }
    return costs.at(to);
};


int main() {
    ll N, M;
    cin >> N >> M;
    vector<vector<pair<ll, ll>>> nodes(N, vector<pair<ll, ll>>{});
    for (auto &&i: boost::irange(0LL, M)) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--;
        b--;
        nodes.at(a).emplace_back(make_pair(c, b));
        swap(a, b);
        nodes.at(a).emplace_back(make_pair(c, b));
    }
    vector<vector<ll>> costs(N, vector<ll>(N, numeric_limits<ll>::max()));
    for (auto &&i: boost::irange(0LL, N)){
        for (auto &&j: boost::irange(0LL, N)){
            costs.at(i).at(j) = dijkstra(i, j, nodes);
        }
    }
    ll count{0};
    for (auto &&from: boost::irange(0LL, N)){
        for (auto &&e: nodes.at(from)){
            ll cost, to;
            tie(cost, to) = e;
            if (cost > costs.at(from).at(to)){
                count++;
            }
        }
    }
    cout << count / 2;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
    int n;
    float cp , cf;
    cin >> n;
    cp=n*1.0;
    if (n%2==0){
        cf=n/2;
    } else {
        cf=n/2+1;
    }
    cout <<cf/cp;
    return 0;
}


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

typedef pair<int, int> P;
typedef pair<int, P> PP;
int tate[101];
vector<PP> yokobo;

void init(){
  for(int i = 1; i <= 100; i++) tate[i] = i;
}

int search(int n, int a){
  for(int i = 1; i <= n; i++){
    if(tate[i] == a) return i;
  }
}

int main(void){
  int n, m, a;
  while(cin >> n >> m >> a){
    if(!n && !m && !a) break;
    init();
    yokobo.clear();
    for(int s = 0; s < m; s++){
      int h, p, q;
      cin >> h >> p >> q;
      yokobo.push_back(PP(h, P(p, q)));
    }
    sort(yokobo.begin(), yokobo.end(), greater<PP>());
    for(int i = 0; i < yokobo.size(); i++){
      swap(tate[yokobo[i].second.first], tate[yokobo[i].second.second]);
    }
    cout << search(n, a) << endl;
  }
  return 0;
}

Measured memory_bytes: 1224
import java.io.PrintStream;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        doit(args, new Scanner(System.in), System.out);
    }

    static void doit(String[] args, Scanner scanner, PrintStream out) {
        int n = scanner.nextInt();
        long debt = 100000;
        for (int i = 0; i < n; i++) {
            debt = ((long) Math.ceil(debt * 1.05 /1000.0)) * 1000;
        }
        out.println(String.format("%d", debt));
    }
}

Measured memory_bytes: 12000
#include <stdio.h>
#include <math.h>
#include <stdbool.h>
typedef long long int lli;
#define rept(x, s, n) for (int x = s; x < n; x++)
int main(void)
{
    lli A, B, M;
    scanf("%lld %lld %lld", &A, &B, &M);
    int *a, *b;
    a = (int *)malloc(sizeof(int) * A);
    b = (int *)malloc(sizeof(int) * B);
    rept(i, 0, A)
    {
        scanf("%d", &a[i]);
    }
    rept(i, 0, B)
    {
        scanf("%d", &b[i]);
    }
    int discrate[100000][3];
    rept(i, 0, M)
    {
        rept(j, 0, 3)
        {
            scanf("%d", &discrate[i][j]);
        }
    }
  	int* discprice;
  	discprice = (int *)malloc(sizeof(int)*M);
  	rept(i, 0, M)
    {
            discprice[i] = a[discrate[i][0] - 1] + b[discrate[i][1] - 1] - discrate[i][2];
    }
    int min=0;
    quick_sort(a,0,A-1);
    quick_sort(b,0,B-1);
    min = a[0]+b[0];
	rept(i, 0, M)
    {
      if(discprice[i]<min){
      	min = discprice[i];
      }
    }
    printf("%d", min);
    return 0;
}

void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}

Measured memory_bytes: 2560
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      //モンスター
      int H = sc.nextInt();
      //アライグマ
      int N = sc.nextInt();
      //全部の必殺技を使う
      for(int i=0;i<N;i++){
        H-=sc.nextInt();
      }
      //最終的なモンスターの体力
      if(H<=0){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
}

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

int main() {
	int A,B,C,D,E,F;cin>>A>>B>>C>>D>>E>>F;
	int sum = A + B * 5 + C * 10 + D * 50 + E * 100 + F * 500;
	if (sum >= 1000) {
		cout << 1 << endl;
	} 
	else {
		cout << 0 << endl;
	}
}


Measured memory_bytes: 3116
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in); 
int w = sc.nextInt();
int n = sc.nextInt();
int[] values = new int[w];
for (int i = 0; i < values.length; i++) { 
	values[i] = i + 1;
}
for (int i = 0; i < n; i++) {
String str = sc.next();
String[] ab = str.split(",");
int a = Integer.parseInt(ab[0]) - 1; 
int b = Integer.parseInt(ab[1]) - 1; 
int temp;
temp=values[a];
values[a]=values[b];
values[b]=temp;
}
// values??????????????????
int i;
for(i=0;i<values.length;i++){
	System.out.println(values[i]);
} 
}
}

Measured memory_bytes: 17200
#include <stdio.h>
#include <stdlib.h>

int main(){
	int N = 0, W = 0, S = 0, E = 0, i;
	char *s = (char *)malloc(sizeof(char) * 1001);
	scanf("%s", s);
	for(i = 0; s[i] != '\0'; i++){
		if(s[i] == 'N'){
			N = 1;
		}
		else if(s[i] == 'W'){
			W = 1;
		}
		else if(s[i] == 'S'){
			S = 1;
		}
		else{
			E = 1;
		}
	}
//	printf("%d %d %d %d\n", N, W, S, E);
	if(N == S && W == E){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
// AtCoder Beginners Contest
// A - Registration

#include <iostream>
#include <string>

using namespace std;

int main()
{
    string S, T;
	int i,flag;

    cin >> S;
    cin >> T;
	size_t Snorm = S.length();
	size_t Tnorm = T.length();

	// 制約確認
	if (Snorm < 1 || 10 < Snorm)  {
        cout << "Sは条件を満たしていません!\n";
        return 0;
    }

	flag = 1;
	for (i = 0; i < Snorm; i++) {
		if (S[i] != T[i]) {
			flag = 0;
		}
	}
	
	if (flag == 1) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
}

Measured memory_bytes: 3624
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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, 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_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      n: usize,
      aa: [usize; n],
    }

    const MOD: usize = 1e9 as usize + 7;
    let mut ans = 1;
    let mut cnt = vec![0; n+1];

    for i in 0..n {
        let a = aa[i];
        if a == 0 {
            ans *= 3 - cnt[0];
            ans %= MOD;
            cnt[0] += 1;
        } else {
            ans *= cnt[a-1] - cnt[a];
            ans %= MOD;
            cnt[a] += 1;
        }
    }
    puts!("{}\n", ans);
}


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

ll n;
int ans = 0;

void dfs(ll x, int a, int b, int c){
    if(x>n) return;
    if(a&b&c) ans++;
    dfs(10*x+3, 1, b, c);
    dfs(10*x+5, a, 1, c);
    dfs(10*x+7, a, b, 1);
}

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> n;
    dfs(0, 0, 0, 0);
    cout << ans << endl;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, ans = 0;
string S, T;

int A[5005];
int Solve(){
  int t = T.length();
  fill(A, A + t, 0);
  A[0] = t;
  int i = 1, j = 0;
  while (i < t){
    while (i + j < t && T[j] == T[i+j]) j++;
    A[i] = j;
    if (j == 0){
      i++; continue;
    }
    int k = 1;
    while (i + k < t && k + A[k] < j){
      A[i + k] = A[k]; k++;
    }
    i += k; j -= k;
  }

  for (int i = 0; i <= t; i++){
    ans = max(ans, min(i, A[i]));
  }

  return 0;
}

int main(){
  cin >> N >> S;
  for (int i = 0; i < N; i++) {
    T = S.substr(i, N);
    Solve();
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, ans = 1; cin >> n;
	ll k; cin >> k;
    vector<int> a(n + 1);
    vector<vector<int>> dp(64, vector<int> (n + 1));
    for(int i = 1; i < n + 1; i++) cin >> a[i];
    for(int i = 0; i < 64; i++) for(int j = 1; j < n + 1; j++)
    {
        if(!i) dp[i][j] = a[j];
        else dp[i][j] = dp[i - 1][dp[i - 1][j]];
    }
    for(int i = 0; k > 0; i++)
    {
        if(k & 1) ans = dp[i][ans];
        k /= 2;
    }
    cout << ans;

	return 0;
}

Measured memory_bytes: 54900
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) debug(x) debug(y);
#define repn(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, a) for(int i = 0; i < (int)(a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sq(x) ((x) * (x))

template<class T> T gcd(T a, T b){ return ((b == 0) ? a : gcd(b, a % b)); }

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, k;
	cin >> n >> k;
	vector<ld> p(n), sum(n);
	rep(i, n){
		ld x;
		cin >> x;
		if(x == 1) p[i] = 1.0;
		else p[i] = (ld)(x / 2) + 0.5;
		if(!i) sum[i] = p[i];
		else sum[i] = sum[i - 1] + p[i];
	}
	ld ans = 0;
	repn(i, k - 1, n){
		int j = i - k;
		ld num;
		if(j == -1) num = 0;
		else num = sum[j];
		ans = max(ans, sum[i] - num);
	}
	cout << fixed << setprecision(10) << ans << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 6528
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

ll norm(ll x){
  if(x == 0) return 0;
  if(x == -1 || x == 1) return 1;
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    if(n ==0){ cout << 0<<endl; return 0;}
    vl v;
    ll phase = 1;
    if(n < 0) phase = -1;
    while(n != 0){
      if(phase == 1){
        v.pb(norm(n%2));
        n = n/2; n *=-1;
        phase = -1;
      } else if(phase == -1){
        v.pb(norm(n%2));
        n = (n-norm((n%2)))/2; n *=-1;
        phase = 1;
      }
    }
    for (auto it = v.crbegin(); it != v.crend(); it++) {
      cout <<*it;
    }

    cout << endl;


    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343



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

typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
const ll INF = 1e18;
const ll mod = 1e9+7;

int main() {
    ll n,p;
    string s;
    cin>>n>>p>>s;
    if (10%p==0){
      ll ans=0;
      rep(i,n){
        if ((s[i]-'0')%p==0) ans+=(i+1);
      }
      cout<<ans;
      return 0;

    }
    else{
      map<ll,ll>mp;
      ll fac=1;
      vector<ll> v(n+1,0);
      ll ans=0;
      mp[0]++;

      for(ll i=n-1;i>=0;i--){
        ll now=s[i]-'0';
        now*=fac;
        now%=p;
        now+=v[i+1];
        now%=p;
        v[i]=now;
        ans+=mp[now];
        mp[now]++;
        fac*=10;
        fac%=p;

      //  cout<<ans<<endl;

      }

      cout<<ans;
    }


}


Measured memory_bytes: 2564
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;
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; }
const ll INF = 1LL << 60;
#define MOD 1000000007
#define MAX_V 100010
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}

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

ll junnretu(ll n){
    ll ans=1;
    for (ll i=1;i<=n;i++){
        ans*=i;
    }
    return ans;
}

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll n,k,ans=0;
    cin >> n >> k;
    ll h[n];
    for (ll i=0;i<n;i++)cin >> h[i];
    sort(h,h+n);
    for (ll i=0;i<n-k;i++){
        ans+=h[i];
    }
    cout << ans << endl;
    return 0;
}






Measured memory_bytes: 1792
import fractions
import numpy as np
n,x=map(int,input().split())
li=np.array(input().split(),dtype=np.int64)

li=abs(li-x)

if n==1:
    print(li[0])
else:
    ans=0
    for i in li:
        ans=fractions.gcd(ans,i)
    print(ans)
    

Measured memory_bytes: 24832
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
hlist = []
for i in range(N):
    x,y,h = list(map(int, input().split()))
    hlist.append((x,y,h))

for i in range(101):
    for j in range(101):
        cx = i
        cy = j
        plist = [x for x in hlist if x[2] > 0]
        plist = sorted(plist, key=lambda x: x[2])
        if len(plist) == 0:
            continue

        for hpp in plist:
            hm = hpp[2] + abs(hpp[0]-cx) + abs(hpp[1]-cy)
            if hm < 1:
                continue
            ok = True
            for l in hlist:
                if l[2] != max((hm - abs(l[0] - cx) - abs(l[1] - cy)), 0):
                    ok = False
                    break
            if ok:
                print("{0} {1} {2}".format(cx, cy, hm))
                exit(0)



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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long
#define vi vector<int>

const double PI = 3.14159265358979323846;

int main() {
    int N, i;
    cin >> N >> i;
    cout << N - i + 1 << endl;
}

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

int main() {
  int n;
  cin >> n;
  n %= 10;
  if (n == 3) cout << "bon" << endl;
  else if (n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
  else cout << "hon" << endl;

  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i++){
        if (S.at(i) == 'C'){
            for (int j = i + 1; j < S.size(); j++){
                if (S.at(j) == 'F'){
                    cout << "Yes" << endl;
                    return 0;
                }
            }
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
    #ifdef DGC
        //freopen("a.txt", "r", stdin);
        //freopen("b.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0), cin.tie(0);

    int n;
    cin >> n;
    vector<pair<ll, ll>> a(n);
    for (auto &i : a)
    	cin >> i.S >> i.F;

    sort(a.begin(), a.end());

    ll cur = 0;
    for (auto i : a)
    {
    	cur += i.S;
    	if (cur > i.F)
    	{
    		cout << "No\n";
    		return 0;
    	}
    }

    cout << "Yes\n";

    return 0;
}


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

int main()
{
    int n, a[100010] = {};
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];

    sort(a, a + n);
    reverse(a, a + n);

    int t = 0;
    for (int i = 0; i < n; i++) {
        if (abs(a[0] / 2 - a[i]) < abs(a[0] / 2 - t)) t = a[i];
    }
    cout << a[0] << " " << t << endl;

    return 0;
}


Measured memory_bytes: 640
K=int(input())
S="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"
S=S.replace(',','')
s_list=S.split()
print(s_list[K-1])

Measured memory_bytes: 38384
moji = input().split()
kazu = list(map(int, input().split()))
moji_w = input()

if moji[0] == moji_w:
  kazu[0] = kazu[0] - 1
else:
  kazu[1] = kazu[1] - 1
print("{} {}".format(kazu[0], kazu[1]))

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

int main(){
  int A,B,T;
  
  cin >> A >> B >> T;
  
  int n=1;
  int k;
  
  while(n*A<=T+0.5){
    k=n*B;
    n++;
  }
  
  cout << k;
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i,N){
        cin >> A[i];
    }
    ll X = 0;
    for(ll i=40;i>=0;i--){
        X += (1LL << i);
        if(X > K){
            X -= (1LL << i);
            continue;
        }
        ll cnt = 0;
        rep(j,N){
            if((A[j] >> i) & 1LL) cnt++;
        }
        if(cnt > N/2){
            X -= (1LL << i);
        }
    }
    ll ans = 0;
    rep(i,N){
        ans += (X^A[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4004
n = int(input())
h = list(map(int,input().split()))
dp = [float("inf") for _ in range(n)]
dp[0] = 0
for i in range(n-1):
    dp[i+1] = min(dp[i+1], dp[i]+abs(h[i]-h[i+1]))
    if i<=n-3:
        dp[i+2] = min(dp[i+2], dp[i]+abs(h[i]-h[i+2]))
print(dp[n-1])

Measured memory_bytes: 13928
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=(j);i<(k);i++)
#define mp make_pair
#define sz(a) (int)(a).size()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef long double ld;
//----head----
int data[100005];
int main()
{
	int n,x;
	scanf("%d%d",&n,&x);
	rep(i,1,n+1)scanf("%d",&data[i]);
	ll ans=0;
	rep(i,1,n+1)if(data[i]>x)
	{
		ans+=data[i]-x;
		data[i]=x;
	}
	rep(i,2,n+1)if(data[i]+data[i-1]>x)
	{
		int a=x-data[i-1];
		ans+=data[i]-a;
		data[i]=a;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  string s;
  cin >> s;
  ll c = 0;
  for(int i = 0;i < (int)s.size();i++){
    c += s[i] - '0';
  }
  c = min(c,(ll)s.size() - c);
  cout << c * 2 << endl;
}

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

int main() {
    int N, K;
    string S;
    cin >> N >> K >> S;
    int def = 0;
    for(int i = 0; i < N; i++) {
        if(i != 0 && S[i] == 'L') {
            if(S[i - 1] == 'L') {
                def++;
            }
        }else if(i != N - 1 && S[i] == 'R'){
            if(S[i + 1] == 'R') {
                def++;
            }
        }
    }
    int rnum = 0;
    bool s = false;
    for(int i = 0; i < N - 1; i++) {
        if(s == false && S[i] == 'L' && S[i + 1] == 'R'){
            s = true;
        }else if(s == true && S[i] == 'R' && S[i + 1] == 'L'){
            s = false;
            rnum++;
        }         
    }
    int ans;
    if(rnum >= K){
        ans = def + K * 2;
    }else{
        if(S[0] != S[N - 1]){
            ans = def + rnum * 2 + 1;
        }else if(S[0] == 'L'){
            ans = def + rnum * 2;
        }else{
            if(S.find('L') == string::npos){
                ans = def;
            }else{
                ans = def + rnum * 2 + 2;
            }
        }
    }
    cout << ans << endl;
    cin >> N;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>

int main(){
    std::string s;
    std::cin >> s;
    if(s=="SUN"){
        std::cout << 7;
        return 0;
    }
    if(s=="MON"){
        std::cout << 6;
        return 0;
    }
    if(s=="TUE"){
        std::cout << 5;
        return 0;
    }
    if(s=="WED"){
        std::cout << 4;
        return 0;
    }
    if(s=="THU"){
        std::cout << 3;
        return 0;
    }
    if(s=="FRI"){
        std::cout << 2;
        return 0;
    }
    if(s=="SAT"){
        std::cout << 1;
    }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll=long long;

int main(){
   int A,B;
   cin>>A>>B;
   int h=100,w=100;
   vector<string> G(h,string(w,'#'));
   
   int cnt=0;
   int p=0;
   for(int i=0;i<h;i+=2){
      for(int j=0;j<w;j+=2){
         if(cnt<A-1){
            G[i][j]='.';
            cnt++;
         }
         else{
            p=i+2;
            break;
         }
      }
      if(p!=0) break;
   }
   
   cnt=0;
   for(int i=p;i<h;i+=2){
      for(int j=0;j<w;j+=2){
         if(cnt<B-1){
            G[i][j]=G[i][j+1]=G[i+1][j+1]='.';
            cnt++;
         }
         else{
            G[i][j]=G[i+1][j]=G[i][j+1]=G[i+1][j+1]='.';
         }
      }
   }

   cout<<h<<" "<<w<<endl;
   for(int i=0;i<h;++i){
      cout<<G[i]<<endl;
   }
}

Measured memory_bytes: 256
/*
C++ ???????????????????????????????????¬??????
??????AOJ-ITP1??????????????????
*/
#define _USE_MATH_DEFINES

#include <iostream> // ?¨??????\??????
#include <fstream>  // ??????????????\??????
#include <string>   // ???????????¢???
#include <vector>   // ???????????????
#include <cmath>    // ??°??????
#include <iomanip>  // stream???????????¢???
#include <algorithm>// max??¢??°??????

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;        // ????´???°????????????????????????
using std::fixed;         // ???????????????????¨???????????????????????????????
using std::setprecision;  // ?????°????°???°?????\???????????°????????????????????¨????????\???

int main() {
	int a;
	int count;
	int ccount;
	vector<int> c = { 0 };
	while (cin >> a)
	{
		a = a + 1;
		count = 0;
		
		// ?????§????????§????????????0??§???????????????
		c.resize(a);
		
		// 2*i????????§????????§?????????????????????1?????????
		for (size_t i = 2; i < a; i++)
		{
			for (size_t j = 2; i*j < a; j++)
			{
				c[i*j] = 1;
			}
		}
		c[0] = c[1] = 1;
		// ??????????????????0??????????????°????????????
		for (size_t i = 0; i < a; i++)
		{
			if (c[i] == 0) {
				count++;
			}
		}
		cout << count << endl;
	}
	return 0;
}

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

int main(){
 int N,L;
  cin >> N >> L;
  vector<string> G(N);
  for(int i=0; i<N; i++){
   	cin >> G[i]; 
  }
  sort(G.begin(),G.end());
  for(int i=0; i<N; i++){
    cout << G[i]; 
  }
  cout << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <math.h>

using namespace std;

int main(){

	int N, M, sum = 0, aux;
	cin >> N >> M;

	for (int i = 0; i < M; ++i){
		cin >> aux;
		sum += aux;
	}

	aux = N - sum;

	if(aux >= 0){
		cout << aux << endl;
	}else{
		cout << "-1" << endl;
	}
}


Measured memory_bytes: 3552
import sys

n, k = list(map(int, input().split()))

if k > (n - 1) * (n - 2) // 2:
	print(-1)
else:
	rest = (n - 1) * (n - 2) // 2 - k
	print((n - 1) + rest)
	for i in range(2, n + 1):
		print("1 " + str(i))

	for i in range(2, n + 1):
		for j in range(i + 1, n + 1):
			if rest == 0:
				sys.exit()
			print(str(i) + " " + str(j))
			rest -= 1


Measured memory_bytes: 40944
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,t = readline() |> split |> parseMap
    a = Tuple{Int,Int}[(0,0) for i in 1:n]
    for i in 1:n
        p,q = readline() |> split |> parseMap
        a[i] = (p,q)
    end
    a = sort(a,by=x->x[1])
    dp = -ones(Int,n+1,t+3000)
    dp[1,1] = 0
    for i in 1:n
        for j in 1:t
            if dp[i,j]>-1
                dp[i+1,j] = max(dp[i+1,j],dp[i,j])
                dp[i+1,j+a[i][1]] = max(dp[i+1,j+a[i][1]], dp[i,j]+a[i][2])
            end
        end
    end
    println(maximum(dp))
end
main()

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

namespace _20191201
{
    static class B
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int a = (int)(n / 1.08);
            string ans;
            if ((int)(a * 1.08) == n) { ans = a.ToString(); }
            else if((int)((a + 1) * 1.08) == n) { ans = (a + 1).ToString(); }
            else { ans = ":("; }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807
#define sortR(a,b) sort(a, b, greater<int>())

using namespace std;

long long GCD(long long a, long long b) {
	if (a < b)
		swap(a, b);
	if (b == 0) return a;
	else return GCD(b, a % b);
}
bool sosuu_check(int num) {
	int i;
	for (i = 2; i <= sqrt(num); ++i) {
		if (num%i == 0)
			return false;
	}
	return (num < 2) ? false : true;
}

int main() {
	ll N, M, i, j, ans = 0,a,b;
	cin >> N >> M;
	string S, T;
	cin >> S >> T;
	bool check = true;
	if (S[0] != T[0]) {
		cout << "-1" << endl;
		return 0;
	}
	if (N < M) {
		swap(N, M);
		swap(S, T);
	}
	if (N%M == 0) {
		REP(i, M) {
			j = i * N / M;
			if (S[j] != T[i]) {
				check = false;
				break;
			}
		}
		if (check) {
			cout << N << endl;
			return 0;
		}
		else {
			cout << "-1" << endl;
			return 0;
		}
	}
	ans = (ll)GCD(N, M);
	if (ans == 1) {
		cout << N * M << endl;
		return 0;
	}
	REP(i, N) {
		a = N / ans * i;
		b = M / ans * i;
		if (a > N || b > M)
			break;
		if (S[a] != T[b]) {
			cout << "-1" << endl;
			return 0;
		}
	}
	ans = N * M / ans;
	cout << ans << endl;
	return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
typedef long long ll;

int main(){
  int x;
  cin >> x;
  int h = x/3600;
  int m = (x%3600)/60;
  int s = (x%3600)%60;
  cout << h << ':' << m << ':' << s << endl;
}



Measured memory_bytes: 3092
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

int h, w;
int ans = 0;
char a[1010][1010];
int dist[1010][1010];
int dh[] = {1,0,-1,0};
int dw[] = {0,1,0,-1};

int
main(void){  
  ios_base::sync_with_stdio(false); cin.tie(0);
  
  cin >> h >> w;
  REP(i, h) REP(j, w) cin >> a[i][j];

  queue<P> q;

  REP(i, h) REP(j, w){
    if(a[i][j] == '#'){
      q.push({i, j});
      dist[i][j] = 0;
    }
    else{
      dist[i][j] = 1e9;
    }
  }

  auto check = [](auto hh, auto ww){ return (0 <= hh && hh < h && 0 <= ww && ww < w);};
  
  while(!q.empty()){
    P tmpp = q.front(); q.pop();
    REP(i, 4){
      int hh = tmpp.first + dh[i], ww = tmpp.second + dw[i];
      if(check(hh, ww) && dist[hh][ww] > dist[tmpp.first][tmpp.second]+1){
	//cerr << hh << ":" << ww << endl;
	dist[hh][ww] = dist[tmpp.first][tmpp.second]+1;
	q.push({hh, ww});
      }
    }
  }

  /*
  REP(i, h) {
    REP(j, w) cerr << dist[i][j] << " ";
    cerr << endl;
  }
  */
  
  REP(i, h){
    REP(j, w){
      ans = max(ans, dist[i][j]);
    }
  }
  cout << ans << endl;
  
  return 0;
}


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

int main(){
  int h,m,s,hh,mm,ss,ah,am,as;
  for(int i=0;i<3;i++){
    cin>>h>>m>>s>>hh>>mm>>ss;
    as=ss-s;
    am=mm-m;
    ah=hh-h;
    if(as<0){
      as+=60;
      am--;
    }
    if(am<0){
      am+=60;
      ah--;
    }
    cout<<ah<<' '<<am<<' '<<as<<endl;
  }
  return 0;
}

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

int main() {
	int n, min, swap=0;
	cin >> n;
	int *a = new int[n];
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n -1; i++) {
		min = i;
		for (int j = i + 1; j < n ; j++) {
			if (a[j] < a[min])
				min = j;
		}
		if (min != i) {
			a[i] = a[min] - a[i];
			a[min] -= a[i];
			a[i] += a[min];
			swap += 1;
		}
	}
	for (int i = 0; i < n-1; i++)
		cout << a[i] << ' ';
		cout << a[n - 1] << endl;
		cout << swap << endl;	
	return 0;
}

Measured memory_bytes: 3092
#include<stdio.h>
#include<math.h>
int main(){
  long long n;
  int i;

  scanf("%lld",&n);
  if(n==0) printf("0\n");
  else{
    for(i=0; i<62; i++){
      if((1LL<<i) > n) break;
    }
  printf("%d\n",i);
  }
  return 0;
}

Measured memory_bytes: 596
import sys

a = []
for line in sys.stdin:
    a.append(line)

time=0
for n in a:
    if time==0:
        Alist=n.split()
        time=1
    else:
        Blist=n.split()
        hit=0
        blow=0
        for i in range(4):
            if Blist[i]==Alist[i]:
                hit+=1
            else:
                if Blist[i] in Alist:
                    blow+=1
        time=0
        print hit,blow

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

class Program
{
    static void Main(string[] args)
    {
        var nd = Console.ReadLine().Split();
        var n = int.Parse(nd[0]);
        var d = int.Parse(nd[1]);
        var y = 2 * d + 1;
        Console.WriteLine((n + y - 1) / y);
    }
}


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

int main() {
  vector<int> num(3);
  int k;
  cin >> num.at(0) >> num.at(1) >> num.at(2) >> k;
  sort(num.begin(), num.end());

  int i = 0;
  while (i < k) {
    num.at(2) *= 2;
    i ++;
  }
  int ans = num.at(0) + num.at(1) + num.at(2);

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <utility>
#include <string>
#include <math.h>
using namespace std;

string input;
stack< pair<int, int> > top;
stack< pair<int, int> > water;


float getArea(int start, int end) {
	float area = 0;

	int height = 0;
	for (int i = start; i<end; i++) {
		switch (input[i]) {
		case'/':
			area += -(height + 0.5);
			height++;
			break;
		case'\\':
			area += -(height - 0.5);
			height--;
			break;
		case'_':
			area += -height;
			;
		}
	}

	return area;
}

int main() {

	cin >> input;

	int length = (int)(input.length());
	int height = 20005;
	for (int i = 0; i < length; i++) {
		switch (input[i]) {
		case 47:
			height++;
			if (top.size() != 0 && top.top().second == height) {
				pair<int, int> popped = top.top();
				top.pop();
				int area = round(getArea(popped.first, i));
				water.push(make_pair(popped.first, area));
			}
			break;
		case 92:
			top.push(make_pair(i, height));
			height--;
		}
	}

	if (water.size() == 0) {
		cout << 0 << endl;
		cout << 0 << endl;
		return 0;
	}

	pair<int, int> latest = water.top();
	water.pop();
	int sum = latest.second;
	int num = 1;
	int arr[20000];
	arr[0] = latest.second;
	while (water.size()>0) {
		if (water.top().first>latest.first) {
			water.pop();
		}
		else {
			latest = water.top();
			water.pop();
			sum += latest.second;
			arr[num++] = latest.second;
		}
	}

	cout << sum << endl;
	cout << num;

	for (int i = num - 1; i >= 0; i--) {
		cout << ' ' << arr[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3376
import Control.Monad
import Control.Applicative
import Data.List

-- String, Int, Char, IO
-- putStrLn
-- e.g.
-- 1
-- [a] <- map read . words <$> getLine => [1] -> a == 1
-- 1
-- a <- readLn
-- 1 2 3
-- lst <- map read . words <$> getLine => [1, 2, 3]
-- 1 2 3
-- [l, m, n] <- map read . words <$. getLine :: IO [Int] => [1, 2, 3]
-- 'a'
-- c <- getChar => c == 'a'
--
-- slst <- replicateM h getLine


getBysplit = map read . words <$> getLine

main :: IO()
main = do
  [x, t] <-  getBysplit :: IO [Int]
  let ans = if x - t > 0
              then x -t
              else 0
  print ans


Measured memory_bytes: 508