akhauriyash/Code-Regression huggingface dataset:
a,b,c = map(int,input().split())
count = 0
flag = True
while(a % 2 == 0 and b % 2 == 0 and c % 2 == 0):
    aa = a//2
    bb = b//2
    cc = c//2
    a = bb + cc
    b = aa + cc
    c = aa + bb
    if(a == b == c):
        flag = False
        break
    count += 1

if flag:
    print(count)
else:
    print(-1)


Measured memory_bytes: 3060
N,Y = map(int,input().split())
f = False
for x in range(Y//10000+1):
  r = Y-10000*x
  if r < 0: continue
  for y in range(r//5000+1):
    z = r-5000*y
    if z < 0: continue
    z = z // 1000
    if (x+y+z)==N: f = True
    if f: break
  if f: break
print(' '.join(map(str,[x,y,z])) if f else '-1 -1 -1')


Measured memory_bytes: 3060
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
const int INF = 1<<28;
const ll MOD = 1000000007;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

vi v;
void sieve() {
	bool prime[50000];
	fill(prime, prime+50000, true);
	prime[0] = prime[1] = false;
	REP(i, 50000)
		if(prime[i])
			for(int j = i*2; j < 50000; j += i)
				prime[j] = false;
	REP(i, 50000)
		if(prime[i])
			v.pb(i);
	return;
}

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

	sieve();
	int m, a, b;
	while(cin >> m >> a >> b, m|a|b) {
		ll max = 0;
		int p, q;
		REP(i, v.size()) {
			REP(j, v.size()) {
				if(v[i] * v[j] > m)
					break;
				if(v[i] * v[j] <= m && (double)a/b <= (double)v[i]/v[j]
						&& (double)v[i]/v[j] <= 1 && v[i] * v[j] > max) {
					max = v[i] * v[j];
					p = v[i]; q = v[j];
				}
			}
		}
		cout << p << ' ' << q << endl;
	}
	return 0;
}

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

int main(){
  ll x,y;
  ll a = 0;
  ll b = 0;

  scanf("%lld %lld", &x, &y);

  if(abs(x - y) <= 1) printf("Brown\n");

  else printf("Alice\n");

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    public static void main(String[] args) throws Exception {
        int N =Integer.parseInt(br.readLine());
        int[] arr =inputval();
        int result = 0;
        Map<Integer,Integer> map = new HashMap<>();
        for(int i=0; i<N; i++){
            if(!map.containsKey(arr[i])){
                map.put(arr[i],1);
            }else{
                map.put(arr[i], map.get(arr[i])+1);
            }
        }
        for(Map.Entry<Integer,Integer> entry: map.entrySet()){
            if(entry.getKey() <= entry.getValue()){
                result += entry.getValue()-entry.getKey();
            }else{
                result += entry.getValue();
            }
        }
        System.out.println(result);
    }


    static int[] inputval() throws Exception {
        String[] strarray = br.readLine().trim().split(" ");
        int[] intarray = new int[strarray.length];
        for (int i = 0; i < intarray.length; i++) {
            intarray[i] = Integer.parseInt(strarray[i]);
        }
        return intarray;
    }

    static void array_sout(int[][] array) {
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[0].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }

    static void array_sout(int[] array) {
        for (int i = 0; i < array.length; i++) {
            System.out.print(array[i] + " ");
        }
        System.out.println();
    }
}

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

#define int long long

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) if (ch == '-') f = -1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) x = (x << 1) + (x << 3) + ch - '0';
	return x * f;
}

const int N = 2e5 + 5;
vector<int> a, b;
char s[N];

signed main()
{
	int n = read(), k = read(), c = read();
	scanf("%s", s + 1);
	
	for (int i = 1; i <= n; ++i) if (s[i] == 'o') a.push_back(i), i += c;
	for (int i = n; i >= 1; --i) if (s[i] == 'o') b.push_back(i), i -= c;
	for (int i = 0; i < k; ++i) if (a[i] == b[k - i - 1]) printf("%d\n", a[i]);
	
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  int x = N;
  while(x > 0){
    sum += (x % 10);
    x = x / 10; 
    if(x < 10){
      sum += x;
      break;
    }
  }
  
  if(N % sum == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int n,k;cin>>n>>k;
  int d;
  int a[n];
  rep(i,n) a[i]=0;
  int b;
  rep(i,k){
    cin>>d;
    rep(j,d){
      cin>>b;
      b--;
      a[b]++;
      //cout<<b<<endl;
    }
  }
  int ans=0;
  rep(i,n){
    if(a[i]==0) {
      ans++;
    }
  }
  cout<<ans<<endl;
}

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

long long int N;

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

    cin >> N;

    long long int ans = 1e12;
    for(long long int i = 1; i * i <= N; i++) {
        if(N % i == 0) {
            ans = min(ans, i + N/i);
        }
    }

    printf("%lld\n", ans - 2);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

vector<vector<ll>> DP;

char win(char t) {
    char w;
    if (t == 'r') w = 'p';
    else if (t == 's') w = 'r';
    else if (t == 'p') w = 's';
    return w;
}

int main() {
    ll N, K; cin >> N >> K;
    ll R, S, P; cin >> R >> S >> P;
    string T; cin >> T;
    string hand;

    map<char,int> bonus;
    bonus['r'] = R;
    bonus['s'] = S;
    bonus['p'] = P;
    
    ll score = 0;
    for (int i = 0; i < N; i++) {
        char t = T[i];
        char w = win(t);
        if (i >= K && hand[i - K] == w) { // if you can't win
            if (i + K < N) { // There's future fight
                w = win(T[i+K]); // i+K'th turn's winning hand
                if (t == w) t = T[i+K]; // if t shouldn't be used, change
            }
            hand.push_back(t);
            continue;
        } 
        score += bonus[w];
        hand.push_back(w);
    }

    cout << score << endl;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
ll a[200005];
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n;cin>>n;
  REP(i,n)cin>>a[i];
  ll cnt=0,r=0,tmp=0;
  // 各lに対して考える
  for(int l=0;l<n;l++){
    while(r<n && (tmp&a[r])==0){
      tmp|=a[r];
      r++;
    }
    cnt+=r-l;
    tmp^=a[l];
  }
  P(cnt);
  // while(true){
  //   if(r>=n || l>=n)break;
  //   cout<<l<<" "<<r<<"\n";
  //   if((tmp&a[r])==0){
  //     tmp+=a[r];
  //     r++;
  //     // cout<<l<<" "<<r<<"\n";
  //   }else{
  //     // cout<<l<<" "<<r<<"\n";
  //     cnt+=r-l;
  //     tmp+=a[l];
  //     l++;
  //   }
  //
  //   if(r>=n){
  //     // cout<<l<<" "<<r<<"\n";
  //     cnt+=r-l;
  //     r=n-1;
  //     tmp^=a[l];
  //     l++;
  //   }
  //   if(l>r){
  //     r=l;
  //     tmp=a[r];
  //   }
  // }
  // P(cnt);

  return 0;
}


Measured memory_bytes: 1792
N=int(input())
S=input()

def atoi(a):
    alphabet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o',
                'p','q','r','s','t','u','v','w','x','y','z']
    return alphabet.index(a)

a_list = [0 for i in range(26)]
for i in range(N):
    a_list[atoi(S[i])]+=1
ans = 1
for i in range(26):
    ans *= (a_list[i]+1)
    ans = ans%(10**9 + 7)
if ans>0:
    ans-=1
else:
    ans=10**9 + 6
print(ans)

Measured memory_bytes: 3188
from collections import defaultdict
X,Y = list(map(int,input().split()))
M = defaultdict(int)
M[3] = 100000
M[2] = 200000
M[1] = 300000
sm = 0
sm += M[X]
sm += M[Y]
if X == Y == 1:
    sm += 400000
print(sm)

Measured memory_bytes: 3316
/**
 * author: apikdech
 * created: 19:02:31 28-12-2019
 * last modified: 19:22:17 28-12-2019
**/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  ll n, a, b;
  cin >> n >> a >> b;
  if ((b-a) % 2 == 0) cout << (b-a)/2LL << "\n";
  else {
    ll ans = min(max(a-1, b-1), max(n-a, n-b));
    ll cur = 0;
    if (a-1 < n-b) {
      cur = a;
      b -= a;
      a = 1;
      ans = min(ans, cur + (b-a)/2);
    } else {
      b = n - b + 1;
      a = n - a + 1;
      cur = a;
      b -= a;
      a = 1;
      ans = min(ans, cur + (b-a)/2);
    }
    cout << ans << "\n";
  }
  // cerr << "time = " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << " ms\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> D1(N),D2(N);
    for(int i=0;i<N;i++) cin >> D1.at(i) >> D2.at(i);
    int count = 0;
    for(int i=0;i<N;i++){
        if(D1.at(i)==D2.at(i)) count++;
        else count = 0;
        if(count==3) break;
    }
    if(count==3) cout << "Yes" << endl;
    else cout << "No" << endl;
    
	return 0;
}

Measured memory_bytes: 3656
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <array>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3fB
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	long long l, r; cin >> l >> r;
	if ((r - l + 1) >= 3000) {
		cout << 0;
		return 0;
	}

	long long ans = INT_MAX;
	for (long long i = l; i <= r - 1; i++) {
		for (long long j = i + 1; j <= r; j++) ans = min(ans, ((i * j) % 2019));
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 3160
n = int(input())
s = input()

w_counter_all = 0
for i in range(n):
    if s[i] == '.': # white
        w_counter_all += 1

if s[0] == '.':
    cost1 = 0
else:
    cost1 = 1
cost1_list = [cost1]
for i in range(1, n):
    if s[i] == '#':
        # black
        cost1 += 1
    cost1_list.append(cost1)


cost_all = [w_counter_all]
for i in range(n):
    cost_all.append(n - i - 1 - cost1_list[-1] + cost1_list[i] * 2)
print(min(cost_all))


Measured memory_bytes: 19328
s = input()
t = input()

result = 0
for i in range(len(s) - len(t) + 1):
    c = 0
    for m in range(len(t)):
        if t[m] == s[m+i]:
            c+=1
    if c > result:
        result = c
print(len(t) - result)

Measured memory_bytes: 9120
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int x = sc.nextInt();
    int left = x-(k-1);
    int right = x+(k-1);
    for(int i=left;i<=right;i++){
      System.out.print(i+" ");
    }
  }
}

Measured memory_bytes: 23636
import sys
import math

a,b,x=(int(x) for x in input().split())

if a*a*b/2 <= x:
	T=a*(b-(x/(a*a)))
	c=2*T/a 
	d = math.atan2(c, a)
	d_deg=math.degrees(d)
else:
	e=2*x/(a*b)
	d = math.atan2(b, e)
	d_deg=math.degrees(d)
	
#print(d)
print(d_deg)
 

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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
vector< bool > prime_table(ll n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(ll i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(ll j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  auto p=prime_table(1000000);
  ll x;cin>>x;
  while(!p[x])x++;
  cout<<x<<endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    string str;
    int c[4]={0};
    for(int i=0; i<N; i++){
        cin >> str;
        switch(str.at(0)){
            case 'A':
            c[0]++;
            break;
            case 'W':
            c[1]++;
            break;
            case 'T':
            c[2]++;
            break;
            case 'R':
            c[3]++;
            break;
        }
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n"
        ,c[0],c[1],c[2],c[3]);
    return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;
using ll = long long;

ll n;
ll d[202];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	for(int i=0; i<n; ++i)cin>>d[i];
	ll sum=0;
	for(int i=0; i<n; ++i){
		for(int j=i+1; j<n; ++j){
			sum+=d[i]*d[j];
		}
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long s[1000];
int main()
{
    int T;
    cin>>T;
    int j=0;
    set<long long>H;
    for(int i=0; i<T; i++)
    {
        cin>>s[i];
    }
    sort(s,s+T);
    long long m=999999999;
    for(int j=s[0]; j<=s[T-1]; j++)
    {
        long long n=0;
        for(int i=0; i<T; i++)
        {

            n+=(s[i]-j)*(s[i]-j);
        }
        m=min(m,n);
    }
    cout<<m;




    return 0;
}




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

int main(){
  int h,w;

  while(1){
    cin>>h>>w;
    if(h==0 && w==0) break;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if((i+j)%2==0) cout<<"#";
	else cout<<".";
      }
      cout<<endl;
    }
    cout<<endl;
  }
  return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll zero = 0;
ll INF = 10000000000;

int main(){
    string s;
    cin >> s;
    string changed;
    changed = "";
    
    //最後の文字がBCのCでないときは結果に影響しないので無視する
    for(int i = 0; i < s.size() -1 ; i++){
        if( s.at(i) == 'B' && s.at(i+1) == 'C'){
            changed = changed + 'D';
            i++;
        }
        else{
            changed = changed + s.at(i);
        }
    }
    
    ll cnt = 0;
    int tmpa = 0; //このフェーズで登場したaの数
    for(char c : changed){
        if (c == 'A'){
            tmpa++;
        }
        else if (c == 'D'){ //このフェーズで登場したaの数だけ足す
            cnt += tmpa;
        }
        else{ //リセットする(フェーズ更新)
            tmpa = 0;
        }
    }
    
    printf("%lld", cnt);
    
}

Measured memory_bytes: 1436
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int k = sc.nextInt();

		if ( k <= 12 ) {
			System.out.println(k);
			System.exit(0);
		}

		LinkedList<Long> ll = new LinkedList<Long>();
		for ( int i=1; i<=9; i++ ) {
			ll.add((long)i);
		}
		int ix = 0;

		while ( ll.size() < k ) {
			long li = ll.get(ix);
			long last = li%10l;
			long add0 = li*10l + last;
			if ( last!=0 ) {
				ll.addLast(add0-1l);
			}

			ll.addLast(add0);

			if ( last!=9 ) {
				ll.addLast(add0+1l);
			}

			ix++;
		}

		System.out.println(ll.get(k-1));
	}
}


Measured memory_bytes: 25812
def General_Binary_Search(L,R,cond,Integer=True,ep=1/(1<<20)):
    """一般的な二部探索を行う.
    L:解の下限
    R:解の上限
    cond:条件(1変数関数,単調減少を満たす)
    Integer:解を整数に制限するか?
    ep:Integer=Falseのとき,解の許容する誤差
    """

    if Integer:
        R+=1
        while R-L>1:
            C=L+(R-L)//2
            if cond(C):
                L=C
            else:
                R=C
        return L
    else:
        C=(R-L)/2
        while (R-C)>ep:
            if cond(C):
                L=C
            else:
                R=C
            C=L+(R-L)/2
        return C
#======================================
N,K=map(int,input().split())
A=list(map(int,input().split()))

def f(x):
    r=0
    for a in A:
        r+=(a+x-1)//x
    return r-N

print(-General_Binary_Search(-max(A),-1,lambda x:f(-x)<=K))

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

public class Main {

	static long mod = (long) 1e9 + 7;
	static PrintWriter out = new PrintWriter(System.out);
	static Reader scn = new Reader();

	public static void main(String[] args) throws IOException {
		StringBuilder king = new StringBuilder();
		long n = scn.nextInt(), m = scn.nextInt();
		long s = 0;
		for (long i = 0; i < m; i++)
			s += scn.nextLong();

		out.println(s > n ? -1 : n - s);
		out.flush();
	}

	public static class Reader {

		final private int BUFFER_SIZE = 1 << 16;
		private DataInputStream din;
		private byte[] buffer;
		private int bufferPointer, bytesRead;

		public Reader() {
			din = new DataInputStream(System.in);
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public Reader(String file_name) throws IOException {
			din = new DataInputStream(new FileInputStream(file_name));
			buffer = new byte[BUFFER_SIZE];
			bufferPointer = bytesRead = 0;
		}

		public String readLine() throws IOException {
			byte[] buf = new byte[100000 + 1];
			int cnt = 0, c;
			while ((c = read()) != -1) {
				if (c == '\n')
					break;
				buf[cnt++] = (byte) c;
			}
			return new String(buf, 0, cnt);
		}

		public int nextInt() throws IOException {
			int ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public long nextLong() throws IOException {
			long ret = 0;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();
			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');
			if (neg)
				return -ret;
			return ret;
		}

		public double nextDouble() throws IOException {
			double ret = 0, div = 1;
			byte c = read();
			while (c <= ' ')
				c = read();
			boolean neg = (c == '-');
			if (neg)
				c = read();

			do {
				ret = ret * 10 + c - '0';
			} while ((c = read()) >= '0' && c <= '9');

			if (c == '.')
				while ((c = read()) >= '0' && c <= '9')
					ret += (c - '0') / (div *= 10);
			if (neg)
				return -ret;
			return ret;
		}

		private void fillBuffer() throws IOException {
			bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
			if (bytesRead == -1)
				buffer[0] = -1;
		}

		private byte read() throws IOException {
			if (bufferPointer == bytesRead)
				fillBuffer();
			return buffer[bufferPointer++];
		}

		public void close() throws IOException {
			if (din == null)
				return;
			din.close();
		}

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

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

		public int[][] nextInt2DArray(int m, int n) throws IOException {
			int[][] arr = new int[m][n];
			for (int i = 0; i < m; i++)
				for (int j = 0; j < n; j++)
					arr[i][j] = nextInt();
			return arr;
		}
	}
}

Measured memory_bytes: 32640
// Problem : B - Choose Integers
// Contest : AtCoder - AtCoder Beginner Contest 060
// URL : https://atcoder.jp/contests/abc060/tasks/abc060_b
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

double pi=acos(-1.0);
const int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
int a,b,c;cin>>a>>b>>c;
for(int i=1;i<=1000;i++)
{
	if((i*b+c)%a==0)
	{
		cout<<"YES";return;
	}
}
cout<<"NO";
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int a, b, i = 0, count, answers[100];
    char op;

    while (1)
    {
        scanf("%d %c %d", &a, &op, &b);
        if (op == '?') {
            break;
        }
        switch (op)
        {
        case '+': answers[i] = a + b;
                break;
        case '-': answers[i] = a - b;
                break;
        case '*': answers[i] = a * b;
                break;
        case '/': answers[i] = a / b;
                break;
        default:
            break;
        }
        i++;
    }
    
    for (count = 0; count < i; count++) {
        printf("%d\n", answers[count]);
    }

    return 0;
}


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

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d ;
  if (abs(a - c) <= d) {
    cout << "Yes";
  } else if (abs(a - b) <= d and abs(b - c) <= d) {
    cout << "Yes";
  } else {
    cout << "No";
  }
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
rep(i,N) {
  cin >> list[i];
}
//配列(スタックとしても使える)
vector<int> list;
list.at(i)
vector<vector<int>> list(10, vector<int>(10));
//ソート クイックだからO(NlogN)
sort(all(list));
sort(all(list), greater<int>());

//配列の内容表示
dout << "====listの内容====\n";
for (int edp = 0; edp < N; edp++) dout << list[edp] << endl;
dout << "====ここまで====\n";


//配列の最小最大(Nは要素数)
*min_element(all(c))
*max_element(all(c))

//a[0]からa[N]を逆順にする(計算量はO(N))
reverse(all(a));
//listの末尾に要素を追加
list.push_back(10);
//listの末尾から要素を削除
list.pop_back();
//空ですか？
list.empty()



//キュー(待ち行列)
//定義
queue<int> a;
//追加
a.push(x);
//取る
a.pop();
//チェック
a.front()
//サイズ
a.size()
//空ですか
a.empty()



//優先度付きキュー※全部計算量がO(NlogN)あるので注意
// int 型の要素を持ち、最も小さい値を取り出す形の priority_queue を定義
priority_queue<int, vector<int>, greater<int>> Q1;
// double 型の要素を持ち、最も大きい値を取り出す形の priority_queueを定義
priority_queue<double, vector<double>, less<double>> Q2;
//追加
a.push(x);
//取る
a.pop();
//一番小さいの教えて下さい
a.top()
//サイズ
a.size()
//空ですか
a.empty()



//部分文字列
//添字3から5文字
s.substr(3,5)
//添字3から全部
s.substr(3)

//入れ替え
swap(a,b);



// int 型の番地に string 型の変数を記録する場合（2^31 要素の string型配列と同じような感じ）
map<int, string> mp;
for (auto itr =mp.begin(); itr != mp.end(); itr++) {
    //順番にマップを眺める。itr->firstでキー、itr->secondがバリュー
}

//ソート済みのaの中で初めてx以上になるインデックスを返す
lower_bound(all(a), x) - a

//next_permutation
do {
  //ここにパーテーションがくる
} while (next_permutation(s.begin(), s.end()));

//set
set<int> hoge;
hoge.insert(50);  //hogeに挿入。重複は無視される。
hoge.insert(20);  //内部は小さい順に並ぶ
hoge.erase(50);   //hogeから消し去る。
//40以上である最小の要素を指すイテレーターを返す。
//もちろんそんなものはないからEndが出力される
auto itr1 = Set.lower_bound(40);
if (itr1 == Set.end()) cout << "End" << endl;
else cout << (*itr1) << endl;

//pair
//たくさんつくる
vector<pair<int,string>> hoge(10);
//参照
hoge[0].first
sort(all(hoge), greater<pair<int, string>>());




*/


Measured memory_bytes: 256
package main

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

func main() {
	n := readI()
	for i := 0; i < n; i++ {
		a := readI()
		if a%2 == 0 {
			if !(a%3 == 0 || a%5 == 0) {
				fmt.Println("DENIED")
				return
			}
		}
	}
	fmt.Println("APPROVED")
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


Measured memory_bytes: 1784
import java.util.*;

class Main {

  static int x4[] = {0, 1, 0, -1};
  static int y4[] = {1, 0, -1, 0};

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

    String a = sc.next().replaceAll("\\?", ".");
    String b = sc.next();
    for (int i = a.length() - b.length(); i >= 0; i--) {
      String s = a.substring(i, i + b.length());
      if (b.matches(s)) {
        a = a.replaceFirst(a.substring(0, i) + s, a.substring(0, i) + b).replaceAll("\\.", "a");
        System.out.println(a);
        return;
      }
    }
    System.out.println("UNRESTORABLE");
  }
}


Measured memory_bytes: 22612
using System;
using System.Linq;

class Problem {
    private static void InsertionSort(int[] A) {
        Console.WriteLine(string.Join(" ", A.Select(n => n.ToString()).ToArray()));
        for (var i = 1; i < A.Length; i++) {
            var v = A[i];
            var j = i - 1;
            while (j >= 0 && A[j] > v) A[j + 1] = A[j--];
            A[j + 1] = v;
            Console.WriteLine(string.Join(" ", A.Select(n => n.ToString()).ToArray()));
        }
    }
    public static void Main() {
        Console.ReadLine();
        InsertionSort(Console.ReadLine().Split().Select(int.Parse).ToArray());
    }
}


Measured memory_bytes: 9756
from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush,heappop
import math
from collections import *
from functools import reduce,cmp_to_key
import sys
input = sys.stdin.readline

M = mod = 10**9 +7
def factors(n):return sorted(set(reduce(list.__add__, ([i, n//i] for i in range(1, int(n**0.5) + 1) if n % i == 0))))
def inv_mod(n):return pow(n, mod - 2, mod)

def li():return [int(i) for i in input().rstrip('\n').split()]
def st():return input().rstrip('\n')
def val():return int(input().rstrip('\n'))
def li2():return [i for i in input().rstrip('\n')]
def li3():return [int(i) for i in input().rstrip('\n')]
def li4():return [float(i) for i in input().rstrip('\n').split(' ')]





n = val()
l = []
for i in range(n):l.append(li())
dp = [[0]*3 for i in range(n)]
dp[0] = l[0][:]
for i in range(1,n):
    for j in range(3):
        dp[i][j] = l[i][j] + max(dp[i-1][j-1],dp[i-1][j-2])
print(max(dp[-1]))

Measured memory_bytes: 70364
#include<stdio.h>
#include<cstdio>
#include<algorithm>
using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int ary1[100010] = {}, ary2[100010] = {};
  for (int i=0 ; i<n ; i++) {
    int num;
    scanf("%d", &num);
    if (i % 2 == 0) {
      ary1[num]++;
    } else {
      ary2[num]++;
    }
  }

  int even_max = 0, odd_max = 0;
  for (int i=0 ; i<100010 ; i++) {
    if (ary1[i] > ary1[even_max]) {
      even_max = i;
    }
    if (ary2[i] > ary2[odd_max]) {
      odd_max = i;
    }
  }

  if (even_max != odd_max) {
    printf("%d\n", n - ary1[even_max] - ary2[odd_max]);
  } else {
    sort(ary1, ary1+100010);
    sort(ary2, ary2+100010);
    printf("%d\n", min(n - ary1[100009] - ary2[100008], n - ary1[100008] - ary2[100009]));
  }

}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main() {
	string a,b,c;
	cin>>a>>b>>c;
	if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        for (int i = 1; ; i++) {
            if(n < i * i) {
                System.out.println((i - 1) * (i - 1));
                return;
            }
        }
    }
}

Measured memory_bytes: 35644
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e8;
using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")

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

	unsigned long long a[5],n;
	int b[6];
	unsigned long long time=0;
	int osoi=0;

	cin >> n;

	for (int i = 0;i < 5;i++)
	{
		cin >> a[i];
		if (a[osoi] > a[i])
			osoi = i;
	}

	if (n%a[osoi] == 0)
	{
		time += 4 + (n / a[osoi]);
	}
	else
	{
		time += 4 + (n / a[osoi] + 1);
	}

	cout << time << endl;

}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int x, y, gcd, box;
  scanf("%d %d", &x, &y); 
  box = 0;
  while(1){
    if (x < y){
      box = x;
      x = y;
      y = box;
    }
    x %= y;
    if (x == 0){
      break;
    }
  }
  printf("%d\n", y);
}
    

Measured memory_bytes: 1816
#include <iostream>

using namespace std;

int main(){
	int N, x, y, M, distance[30], placex, placey;
	char move[30];
	while(1){
		cin >> N;
		if(N == 0) break;

		int field[25][25] = {{0}};
		int placex = 10, placey = 10, count = 0;

		for(int i = 1;i <= N;i++){
			cin >> x >> y;
			field[x][y] = 1;
		}

		cin >> M;
		for(int i = 0;i < M;i++){
			cin >> move[i] >> distance[i];
		}

		for(int i = 0;i < M;i++){
			if(move[i] == 'N'){
				for(int j = 0;j < distance[i];j++){
					placey++;
					if(field[placex][placey] == 1){
						count++;
						field[placex][placey] = 0;
					}
				}
			} else if (move[i] == 'E'){
				for(int j = 0;j < distance[i];j++){
					placex++;
					if(field[placex][placey] == 1){
						count++;
						field[placex][placey] = 0;
					}
				}
			} else if (move[i] == 'W'){
				for(int j = 0;j < distance[i];j++){
					placex--;
					if(field[placex][placey] == 1){
						count++;
						field[placex][placey] = 0;
					}
				}
			} else {
				for(int j = 0;j < distance[i];j++){
					placey--;
					if(field[placex][placey] == 1){
						count++;
						field[placex][placey] = 0;
					}
				}
			}
		}
		if(count == N){
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1152
N, x, *A = map(int, open(0).read().split())

B = A[:]
ans = sum(A)

for k in range(1, N):
    B = [min(B[i], A[i - k]) for i in range(N)]
    tmp = sum(B) + k * x
    if tmp < ans:
        ans = tmp
    else:
        break
print(ans)

Measured memory_bytes: 3188
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int k = sc.nextInt();
        int x = sc.nextInt();
        if(k * 500 >= x){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }



    private static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

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

        private int readByte() {
            if (hasNextByte())
                return buffer[ptr++];
            else
                return -1;
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

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

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

        public long nextLong() {
            if (!hasNext())
                throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
                throw new NumberFormatException();
            return (int) nl;
        }

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

}



Measured memory_bytes: 22612
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__

int M[22][22];
int C[22][22];

queue<pair<int,int>> Q;

int H,W;
int mx,my;

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

void drawC(int H, int W){
  REP(y,H){
    REP(x,W){
      cout << setw(3) << C[y][x] << " ";
    }
    cout << endl;
  }
  cout << "----------------------" << endl;
  return;
}

int bfs(int h, int w) {
  int nmax=0;
  
  C[h][w]=0;
  Q.push(make_pair(h,w));
  
  while(!Q.empty()){
    pair<int,int> t=Q.front();
    Q.pop();
    int tx=t.second;
    int ty=t.first;
    
    REP(i,4){
      int nx=tx+dx[i];
      int ny=ty+dy[i];
      if(M[ny][nx]==-1){continue;}
      if(C[ny][nx]!=-1){continue;}
      C[ny][nx]=C[ty][tx]+1;
      Q.push(make_pair(ny,nx));
    }
  }
  
  REP(i,H+2){
    REP(j,W+2){
      if(nmax<C[i][j]){
        nmax=C[i][j];
        mx=j;
        my=i;
      }
    }
  }
  
//  drawC(H+2,W+2);
  
  return nmax;
}
 

void draw(int H, int W){
  REP(y,H+2){
    REP(x,W+2){
      cout << setw(3) << M[y][x] << " ";
    }
    cout << endl;
  }
  return;
}

void initC(void){
  REP(i,22){
    REP(j,22){
      C[i][j]=-1;
    }
  }
}

void solve(void){
  
  cin >> H >> W;
  
  REP(y,22){
    REP(x, 22){
      if(x==0||x>=W+1||y==0||y>=H+1){M[y][x]=-1; continue;}
      char tmp;
      cin >> tmp;
      if(tmp=='.'){M[y][x]=0;mx=x;my=y;}
      if(tmp=='#'){M[y][x]=-1;}
    }
  }
  
//  draw(H,W);
  
  int ans=0;
  
  REP(i,H+2){
    REP(j,W+2){
      if(M[i][j]==0){
        initC();
        chmax(ans,bfs(i,j));
      }
    }
  }
  
  cout << ans << endl;

  return;
   
}


int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();
 
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n;
  cin >> n;
  vector<ll> a(n);
  ll ans = 0LL;
  for (ll i = 0LL; i < n; i++) {
    cin >> a[i];
    while (a[i] % 2LL == 0) {
      ans++;
      a[i] /= 2LL;
    }
  }
  cout << ans << endl;
  return 0;
}

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

void Scan(string* a,int n){
    for(int i=0;i<n;i++)
        cin>>a[i];
}

bool Mat(string* a,string* b,int x,int y,int m){
    for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
            if(a[x+i][y+j]!=b[i][j]) return false;
        }
    }
    return true;
}

void Solve(string* a,string* b,int n,int m){
    for(int i=0;i<=n-m;i++){
        for(int j=0;j<=n-m;j++){
            if(Mat(a,b,i,j,m)){
                cout<<"Yes"<<endl;
                return;
            }
        }
    }
    cout<<"No"<<endl;
}

int main(){
    int n,m;
    string a[55],b[55];
    while(cin>>n>>m){
        Scan(a,n);
        Scan(b,m);
        Solve(a,b,n,m);
    }
    return 0;
}

Measured memory_bytes: 3020
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
 	long L[] = new long[100];
    L[0] = 2;
    L[1] = 1;
    
    for(int i = 2; i <= N; i++){
    	L[i] = L[i - 2] + L[i - 1];
    }
    System.out.println(L[N]);
  }
}

Measured memory_bytes: 23892
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <bitset>
#include <cmath>

#define ll long long
#define repp(i,a,b) for(int i=(int)(a);i<(int)(b);++i)

using namespace std;

int main() {
    int N; cin >> N;
    vector<int> p(N); repp(i,0,N) cin >> p[i];
    int count = 0;
    repp(i,0,N) {
        if (p[i] - 1 != i) ++count;
    }
    if (count < 3) cout << "YES" << endl;
    else cout << "NO" << endl;

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] c = sc.next().toCharArray();
		int count=0;
		for (int i=0;i<c.length;i++){
			if (c[i]=='o'){
        	count+=1;
        	}
        }
		System.out.print(700+count*100);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
   vector<string> s(3);
   rep(i,3) cin >> s[i];
   int i = 0;
   while(1) {
       if(s[i].size()==0) {
           cout << char(i+'A') << endl;
           return 0;
        }
        char t = s[i][0];
        s[i].erase(s[i].begin());
        i = t - 'a';
   }
    
    return 0;
}

Measured memory_bytes: 3616
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define N 100010
#define mod 1000000007
using namespace std;
struct mat{
	int a[3][3];
	void clear(){memset(a, 0, sizeof(a));}
}A, B;
int n, m, w[N], f[3], g[3];
inline mat operator*(mat A, mat B){
	mat C; C.clear();
	for(int i=0; i<=2; i++)
		for(int j=0; j<=2; j++)
			for(int k=0; k<=2; k++)C.a[i][j]=(C.a[i][j]+(ll)A.a[i][k]*B.a[k][j]%mod)%mod;
	return C;
}
inline mat pow(mat A, int x){
	mat s; s.clear(); for(int i=0; i<=2; i++)s.a[i][i]=1;
	while(x){if(x&1)s=s*A; A=A*A; x>>=1;}
	return s;
}
int main(){
	scanf("%d%d", &n, &m);
	for(int i=1; i<=m; i++)scanf("%d", &w[i]); w[0]=0; w[m+1]=n;
	A.a[0][0]=2; A.a[0][1]=2; A.a[0][2]=1;
	A.a[1][0]=1; A.a[1][1]=1; A.a[1][2]=1;
	A.a[2][0]=1; A.a[2][1]=0; A.a[2][2]=1;
	f[0]=1; f[1]=0; f[2]=0;
	for(int i=1; i<=m+1; i++){
		B=pow(A, w[i]-w[i-1]-1);
		memcpy(g, f, sizeof(g));
		for(int j=0; j<=2; j++){
			f[j]=0;
			for(int k=0; k<=2; k++)f[j]=(f[j]+(ll)g[k]*B.a[k][j]%mod)%mod;
		}
		if(i==m+1){printf("%d", ((f[0]+f[1])%mod+f[2])%mod); return 0;}
		memcpy(g, f, sizeof(g));
		f[0]=g[0];
		f[1]=(g[0]*2%mod+g[1])%mod;
		f[2]=((g[0]+g[1])%mod+g[2])%mod;
	}
	return 0;
}

Measured memory_bytes: 512
from itertools import accumulate
n,m,q=map(int,input().split())
s=[[0 for i in range(n)] for j in range(n)]
for i in range(m):
    x,y=map(int,input().split())
    s[n-x][y-1]+=1
def f(s):
    for i in range(len(s)):
        s[i]=list(accumulate(s[i]))
f(s)
s=list(zip(*s))
f(s)
for i in range(q):
    x,y=map(int,input().split())
    print(s[y-1][n-x])

Measured memory_bytes: 11636
#include<iostream>
#include <string>
#include <cstring>
using namespace std;
 
int main(){
    int X, N;
    int p;
  	int array[102]={};
    cin>> X>> N;
    //array[X] = 1;
    for(int i = 0; i<N; i++){
      cin >>p; 
      array[p]=1;
    }
  	for(int i=0; i<100;i++){
        //cout<<array[X-i]<<" "<<array[X+i]<<endl;
        //cout<<N/2<<" "<<X-i<<endl;
	    if (X-i>=0 && array[X-i]==0){
            cout << X-i<<endl;
            return 0;
        } else if(X+i<=101 && array[X+i]==0){
            cout << X+i<<endl;
            return 0;
        }
    }
    return 0;
}

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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;

int H,W;
string s[500];
bool pathed[500][500] = {0};
ll cntw(0),cntb(0);
int th[4]= {1,-1,0,0};
int tw[4]= {0,0,1,-1};

void dfs(int h,int w){
  //cout << h <<  " " << w << endl;
  pathed[h][w] = true;
  if(s[h][w] == '.') cntw++;
  else cntb++;
  for(int i(0);i<4;i++){
    int nh = h+th[i],nw = w + tw[i];
    if(nh < H && nh >= 0 && nw < W && nw >= 0 && pathed[nh][nw] == false && s[h][w] != s[nh][nw]){
      dfs(nh,nw);
    }
  }
}
int main(){
  cin>>H>>W;
  for(int i(0);i<H;i++){
    cin>>s[i];
  } 
  ll cnt(0);
  for(int i(0);i<H;i++){
    for(int j(0);j<W;j++){
      if(pathed[i][j] == false){
        cntw = 0;
        cntb = 0;
        dfs(i,j);
        cnt += cntb*cntw;
      }
    }
  }
  cout << cnt << endl;
  return 0;
}



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

int main() {
    ll a,b,k;
    cin >> a >> b >> k;
    if (k >= a) {
        k -= a;
        a = 0;
    } else {
        a -= k;
        k = 0;
    }
    if (k >= b) {
        k -= b;
        b = 0;
    } else {
        b -= k;
        k = 0;
    }
    
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256