akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

LL ce_sqrt(LL x) {
	assert(x >= 0);
	LL y = sqrtl(x);
	if(y * y < x) { y++; }
	{
		LL z = y - 1;
		assert(y * y >= x);
		assert(z * z <  x || z == -1);
	}
	return y;
}

int main() {
	LL s;
	cin >> s;
	
	LL a = ce_sqrt(s), d = a, b = 1;
	assert(a * d >= s);
	
	if(a * d - s > a) { d--; }
	LL c = a * d - s;
	assert(c <= a);
	
	cout << "0 0 " << a << " " << b << " " << c << " " << d << endl;
	
	return 0;
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;

string red(string s) {
	stack<char> st;
	for(auto i: s)
		if(i=='(')
			st.push('(');
		else if(i==')' && (st.size()==0 || st.top()==')'))
			st.push(')');
		else
			st.pop();
	string ans="";
	while(st.size())
		ans+=st.top(),st.pop();
	reverse(all(ans));
	return ans;
}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;
	
	ll k,a,b;
	cin>>k>>a>>b;
	for(int i=a;i<=b;i++)
		if(i%k==0)
		{cout<<"OK";return 0;}
	cout<<"NG";

}


Measured memory_bytes: 3624
import java.util.Scanner;

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

        for(int i = 0; i < N; i++) {
            int P = sc.nextInt();
            mi = Math.min(mi, P);
            if(mi == P) {
                res++;
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 63624
#include<stdio.h>

int main()
{
  int i,tmp,max;
  char s[11];
  i=0;
  tmp=0;
  max=0;

  scanf("%s", &s);

  while (s[i]!='\0') {
  if(s[i]=='A' || s[i]=='T' || s[i]=='C' || s[i]=='G'){
    tmp+=1;
  }
  else {
    tmp=0;
  }
  i++;
  if(max<tmp){
    max=tmp;
  }
  }

  printf("%d", max);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#define REP(i,n) for(int i=2;i<=n;i++)
int main(void)
{
  long long int L1=2,L2=1,L3;
  int N,i;
  scanf("%d",&N);

  if(N==1){
    printf("1\n");
  } else {
  REP(i,N){
    L3=L1+L2;
    L1=L2;
    L2=L3;
  }

  printf("%lld\n",L3);
  }
  return 0;
}


Measured memory_bytes: 128
import itertools
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
ans = []
for i in range(2, N + 1):
    ans.append([1, i])

"""
全ての組み合わせは N_C_2
1を中心にスターグラフを作る
2,3,...,Nの中での組み合わせは N-1_C_2、これらの距離は2
2,3,...,Nの中で、(N-1_C_2 - K) 個の辺を張れば、
距離2の組み合わせがK個残る

N-1_C_2 - K < 0 となる時、構築不可
"""

if (N - 1) * (N - 2) // 2 - K < 0:
    print(-1)
    exit()
else:
    comb = list(itertools.combinations(range(2, N + 1), 2))
    for i in range((N - 1) * (N - 2) // 2 - K):
        u = comb[i][0]
        v = comb[i][1]
        ans.append([u, v])
    print(len(ans))
    for i in ans:
        print(*i)


Measured memory_bytes: 74928
// A
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

typedef long long ll;
ll a, b, k;

int main() {
	cin >> k;
	cin >> a >> b;

	if (b - a + 1 >= k) {
		cout << "OK" << endl;
		return 0;
	}
	else {
		for (ll i = a; i <= b; i++) {
			if (i % k == 0) {
				cout << "OK" << endl;
				return 0;
			}
		}
	}

	cout << "NG" << endl;

	return 0;
}

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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

const int MAX_N=3005;
const ll MOD=1000000007;
int n;
ll ans,dp[MAX_N][MAX_N],p[MAX_N][MAX_N];
string s;

int main(){
  cin >> n;
  cin >> s;
  dp[1][1]=1;
  p[1][1]=1;
  for(int i=2;i<=n;++i){
    for(int j=1;j<=i;++j){
        if(s[i-2]=='>'){
            dp[i][j]=p[i-1][i-1]-p[i-1][j-1];
            dp[i][j]%=MOD;
        }else{
           dp[i][j]=p[i-1][j-1];
           dp[i][j]%=MOD;
        }
        p[i][j]=p[i][j-1]+dp[i][j];
        p[i][j]%=MOD;

    }
  }
  if(p[n][n]<0){
    p[n][n]+=MOD;
  }
  cout << p[n][n];
  return 0;
}


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

using namespace std;
typedef long long int ll;

int H,W;
string S[55];


void g(int y, int x ){
  if( y<0 || H<=y||x<0||W<=x)return;
  if(S[y][x]=='#')return;
  S[y][x]++;
}
void f(int y, int x ){
  for(int i = -1;i<=1;i++){
    for(int j = -1;j<=1;j++){
      if(i==0 &&j==0)continue;
      g(y+i,x+j);
    }
  }
}
    


int main() {

  cin>>H>>W;
  for(int i = 0;i<H;i++){
    cin>>S[i];
    for(int j = 0;j<W;j++){
      if(S[i][j]=='.')S[i][j]='0';
    }
  }

  for(int i = 0;i<H;i++){
    for(int j = 0;j<W;j++){
      if(S[i][j]=='#') f(i,j);
    }
  }
  for(int i = 0;i<H;i++){
    cout<<S[i]<<endl;
  }
  

  return 0;
}


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

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintStream out = new PrintStream(System.out);
        String s1, s2, s3;
        char l1, l2, l3;

        s1 = sc.next();
        s2 = sc.next();
        s3 = sc.next();

        l1 = s1.toUpperCase().charAt(0);
        l2 = s2.toUpperCase().charAt(0);
        l3 = s3.toUpperCase().charAt(0);

        out.println(""+l1+l2+l3);
        
        sc.close();
    }
}

Measured memory_bytes: 22612
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,ans=0LL,mx=0LL;
  cin>>N;
  vector<pair<ll,ll>> LR;
  REP(i,N){
    ll l,r;
    cin>>l>>r;
    LR.PB(MP(l,r));
  }
  
  SORT(LR);
  
  ll Amn[N],Amx[N],Bmn[N],Bmx[N];
  Amn[0]=LR[0].first;
  Amx[0]=LR[0].second;
  for(int i=1; i<N; ++i){
    Amn[i]=max(Amn[i-1],LR[i].first);
    Amx[i]=min(Amx[i-1],LR[i].second);
  }
  Bmn[N-1]=LR[N-1].first;
  Bmx[N-1]=LR[N-1].second;
  for(int i=N-2; i>=0; --i){
    Bmn[i]=max(Bmn[i+1],LR[i].first);
    Bmx[i]=min(Bmx[i+1],LR[i].second);
  }
  
  for(int i=1; i<=N-2; ++i){
    chmax(ans,LR[i].second-LR[i].first+1+max(min(Amx[i-1],Bmx[i+1])-max(Amn[i-1],Bmn[i+1])+1,0LL));
  }
  chmax(ans,LR[0].second-LR[0].first+1+max(Bmx[1]-Bmn[1]+1,0LL));
  chmax(ans,LR[N-1].second-LR[N-1].first+1+max(Amx[N-2]-Amn[N-2]+1,0LL));
  
  for(int i=0; i<=N-2; ++i){
    chmax(ans,Amx[i]-Amn[i]+1+Bmx[i+1]-Bmn[i+1]+1);
  }
  
  co(ans);
  return 0;
}

Measured memory_bytes: 5488
//https://atcoder.jp/contests/dp/tasks/dp_l
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

LL dp[3233][3123];
bool vis[3123][3123];
LL a[3123];
LL solve(int l,int r,int p){
    if(r<l)return 0;
    if(vis[l][r])return dp[l][r];
    vis[l][r]=true;
    if(p==0){
        dp[l][r]=solve(l+1,r,1-p)+a[l];
        chmax(dp[l][r],solve(l,r-1,1-p)+a[r]);
    }
    else{
        dp[l][r]=solve(l+1,r,1-p)-a[l];
        chmin(dp[l][r],solve(l,r-1,1-p)-a[r]);
    }
    return dp[l][r];
}
int main(){
    int N;
    cin>>N;
    for(int i:range(N))cin>>a[i];
    cout<<solve(0,N-1,0)<<endl;
    return 0;
}

Measured memory_bytes: 84352
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

int N, H, A, B;
vector <int> weilds;
vector <int> throws;
int sum = 0;

int main()
{
	scanf("%d %d", &N, &H);


	for(int i = 0; i < N; i++)
	{
		scanf("%d" , &A);
		weilds.push_back(A);
		scanf("%d",  &B);
		throws.push_back(B);
	}

	sort(weilds.begin(), weilds.end());
	sort(throws.begin(), throws.end());

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

	int ret = 0;
	int cnt = 0;
	int cnt1 = 0;
	if(throws[N - 1] < weilds[N - 1])
	{
		while(ret < H)
		{
			ret += weilds[N - 1];
			cnt++;
		}
		cout << cnt;
	}
	else
	{
		for(int i = N - 1; i >= 0; i--)
		{
			if(throws[i] > weilds[N - 1] && sum < H)
			{
				sum += throws[i];
				cnt1++;
			}
			else
			{
				break;
			}
		}
		while(sum < H)
		{
			sum += weilds[N - 1];
			cnt1++;
		}
		cout << cnt1;
	}
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/

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

using namespace std;


int main() {
    string s;
    cin >> s;
    int n = s.size();
    vector<long long> a(n+1, 0);
    for(int i = 0; i < n; i++) {
        if(s[i] == '<') {
            a[i+1] = max(a[i]+1, a[i+1]);
        }
    }
    for(int i = n-1; i >= 0; i--) {
        if(s[i] == '>') {
            a[i] = max(a[i], a[i+1]+1);
        }
    }
    long long ans = 0;
    for(auto au : a) {
        ans += au;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 7528
#include <iostream>
#include <string>
using namespace std;
int main(){
    int a,b,i;
    cin >> a >> b;
    string s[a];
    for (i=0; i<a; i++){
        cin >> s[i];
    }
    for (i=0; i<b+2; i++){
        cout << "#";
    }
    cout <<endl;
    for (i=0; i<a; i++){
        cout << "#" << s[i] << "#" << endl;
    }
    for (i=0; i<b+2; i++){
        cout << "#";
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
bool is_prime(int n){
    for (int i=2; i*i<=n; i++){
        if (n%i==0) return false;
    }
    return n!=1; //1の場合はfalse
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin>>N;
    vector<int> v, m;
    
    rer(i,N+1,1){
        if(is_prime(i)){
            v.push_back(i);
            int a=0;
            int l=N;
            while(i<=l){
                a+=l/i;
                l/=i;
            }
            m.push_back(a);
        }
    }
    int k=v.size();
    int ans=0;
    ans+=m.end()-lower_bound(m.begin(),m.end(),74);
    ans+=(m.end()-lower_bound(m.begin(),m.end(),24))*(m.end()-lower_bound(m.begin(),m.end(),2)-1);
    ans+=(m.end()-lower_bound(m.begin(),m.end(),14))*(m.end()-lower_bound(m.begin(),m.end(),4)-1);
    ans+=(m.end()-lower_bound(m.begin(),m.end(),4))*(m.end()-lower_bound(m.begin(),m.end(),4)-1)/2*(m.end()-lower_bound(m.begin(),m.end(),2)-2);
    cout << ans<<"\n";
}



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

int main(){
    long N, K;
    cin >> N >> K;
    map<long, long> List;
    for (int i=0; i<N; i++){
        long a, b;
        cin >> a >> b;
        if (List.find(a) == List.end()){
            List.emplace(a,b);
        }
        else{
            List[a] += b;
        } 
    }
    long order = 0, ans = -1;
    for (auto x : List){
        order += x.second;
        if (order >= K){
            ans = x.first;
            break;
        } 
    }
    cout << ans << endl;;
    return 0;
}

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

int main(){
    string S;
    cin >> S;
    int count = 0;
    bool A = false;
    if(S.size() %2 == 1){
        A = true;
    }
    else{
        for (int i = 0; i < S.size()-1; i= i+2)
        {
            if(S[i] != 'h'|| S[i+1] !='i'){
                A = true;
            }
        }
    }
    if(A){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}


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


num_W = [0]*N # ある人の左にいるWの数
num_E = [0]*N # ある人の右にいるEの数

for i in range(1,N):
    if S[i-1] == "W":
        num_W[i] = num_W[i-1] + 1
    else:
        num_W[i] = num_W[i-1]

for i in reversed(range(0,N-1)):
    if S[i+1] == "E":
        num_E[i] = num_E[i+1] + 1
    else:
        num_E[i] = num_E[i+1]

ans = N
for i in range(N):
    ans = min(ans, num_E[i] + num_W[i])

print(ans)

Measured memory_bytes: 17624
s = input()[::-1]
l = ["maerd", "remaerd", "esare", "resare"]
b = 0
flag = 1
while b!=len(s):
    if s[b:b+5] in ["maerd", "esare"]: b += 5
    elif s[b:b+6] == "resare": b += 6
    elif s[b:b+7] == "remaerd": b += 7
    else: break
else: flag = 0
print("YNEOS"[flag::2])

Measured memory_bytes: 3188
#include <stdio.h>

int main (int argc, char* argv[]) {
  char s[4];
  scanf("%s", s);

  for (int i = 0; i < 3; i++) {
    if (s[i] == s[i+1]) {
      printf("Bad\n");
      return 0;
    }
  }

  printf("Good\n");


  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
#define fi first
#define se second
const int N = 1e5+5;
int g[55][55];
int degree[55];
int main()
{
	int n,m,flag=0,v,u,ans=0;
	memset(degree,0,sizeof(degree));
	memset(g,0,sizeof(g));
//	g[1][1]=1;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d %d",&u,&v);
		g[u][v]=1;
		g[v][u]=1;
		degree[u]++;
		degree[v]++;
	}
	/*if(m==n-1)
	{
		cout<<m<<endl;
		return 0;
	}
*/	while(1)
	{	
		flag=1;
		for(int i=1;i<=n;i++)
		{
			if(degree[i]==1)
			{
			degree[i]--;
				for(int j=1;j<=n;j++)
				{
					if(g[i][j]==1)
					{
						flag=0;
						ans++;
						degree[j]--;
						g[i][j]=0;
						g[j][i]=0;
						break;
					}
				}
			}
		}
		if(flag==1) break;
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
long long dp[51][2];
int a[51];
int main()
{
	int n,p;
	scanf("%d%d",&n,&p);
	dp[0][0]=1;
	for (int i=1;i<=n;++i)
		scanf("%d",a+i);
	for (int i=1;i<=n;++i)
		for (int j=0;j<2;++j)
			dp[i][j]=dp[i-1][j]+dp[i-1][j^(a[i]&1)];
	printf("%lld",dp[n][p]);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>> 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("explicit.in","r",stdin);freopen("explicit.out","w",stdout)
#define mp make_pair
#define pll pair <lli,lli>
#define vll vector <lli>
#define pq2 priority_queue<pair<lli,lli>>
#define f first
#define s second
#define pb push_back
#define pf push_front
#define minii LLONG_MAX
#define all(x) x.begin(), x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define ld long double 
const long double pi = 3.1415926535898;
#define dec greater<lli>()
const lli mod=1000000007;
//const lli mod=100000000;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0) return 1;
    lli c=modpower(a,b/2)%mod;
    if (b%2) return (((a*c)%mod)*c)%mod;
    else return (c*c)%mod;
}
lli power (lli a,lli b)
{
    if(b==0) return 1;
    lli c=power(a,b/2);
    if (b%2) return (a*c*c);
    else return c*c;
}
bool prime (lli k)
{
    if (k==1||k==0) return 0;
    bool flag=1;
    lli a=sqrt(k);
    for (int i=2;i<=a;i++)
    {
        if (k%i==0)
        {flag=0;break;}
    }
    return flag;
}
lli sieve (int n)
{
    bool qrr[n+1];
    for (int i=0;i<=n;i++)
    qrr[i]=1;qrr[0]=0;qrr[1]=0;
    for (int i=2;i<=n;i++)
    {
        if (qrr[i]==1)
        {
            for (int j=i;j<=n;j+=i)
            {qrr[j]=0;}
        }
    }
    return 0;
}
int main()
{
    fio;
    lli t;
    t=1;
    while (t--)
    {
        lli a,b,c,k;
        cin>>a>>b>>c>>k;
        bool f=0;
        while (b<=a)
        {
            if (k==0)
            break;
            b*=2;
            k--;
            if (k==0)
            break;
        }
        while (c<=b)
        {
            if (k==0)
            break;
            c*=2;
            k--;
            if (k==0)
            break;
        }
        if (c>b&&b>a)
        {
            cout<<"Yes";
        }
        else
        cout<<"No";
    }
    return 0;
}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;


const double EPS = 1e-10;
const double PI = acosl(-1.0);

struct Point{
    double x, y;
    Point(double x=0.0, double y=0.0) : x(x), y(y) {}
};
inline Point operator + (Point p, Point q){return Point(p.x + q.x, p.y + q.y);}
inline Point operator - (Point p, Point q){return Point(p.x - q.x, p.y - q.y);}
inline Point operator / (Point p, double a){return Point(p.x / a, p.y / a);}
inline Point rot(Point p, double ang){return Point(p.x * cos(ang) - p.y * sin(ang), p.x * sin(ang) + p.y * cos(ang));}
inline Point rot90(Point p){return Point(-p.y, p.x);}
inline double cross(Point p, Point q) {return p.x * q.y - p.y * q.x;}
inline double dot(Point p, Point q){return p.x * q.x + p.y * q.y;}
inline double abs(Point p){return sqrt(dot(p, p));}

struct Line{
    double a, b, c;
    Line(Point p=Point(), Point q=Point()){
        a = p.y - q.y;
        b = -(p.x - q.x);
        c = -(a * p.x + b * p.y);
    }
};

int ccw(Point a, Point b, Point c){
    if(cross(b - a, c - a) > EPS)return 1;
    if(cross(b - a, c - a) < -EPS)return -1;
    return 0;
}

Point intersection(Line l, Line m){return Point((l.b * m.c - m.b * l.c) / (l.a * m.b - m.a * l.b), (m.a * l.c - l.a * m.c) / (l.a * m.b - m.a * l.b));}

Point circumcenter(Point a, Point b, Point c){
    Line ab((a + b) / 2, (a + b) / 2 + rot90(a - b));
    Line bc((b + c) / 2, (b + c) / 2 + rot90(b - c));
    return intersection(ab, bc);
}


int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    Point p[n]; zep(i, 0, n){cin >> p[i].x >> p[i].y;}  

    vector<Point> v;
    zep(i, 0, n){
        zep(j, i+1, n){
            v.push_back((p[i]+p[j])/2);

            zep(k, j+1, n){
                if(ccw(p[i], p[j], p[k]) != 0){
                    v.push_back(circumcenter(p[i], p[j], p[k])); 
                }
            }
        }
    }
    
    double ans = INF;
    zep(i, 0, v.size()){
        double buf = 0;
        zep(j, 0, n){buf = max(buf, abs(p[j]-v[i]));}
        ans = min(ans, buf);
    }
    cout << fixed << setprecision(20) << ans << endl;
    return 0;
}

Measured memory_bytes: 892
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> S = new ArrayList<>();
        List<Integer> H = new ArrayList<>();
        List<Integer> C = new ArrayList<>();
        List<Integer> D = new ArrayList<>();
        
        for (int i = 0; i < n; i++) {
            String symbol = sc.next();
            int num = sc.nextInt();

            if ("S".equals(symbol)) {
                S.add(num);
            } else if ("H".equals(symbol)) {
                H.add(num);
            } else if ("C".equals(symbol)) {
                C.add(num);
            } else {
                D.add(num);
            }
        }
       
        for (int i = 1; i < 14; i++) {
            if (!S.contains(i)) {
                System.out.println("S" + " " + i);
            }
        }
        for (int i = 1; i < 14; i++) {
            if (!H.contains(i)) {
                System.out.println("H" + " " + i);
            }
        }
        for (int i = 1; i < 14; i++) {
            if (!C.contains(i)) {
                System.out.println("C" + " " + i);
            }
        }
        for (int i = 1; i < 14; i++) {
            if (!D.contains(i)) {
                System.out.println("D" + " " + i);
            }
        }
    }
}

Measured memory_bytes: 26312
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
const int maxn=2e5+9;
int main(){
    ll n;
    ll arr[55];
    ios::sync_with_stdio(0);
    while(cin>>n){
        for(int i=0;i<n;i++)cin>>arr[i];
        ll ans=0;
        ll t=0;
        ll bu[55];
        while(1){
            memset(bu,0,sizeof(bu));
            t=0;
            for(int i=0;i<n;i++){
                if(arr[i]>n-1){
                    bu[i]=(arr[i]-n+1)/n;
                    if((arr[i]-n+1)%n){
                        bu[i]++;
                    }
                    t+=bu[i];
                }
            }
            if(!t)break;
            ans+=t;
            for(int i=0;i<n;i++){
                arr[i]-=bu[i]*n;
                arr[i]+=t-bu[i];
            }
            //for(int i=0;i<n;i++)cout<<arr[i]<<' ';cout<<endl;
            //for(int i=0;i<n;i++)cout<<bu[i]<<' ';cout<<endl;
        }
        cout<<ans<<endl;
    }

}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){

  int a,b, output, input, temp=1;

  while(scanf("%d %d", &a, &b)!= EOF){

  temp = 1;
  input = 0;
  output = 0;

  input = a + b;

  for(output = 0; input != 0; output++){
    input /= 10;

  }

  if(a == 0 && b == 0)
    output = 1;
  

  printf("%d\n", output);
  }

  return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int h,n;
    cin>>h>>n;
    vi a(n);
    vi b(n);
    FOR(i,0,n){
        cin>>a[i]>>b[i];
    }
    vl dp(20201,mod);
    dp[0]=0;
    LL ans=1LL*mod*mod;
    FOR(i,0,n){
        vl dp2(dp);
        FOR(j,0,h){
            dp2[j+a[i]]=min(dp2[j+a[i]],dp2[j]+b[i]);
            if(j+a[i]>=h){
                ans=min(ans,dp2[j+a[i]]);
            }
        }
        dp=dp2;
    }
    cout<<ans<<endl;


}


Measured memory_bytes: 608
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pil;
typedef complex<double> xy_t;

const lint mod = 1e9 + 7;

int main(){
    int n;
    scanf("%d", &n);
    lint a[n];
    rep(i, n) scanf("%lld", &a[i]);
    if(a[0] > 0){
        printf("-1\n");
        return 0;
    }
    rep(i, n-1){
        if(a[i+1]-a[i] > 1){
            printf("-1\n");
            return 0;
        }
    }

    lint ans = 0;
    int l = 0;
    while(l < n){
        int r = l+1;
        while(r < n && a[r]-a[r-1] == 1) ++r;
        ans += a[r-1];
        l = r;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define cs const 
#define int long long
#define low(i) (i&(-i))
#define mid ((l+r)>>1)
#define ls (now<<1)
#define rs (now<<1|1)
#define par pair<int,int>
#define mp make_pair
#define pb push_back
#define fr first 
#define se second
#define cn(x) memset(x, 0, sizeof(x))
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define drep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])
#define dbg cout << "---------------------------------\n"
cs int base = 233;
cs int ff = 1e6+1;
cs int mod = 1e9+7;
cs int inf = 1e17+1;
inline int read() { int x; scanf("%lld", &x); return x; }
int fir[ff], nex[ff], to[ff], va[ff], tot;
void add(int x, int y, int z)
{
    nex[++tot] = fir[x];
    fir[x] = tot;
    to[tot] = y;
    va[tot] = z;
}
int ksm(int a, int b) { return ( b % 2 == 1 ? a : 1 ) * ( b? ksm( a * a % mod, b>>1 ) : 1 ) % mod; }
int getinv(int x) { return ksm(x, mod-2); }
int n, a[ff], k, s;
int calc(int pos, int s = 0) { rep(i, 1, n) s += (a[i]-pos) * (a[i]-pos); return s; }
void init()
{
	cin >> n >> k;
	while( n ) n /= k, s++;
	cout << s;
}
signed main()
{
    int T = 1;
    while(T--) 
        init();
} 

Measured memory_bytes: 2304
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

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

	Int N, K;
	cin >> N >> K;


	vector<Int> a(N);
	vector<Int> f(N);

	for (Int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	for (Int i = 0; i < N; i++) {
		cin >> f[i];
	}
	sort(f.begin(), f.end(), greater<Int>());

	Int ok = 1e12;
	Int ng = -1;
	while (abs(ok - ng) > 1) {
		Int mid = (ok + ng) / 2;
		Int cnt = 0;
		for (Int i = 0; i < N; i++) {
			if (a[i] * f[i] < mid)continue;
			else cnt += a[i] - mid / f[i];
		}
		(cnt <= K ? ok : ng) = mid;
    }
	cout << ok << "\n";
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 10000000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define EPS 0.00000001
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
void solve()
{
    ll n,k;
    cin>>n>>k;
    ll rem=n%k;
    if(rem<=(k/2))
    {
        cout<<n<<'\n';
        return;
    }
    else
    {
        n-=(rem-(k/2));
        cout<<n<<'\n';
        return;
    }
}
bool comdoub(double a,double b)
{
    if(a-EPS<b&&a+EPS>b)
     {
        return true;
     }
    else
     {
        return false;
     }
}

int main()
{

 long long int h;

 cin>>h;

 long long int i,j,k;

 long long int flag=0;
 j=0;
 while(power(2,j)<=h)
{


     j++;
 }

    cout<<power(2,j)-1;

    return 0;
}


Measured memory_bytes: 11904
#include<stdio.h>
long long int modpow(long long int a, long long int n, long long int b)
{
	long long int res = 1;
	while (n > 0)
	{
		if (n % 2 > 0)
			res = res * a % b;
		a = a * a % b;
		n /= 2;
	}
	return res;
}
int main()
{
	long long int n;
	scanf("%lld", &n);
	long long int i;
	long long  int x[200005];
	char s[200005];
	scanf("%s", s);
	for (i = 0; i < n; i++)
		x[i] = s[i] - '0';
	long long int c1 = 0;
	for (i = 0; i < n; i++)
		if (x[i] == 1)
			c1++;
	c1--;
	long long int f1 = 0;
	if (c1 > 0)
		for (i = 0; i < n; i++)
			f1 = (2 * f1 + x[i]) % c1;
	long long int f0 = 0;
	long long int c0 = c1 + 2;
	for (i = 0; i < n; i++)
		f0 = (2 * f0 + x[i]) % c0;
	long long int a, ans, c, d;
	for (i = 0; i < n; i++)
	{
		if (x[i] == 0)
		{
			a = (f0 + modpow(2, n - 1 - i, c0)) % c0;
			ans = 1;
			while (a > 0)
			{
				c = 0;
				d = a;
				while (d > 0)
				{
					c += d % 2;
					d /= 2;
				}
				ans++;
				a %= c;
			}
			printf("%lld\n", ans);
		}
		else
		{
			if (c1 == 0)
				printf("0\n");
			else
			{
				a = (f1 - modpow(2, n - 1 - i, c1) + c1) % c1;
				ans = 1;
				while (a > 0)
				{
					c = 0;
					d = a;
					while (d > 0)
					{
						c += d % 2;
						d /= 2;
					}
					ans++;
					a %= c;
				}
				printf("%lld\n", ans);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3464
n = int(input())
a = list(map(int, input().split()))

mode="?"
cnt=0
last=a[0]
for num in a:
    if mode=="a":
        if last > num:
            cnt+=1
            mode="?"
    elif mode=="d":
        if last < num:
            cnt+=1
            mode="?"
    else:
        if last > num:
            mode="d"
        if last < num:
            mode="a"
    last=num
print(cnt+1)

Measured memory_bytes: 62704
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<utility>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

#define MOD 1000000007;

int main(){
	char a, b, c, d;
	cin >> a >> b >> c >> d;
	int n[]={b-'0', c-'0', d-'0'};
	for(int bit=0; bit<(1<<3); bit++){
		int num=a-'0';
		for(int i=0; i<3; i++){
			if(bit & 1<<i)
				num+=n[i];
			else
				num-=n[i];
		}
		if(num==7){
			cout << a;
			if(bit&1)
				cout << '+';
			else
				cout << '-';
			cout << b;
			if(bit&1<<1)
				cout << '+';
			else
				cout << '-';
			cout << c;
			if(bit&1<<2)
				cout << '+';
			else
				cout << '-';
			cout << d << "=7\n";
			return 0;
		}
	}
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	// Code for A - Buttons
	var A, B int
	fmt.Scanf("%d %d", &A, &B)

	var answer int
	for i := 0; i < 2; i++ {
		if A >= B {
			answer += A
			A--
		} else {
			answer += B
			B--
		}
	}
	fmt.Println(answer)
}


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

#define ln '\n'
#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 FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VVI abc(n, VI(3));
    REP(i, n)REP(j, 3) cin >> abc[i][j];
    VVI dp(n, VI(3));
    REP(j, 3) dp[0][j] = abc[0][j];

    FOR(i, 1, n - 1) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + abc[i][0];
        dp[i][1] = max(dp[i - 1][2], dp[i - 1][0]) + abc[i][1];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + abc[i][2];
    }
    cout << *max_element(ALL(dp[n - 1])) << ln;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

ll pow(ll a, ll b, ll mod) {
  ll ret = 1;
  ll tmp = a;
  while (b) {
    if (b % 2) {
      ret = ret * tmp % mod;
    }
    tmp = tmp * tmp % mod;
    b /= 2;
  }
  return ret;
}

ll inverse(ll a, ll mod) {
  return pow(a, mod - 2, mod);
}

const ll MOD = 1000000007;

int main() {
  ll N, A, B, C, D; cin >> N >> A >> B >> C >> D;
  vvi dp(N + 1, vi(N + 1));

  vvi P(N + 1, vi(N + 1));
  for (ll i = 0; i <= N; i++) {
    ll k = 1;
    for (ll j = 0; j <= N; j++) {
      P[i][j] = k;
      k = k * (i - j) % MOD;
    }
  }

  for (ll i = 0; i <= N; i++) dp[A - 1][0] = 1;
  for (ll i = A; i <= B; i++) {
    for (ll j = 0; j <= N; j++) {
      for (ll k = 0; j - k * i >= 0; k++) {
        if (k == 0 || (C <= k && k <= D)) {
          dp[i][j] += dp[i - 1][j - k * i] * P[N - j + k * i][k * i] % MOD * inverse(pow(P[i][i], k, MOD), MOD) % MOD * inverse(P[k][k], MOD) % MOD;
          dp[i][j] %= MOD;
        }
      }
    }
  }
  cout << dp[B][N] << endl;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	cin >> N;
	vector<int>A(N), B(N), C(N - 1);
	int ans = 0;
	for (int i = 0; i < N; i++){
		cin >> A[i];
		A[i]--;
	}
	for (int i = 0; i < N; i++){
		cin >> B[i];
	}
	for (int i = 0; i < N - 1; i++){
		cin >> C[i];
	}

	for (int i = 0; i < N; i++){
		ans += B[A[i]];
		if (i > 0 && A[i] == A[i - 1] + 1) {
			ans += C[A[i - 1]];
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010

void swap(LL* a,LL* b){LL tmp=*a;*a=*b;*b=tmp;}
LL lpow(LL a,LL n){LL ans=pow(a,n)*10;if(ans%10<5)return ans/10;return ans/10+1;}
LL dup(LL a,LL d){if(a%d==0)return a/d;else return a/d+1;}
LL GCD(LL a,LL b){LL c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int scmp(const void* a,const void* b){return strcmp(*(char**)a,*(char**)b);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(&m,&d);x-=k*y;swap(&x,&y);}return mod(a*mod(x,MOD),MOD);}
LL FAC(LL a){LL i,ans=1;FOR(i,1,a+1){ans*=i;if(MOD>0&&ans>MOD)ans%=MOD;}return ans;}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}

LL dx[4]={1,0,-1,0},dy[4]={0,1,0,-1},H,W;
char S[20][21];
LL co[500][500]={0};
void bfs(){
  LL I,J,i,j,k,s1,s2,nx,ny;
  FOR(I,0,H)FOR(J,0,W)if(S[I][J]=='.'){
    LL n=0,m=0,A[500]={0},flag[500]={0};
    i=I,j=J,s1=i*W+j;
    flag[s1]=1;
    while(1){
      FOR(k,0,4){
        nx=i+dx[k],ny=j+dy[k],s2=nx*W+ny;
        if(nx>=0&&nx<H&&ny>=0&&ny<W)if(S[nx][ny]=='.')if(flag[s2]==0){
          flag[s2]=1,A[n++]=s2,co[s1][s2]=co[s1][i*W+j]+1;
        }
      }
      if(m==n)break;
      i=A[m]/W,j=A[m++]%W;
    }
  }
}

int main(){
  LL i,j,ans=0;
  scanf("%lld%lld",&H,&W);
  FOR(i,0,H)scanf("%s",S[i]);
  bfs();
  FOR(i,0,H*W)FOR(j,i,H*W)ans=MAX(ans,co[i][j]);

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


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        Console.WriteLine(Solve());
        //Solve();
        return;
    }

    public static string Solve()
    {
        int[] input = ReadInts();
        int A = input[0];
        int B = input[1];
        int sum = A + B;
        if (sum % 2 == 0)
        {
            return (sum / 2).ToString();
        }
            return "IMPOSSIBLE";
    }

    public static long Lcm(long a, long b)
    {
        return a * b / Gcd(a, b);
    }

    public static long Gcd(long a, long b)
    {
        if (a < b)
            // 引数を入替えて自分を呼び出す
            return Gcd(b, a);
        while (b != 0)
        {
            var remainder = a % b;
            a = b;
            b = remainder;
        }
        return a;
    }

    private static string Read() { return Console.ReadLine(); }
    private static int ReadInt() { return int.Parse(Read()); }
    private static long ReadLong() { return long.Parse(Read()); }
    private static double ReadDouble() { return double.Parse(Read()); }
    private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
    private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
    private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
}


Measured memory_bytes: 11092
#include<stdio.h>
#include<string.h>
int main()
{
    char s[4];
    char s1[]="SAT";
    char s2[]="SUN";
    char s3[]="MON";
    char s4[]="TUE";
    char s5[]="WED";
    char s6[]="THU";
    char s7[]="FRI";
    int a,b,c,d,e,f,g;
    gets(s);
    a=strcmp(s,s1);
    if(a==0){
        printf("1\n");
    }
    b=strcmp(s,s2);
    if(b==0){
        printf("7\n");
    }
    c=strcmp(s,s3);
    if(c==0){
        printf("6\n");
    }
    d=strcmp(s,s4);
    if(d==0){
        printf("5\n");
    }
    e=strcmp(s,s5);
    if(e==0){
        printf("4\n");
    }
    f=strcmp(s,s6);
    if(f==0){
        printf("3\n");
    }
    g=strcmp(s,s7);
    if(g==0){
        printf("2\n");
    }
    return 0;

}


Measured memory_bytes: 128
x,n=map(int,input().split())
try:
  p=list(map(int,input().split()))
except:
  print(x)
  exit()
ans=float('inf')
for i in range(300):
  if i not in p:
    ans=min(ans,abs(x-i))
    
 
if x-ans not in p :
  print(x-ans)

else:
  print(x+ans)

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

int main() {
  string S;
  cin>>S;
  if(S=="a"||S=="i"||S=="u"||S=="e"||S=="o"){
    cout<<"vowel"<<endl;
  }
  else {cout<<"consonant"<<endl;
}
  // ここにプログラムを追記
}


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

const int N = 200020;

int main() {
  int n,C;
  cin >> n >> C;

  vector<int> ans(N, 0);
  vector<int> s(n), t(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> t[i] >> c[i];
  }
  for (int i = 1; i <= C; i++) {
    vector<int> imos(N, 0);
    for (int j = 0; j < n; j++) {
      if(i == c[j]) imos[s[j] * 2 - 1]++, imos[t[j] * 2]--;
    }
    for (int j = 1; j < N; j++) imos[j] += imos[j - 1];
    for (int j = 0; j < N; j++) {
      if(imos[j] > 0) ans[j]++;
    }
  }

  int res = 1;
  for (auto it : ans) res = max(res, it);
  cout << res << '\n';
}

Measured memory_bytes: 2944
n=int(input())
a=[int(i) for i in input().split()]

num = [0]*n

for i in a:
    num[i-1] += 1


tmp=0
for i in num:
    if i>=2:
        tmp+=(i*(i-1))//2

for i in a:
    if num[i-1]>=2:
        print(tmp-(num[i-1]-1))
    else:
        print(tmp)

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

using namespace std;

int main(){
	
	long long int n,sum=0;
	
	cin>>n;			

	for(int i=1; i<=n; i++){
		
		if(i%3 != 0 && i%5 != 0)
		{
			sum += i;
		}
	}
	
	cout<<sum<<endl;
	

	return 0;
}



Measured memory_bytes: 3632
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;
typedef pair<int, int> P;

string t;
int ans = 0;
int n, k, r, s, p;

void solve(char c){
    switch (c)
    {
    case 'r': ans += p; break;
    case 's': ans += r; break;
    case 'p': ans += s; break;
    }

}

int main(){
    cin >> n >> k >> r >> s >> p;
    cin >> t;
    vector<bool> win(n+1, false);
    for(int i = 0; i < n; i++){
        if(i >= k)
            if(t[i-k] == t[i] && win[i-k]) continue;
        solve(t[i]);
        win[i] = true;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
eval"N,*T=#{`tr -! ,`}0"
z=1
N.times{|i|a,b=T[N+i,2]
z=z*[[[a,t=T[i]].min,0,-1[a-t]][s=T[i-1]<=>t],0,(s%3-1)[t-a]][b<=>a]%(10**9+7)}
p z

Measured memory_bytes: 41908
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  ll n, k; cin >> n >> k;
  Vll a(n); 
  rep(i, n) cin >> a[i];
  const int m = 42;

  VVll cnt(m, Vll(2));
  rep(i, m) rep(j, n) {
    if (a[j] % 2 == 0) ++cnt[i][0];
    if (a[j] % 2 == 1) ++cnt[i][1];
    a[j] /= 2;
  }

  Vll score(m+1);
  rep(i, m) {
    score[i+1] += score[i] + (max(cnt[i][0], cnt[i][1])) * (1ll<<i);
  }

  ll d = 1ll<<m;
  ll scr_now = 0;
  ll ans = 0;
  for (int i = m-1; i >= 0; --i) {
    int x = (k / (1ll<<i)) % 2;
    if (x == 1) {
      chmax(ans, scr_now + cnt[i][1] * (1ll<<i) + score[i]);
    }
    scr_now += cnt[i][1-x] * (1ll<<i);
  }
  chmax(ans, scr_now);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string.h>
using namespace std;

int main(){

	int n, m,l,x, **a,**b;
        long **c;

	cin >> n >> m>>l; 
	

	//????????????a?????????
	a = new int*[n];
	for (int i = 0; i < n; i++){
		a[i] = new int[m];
	}

	//????????????b?????????
	b = new int*[m];
	for (int i = 0; i < m; i++){
		b[i] = new int[l];
	}

	//????????????c?????????
	c = new long*[n];
	for (int i = 0; i < n; i++){
		c[i] = new long[l];
	}

//?????????a
	for (int i = 0; i < n; i++){
		for (int j = 0; j < m; j++){
			cin >> x;
			a[i][j] = x;
		}
	}
//?????????b
	for (int i = 0; i < m; i++){
		for (int j = 0; j < l; j++){
			cin >> x;
			b[i][j] = x;
		}
	}
	//?????????c
	for (int i = 0; i < n; i++){
		for (int j = 0; j < l; j++){
			c[i][j] = 0;
		}
	}

	//???c
	for (int i = 0; i < n; i++){
		for (int j = 0; j < l; j++){
			for (int k = 0; k < m; k++){
				c[i][j] += a[i][k] * b[k][j];
			}

		}
	}


	//?????????
	for (int i = 0; i < n; i++){
		for (int j = 0; j < l; j++){
			cout << c[i][j];
			if (j != l - 1){
				cout << " ";
			}
		}cout << endl;
	}


	//delete
	for (int i = 0; i < n; i++){
		delete[] a[i];
	}
	delete[] a;

	//delete
	for (int i = 0; i < m; i++){
		delete[] b[i];
	}
	delete[] b;

	//delete
	for (int i = 0; i < n; i++){
		delete[] c[i];
	}
	delete[] c;

	return 0;
}

Measured memory_bytes: 1348
package main

import (
	"fmt"
)

func abs(n int64) int64 {
	if n >= 0 {
		return n
	} else {
		return -n
	}
}

func main() {
	var x, k, d int64
	fmt.Scan(&x)
	fmt.Scan(&k)
	fmt.Scan(&d)
	x = abs(x)
	ans := x

	if x > abs(k*d) {
		ans = x - abs(k*d)
	} else {
		if (k-x/d)%2 == 0 {
			ans = x % d
		} else {
			temp := x % d
			if abs(temp+d) < abs(temp-d) {
				ans = abs(temp + d)
			} else {
				ans = abs(temp - d)
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1768
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  int b = 0;
  vector<int> vec(210);
  cin >> a;
  for (int i = 0; i < a; i++) cin >> vec.at(i);
  while (true) {
    bool oddflag = false;
    for (int i = 0; i < a; i++) {
      if (vec.at(i) % 2 != 0) oddflag = true;
    }
    
    if (oddflag) break;
    for (int i = 0; i < a; i++) {
      vec.at(i) /= 2;
    }
    b++;
  }
  cout << b << endl;
}

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

int main()
{
  int N;
  cin >> N;
  
  for(int i = 1; i < 10; i++){
    if((N%i == 0)&&(N/i<=9&&N/i>=1)){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}



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

using namespace std;

typedef long long ll;
#define FOR(i,a,n) for(int (i) = (a);i < (n);i++)

int main()
{
    int n = 0, i = 0, output = 0;
    cin >> n;
    vector<int> skewer(2 * n, 0);

    for(i = 0;i < 2*n; i++)
    {
        int temp = 0;
        cin >> temp;
        skewer.push_back(temp);
    }
    sort(skewer.begin(), skewer.end());
    i = 0;
    while(i < skewer.size())
    {
        output = output + skewer[i];
        i = i + 2;
    }
    cout << output;
	return 0;
}


Measured memory_bytes: 3600
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,x,a[110],c,ans,ans1,ans2;
int main()
{
	cin>>n>>m>>x;
	for(int i=1;i<=m;i++)
	{
		cin>>c;
		a[c]=1;
	}
	for(int i=0;i<=x;i++)
	if(a[i])ans1++;
	for(int i=x;i<=n;i++)
	if(a[i])ans2++;
	ans=min(ans1,ans2);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256