akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long


int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    vector<int> s;
    vector<int> t;
    s = A;
    t = B;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    for (int i = 0; i < N; i++) {
        if (s[i] > t[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    
    for (int i = 1; i < N; i++) {
        if (s[i] <= t[i-1]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    vector<pair<int, int>> p;
    for (int i = 0; i < N; i++) {
        p.push_back({A[i], B[i]});
    }
    sort(p.begin(), p.end());
    int x = p[0].first;
    int y = p[0].second;
    for (int i = 0; i < N-1; i++) {
        auto it = upper_bound(s.begin(), s.end(), y);
        auto nxt = p[distance(s.begin(), it) - 1];
        x = nxt.first;
        y = nxt.second;
        if (x == p[0].first) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ul;
typedef signed long long ll;
ul over = 1000000007;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed;
  int n;
  cin >> n;
  int a[n][2];
  for (int i=0; i<n; ++i) cin >> a[i][0];
  for (int i=0; i<n; ++i) cin >> a[i][1];
  int dp[n][2];
  dp[0][0] = a[0][0];
  dp[0][1] = a[0][0] + a[0][1];
  for (int i=1; i<n; ++i) {
    dp[i][0] = dp[i-1][0] + a[i][0];
    dp[i][1] = max(dp[i][0], dp[i-1][1]) + a[i][1];
  }
  cout << dp[n-1][1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,u,k,v,c,e[100][100],a[100],d[100],g[100],i,j,min,minv;

  scanf("%d", &n);
  for (i=0;i<100;i++) {
    d[i]=1000000-1;
    a[i]=-1;
    for (j=0;j<100;j++) {
      e[i][j] = 1000000-1;
    }
  }

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      e[u][v]=c;
    }
  }

  d[0] = 0;

  for (j=0;j<n;j++){
    min = 1000000;
    for (i=0;i<n;i++) {
      if (min>d[i] && a[i]!=1){
        min=d[i];
        minv=i;
      }
    }

    a[minv] = 1;
    for (i=0;i<n;i++) {
      if (d[minv]+e[minv][i]<d[i] && a[i]!=1){
        d[i]=d[minv] +e[minv][i];
        g[minv]=i;
      }
    }
  }

  for (i=0;i<n;i++) {
    printf("%d %d\n", i, d[i]);
  }

  return 0;
}



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

#define INF 1001001001

int main()
{
  int H, W, input, ans = 0;
  int c[10][10];
  int serch_min(vector<int> &vs, vector<bool> &C);
  map<int, int> m;
  cin >> H >> W;
  rep(i, 10){
    rep(j, 10){
      cin >> c[i][j];
    }
  }
  rep(i, H*W){
    cin >> input;
    m[input]++;
  }
  
  vector<int> vs(10, INF);
  vector<bool> Ch(10, false);
  Ch.at(1) = true;
  rep(i, 10)vs.at(i) = c[i][1];
  rep(i, 9){
    int mini = serch_min(vs, Ch);
    Ch.at(mini) = true;
    //cerr << "vs.at(mini)=" << vs.at(mini) << endl;
    rep(j, 10){
      vs.at(j) = min(vs.at(j), vs.at(mini) + c[j][mini]);
    }
  }
  rep(i, 10){
    ans += vs.at(i)*m[i];
  }
  cout << ans << endl;
}

int serch_min(vector<int> &vs, vector<bool> &C){
  int min = INF, index = -1;
  rep(i, 10){
    if(C.at(i) == false && min > vs.at(i)){
      min = vs.at(i);
      index = i;
    }
  }
  //cerr << "index:" << index << endl;
  return index;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	string n; cin >> n;
	if (n.find("9") != string::npos)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define all(v) v.begin(), v.end()
  #define mod INT_MAX 
  const int MOD=1e9+7;

  int32_t main()
  {
    /*#ifndef ONLINE_JUDGE
       freopen("in.txt","r",stdin);
       freopen("out.txt","w",stdout);
    #endif*/
   IOS
   int a,b,c,k,sum=0;
   cin>>a>>b>>c>>k;
    if(a<=k)
     { sum+=a;
       k-=a;
     }
     else
     {
      sum+=k;
      cout<<sum;
      return 0;
     }
    if(b<=k)
    {
      k-=b;
    }
    else
    {
      cout<<sum;
      return 0;
    }
    if(k>0)
    {
      if(c<=k){
      while(k>0 && c>0)
      {
          sum--;
          c--;
          k--;
       }
      }
      else
      {
        while(k)
        {
          sum--;
          k--;
        }
      }
    }
    cout<<sum;
  

    return 0;
  }

Measured memory_bytes: 3652
s = str(input())
K = int(input())
a = []

for i in range(len(s)):
    a.append(s[i])
    j = 2
    while i + j <= len(s) and j <= 5:
        a.append(s[i:i+j])
        j += 1
print(sorted(set(a))[K-1])

Measured memory_bytes: 5068
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<string> arr;
	for(int i = 0; i<n;i++)
	{
		string a;
		cin>>a;
		sort(a.begin(),a.end());
		arr.push_back(a);
	}
	sort(arr.begin(),arr.end());
	long long cnt = 0;
	long long value=0;
	for(int i = 0; i<arr.size();i++)
	{
		if(i + 1 < arr.size() && arr[i]==arr[i+1])
			cnt++;
		else
		{
			value= value + (cnt * (cnt + 1)) / 2;
			cnt = 0;
		}
	}
		value = value + (cnt * (cnt + 1)) / 2;
		
	cout<<value<<endl;
}

Measured memory_bytes: 5748
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort( a, a+3 );
	for(int i=0; i<3; i++)
	{
		if(i==0)
		{
			cout<<a[i];
		}else
		{
			cout<<" "<<a[i];
		}
	}
	cout<<endl;
}


Measured memory_bytes: 3124
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int s[26]={};
    string str;
    getline(cin,str);
    for(int i=0;i<str.size();i++){
        s[(int)(str[i]-97)]++;
    }
    for(int i=0;i<26;i++){
        if(s[i]==0){
            cout << (char)(i+97);
            return 0;
        }
    }
    cout << "None";
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;

  vll p(n + 1);
  REP(i, n + 1) {
    cin >> p[i];
  }

  int cnt = 0;

  REP(i, n + 1) {
    if (p[i] != i) {
      cnt++;
    }
  }

  if (cnt == 0 || cnt == 2) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;


const int N=2000005;
char s[N];
int n,cnt;
ll ans;

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	rep(i,1,n)
		if(s[i]=='A')cnt++;
		else if(s[i]=='B'&&i<n&&s[i+1]=='C')ans+=cnt,i++;
		else cnt=0;
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
long long n,q,k,x,y,z,dist[111111];
vector<pair<long long,long long> > g[111111];
void dfs(long long i,long long fa)
{
    for (long long j=0;j<g[i].size();j++)
    {
        long long to=g[i][j].first,val=g[i][j].second;
        if (to==fa) continue;
        dist[to]=dist[i]+val;
        //cout<<dist[to]<<endl;
        dfs(to,i);
    }
}
int main()
{
    scanf("%lld",&n);
    for (long long i=1;i<n;i++)
    {
        scanf("%lld%lld%lld",&x,&y,&z);
        g[x].push_back(make_pair(y,z));
        g[y].push_back(make_pair(x,z));
    }
    scanf("%lld%lld",&q,&k);
    dfs(k,0);
    while(q--)
    {
        scanf("%lld%lld",&x,&y);
        printf("%lld\n",dist[x]+dist[y]);
    }
    return 0;
}

Measured memory_bytes: 14592
#include <stdio.h>

int main () {
    int a, b, c, d, e, k;
    int dis;
    scanf("%d\n%d\n%d\n%d\n%d\n%d", &a, &b, &c, &d, &e, &k);
    if(e - a > k || e - b > k || e - c > k || e > d > k){
        printf(":(\n");
    }
    else{
        printf("Yay!\n");
    }
    
    return 0;
}



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

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

	static class ProblemB {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			int[] a = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextInt() - 1;
			}
			int[] l = calc(a);
			a = rev(a);
			int[] r = calc(a);
			r = rev(r);
			long ans = 0;
			a = rev(a);
			for (int i = 0; i < n; i++) {
				ans += (long) (a[i] + 1) * l[i] * r[i];
			}
			out.println(ans);
		}

		private int[] calc(int[] a) {
			int[] s = new int[a.length];
			int[] l = new int[a.length];
			int p = 0;
			for (int i = 0; i < a.length; i++) {
				while (p > 0 && a[s[p - 1]] > a[i]) {
					--p;
				}
				if (p == 0) {
					l[i] = i + 1;
				} else {
					l[i] = i - s[p - 1];
				}
				s[p++] = i;
			}
			return l;
		}

		private int[] rev(int[] a) {
			int[] b = new int[a.length];
			for (int i = 0; i < a.length; i++) {
				b[i] = a[a.length - i - 1];
			}
			return b;
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

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

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

	}
}



Measured memory_bytes: 31956
#include <bits/stdc++.h> 
using namespace std; 
int main() { 
  int N, K; 
  cin >> N >> K; 
  int ans = 1;
  int i = 0;
  while (i<N) {
    if (ans+K>=ans*2) {
      ans*=2;
      i++;
    }
    else {
      ans+=K;
      i++;
    }
  }
  cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
// ここに処理を記述
    int N,M;
    cin >> N >> M;

    priority_queue<ll> A;
    int temp = 0;
    for(int i=0; i<N; i++){
        cin >> temp;
        A.push(temp);
    }

    REP(i,M){
        int temp = A.top();
        A.pop();
        A.push(temp / 2);
    }

    ll ans = 0;
    REP(i,N){
        ans += A.top();
        A.pop();
    }

    cout << ans << "\n";

return 0;
}

Measured memory_bytes: 1400
PROGRAM rollerCoaster
      IMPLICIT NONE
      INTEGER :: N, K
      INTEGER,ALLOCATABLE :: h(:)
      INTEGER :: ans
      
      INTEGER :: i
      
      READ*,N ,K
      ALLOCATE( h(N) )
      READ*,h(:)
      
      ans = 0
      
      DO i = 1,N
        IF( h(i)>=K )THEN
          ans = ans + 1
        END IF
      END DO
      
      
      print'(I0)',ans
      
      
      
      
      
      
      END PROGRAM

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  int64_t X;
  cin >> N >> X;
  vector<int64_t> P(N + 1, 1), B(N + 1, 1);
  for (int i = 1; i < N + 1; i++) {
    P[i] = 2 * P[i - 1] + 1;
    B[i] = 2 * B[i - 1] + 3;
  }
  function<int64_t(int, int64_t)> rec = [&](int n, int64_t x) {
    if (n == 0) {
      return x > 0 ? INT64_C(1) : INT64_C(0);
    } else if (x <= B[n - 1] + 1) {
      return rec(n - 1, x - 1);
    } else {
      return P[n - 1] + rec(n - 1, x - (B[n - 1] + 2)) + 1;
    }
  };
  cout << rec(N, X) << '\n';
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int su = 0;
    rep(i, s.size()){
        su += s[i]-'0';
    }
    int n = stoi(s);
    string ans =(n%su==0) ? "Yes":"No";
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
int main() {
    long long n;
    scanf("%lld",&n);
    long long ans=1;
    for(int j=1;1LL*j*j<n;j++) if((n-1)%j==0) {
        if(j!=1) ans++;
        long long k=(n-1)/j;
        if(k!=j) ans++;
    }
    for(int j=2;1LL*j*j<=n;j++) {
        long long now=j;
        for(;now<=n;) {
            if(n%now) break;
            if(n/now%j==1) ans++;
            now*=j;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

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

int main()
{
    string s;
    cin >> s;
    int A = s[0] - '0';
    int B = s[1] - '0';
    int C = s[2] - '0';
    int D = s[3] - '0';

    if (A + B + C + D == 7)
    {
        string ans = to_string(A) + "+" + to_string(B) + "+" + to_string(C) + "+" + to_string(D) + "=7";
        cout << ans << endl;
    }
    else if (A + B + C - D == 7)
    {
        string ans = to_string(A) + "+" + to_string(B) + "+" + to_string(C) + "-" + to_string(D) + "=7";
        cout << ans << endl;
    }
    else if (A + B - C + D == 7)
    {
        string ans = to_string(A) + "+" + to_string(B) + "-" + to_string(C) + "+" + to_string(D) + "=7";
        cout << ans << endl;
    }
    else if (A - B + C + D == 7)
    {
        string ans = to_string(A) + "-" + to_string(B) + "+" + to_string(C) + "+" + to_string(D) + "=7";
        cout << ans << endl;
    }
    else if (A - B - C + D == 7)
    {
        string ans = to_string(A) + "-" + to_string(B) + "-" + to_string(C) + "+" + to_string(D) + "=7";
        cout << ans << endl;
    }
    else if (A - B + C - D == 7)
    {
        string ans = to_string(A) + "-" + to_string(B) + "+" + to_string(C) + "-" + to_string(D) + "=7";
        cout << ans << endl;
    }
    else if (A + B - C - D == 7)
    {
        string ans = to_string(A) + "+" + to_string(B) + "-" + to_string(C) + "-" + to_string(D) + "=7";
        cout << ans << endl;
    }
    else if (A - B - C - D == 7)
    {
        string ans = to_string(A) + "-" + to_string(B) + "-" + to_string(C) + "-" + to_string(D) + "=7";
        cout << ans << endl;
    }

    return 0;
}

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

int main() {
  int N, K;
//  string s;

  cin >> N >> K;
 
   int ans;
 
  if (N % K == 0){
    ans = 0;
  }
  else{
   ans = 1;
  }
  
  cout << ans << endl;
  return 0;
 
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 1000;

int main(void){
    ll N;
    ll answer;
    ll attends[9];
    rep(i, 9) attends[i] = 111 * (i + 1);
    cin >> N;
    
    rep(i, 9) if (attends[i] >= N) {cout << attends[i] << endl; return 0;}

    return 0;
}

Measured memory_bytes: 256
N,M,X,Y=map(int,input().split())
XL=sorted(list(map(int,input().split())))
YL=sorted(list(map(int,input().split())))
ans = 'War'

for Z in range(X+1,Y+1):
    if XL[-1]<Z and Z<=YL[0]:
        ans = 'No War'
        break

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

const int INF = 1e18;

signed main() {
    string S;
    cin >> S;
    int n = S.size();

    int res = INF;

    //例えばA01B(AとBは任意の01文字列)があったとき、A0か1Bのどちらかを反転すれば、
    //01(i文字目とi+1文字目が異なる部分)を1つ消去できる。
    //Kを最大にするため、A0か1Bの長い方の長さを取ればよい。
    //このような操作をi文字目とi+1文字目が異なるすべてのiについて考え、その最小値が
    //答えである。なぜなら、仮の解をtとして、i文字目とi+1文字目が異なり、
    //i<tかつn-i<tであるようなiが存在するとき、長さt以上にわたる反転操作は、必ずi文字目と
    //i+1文字目を同時に巻き込んでしまい、i文字目とi+1文字目を等しくすることが出来ないからである。
    //逆に、i>=tまたはn-i>=tであれば、どちらかの文字だけを含む連続するt文字を反転できるので、
    //i文字目とi+1文字目を等しくできる。tが最小値であれば、これをi文字目とi+1文字目が異なる
    //全てのiについて行うことが出来る。

    rep(i, n-1) {
        if(S[i]!=S[i+1]) {
            res = min(res, max(i+1, n-i-1));
        }
    }

    if(res==INF) res = n;

    cout << res << endl;
 
    return 0;
}

Measured memory_bytes: 512
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

H,W=MAP()
# 四方に一回り大きいグリッドを作る
grid = list2d(H+2, W+2, 0)
for i in range(1, H+1):
    row = LIST()
    for j in range(1, W+1):
        grid[i][j] = row[j-1]

# dp[i][j] := i,jを右端とする最大正方形の辺の長さ
dp=list2d(H+2, W+2, 0)
for i in range(1, H+1):
    for j in range(1, W+1):
        if grid[i][j]!=1:
            # i,jが汚れマスでなければ、左、左上、上から遷移させてくる
            dp[i][j]=min(dp[i-1][j], dp[i][j-1], dp[i-1][j-1])+1
mx=0
for i in range(1, H+1):
    mx=max(mx, max(dp[i]))
print(mx**2)



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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for( int i=0; i<N; i++ ){
    cin >> a.at(i);
  }
  
  for( int i=1; i<N; i++ ){
    for( int j=i; j>0; j-- ){
      if( a.at(j-1) < a.at(j) ){
        int tmp = a.at(j-1);
        a.at(j-1) = a.at(j);
        a.at(j) = tmp;
      }
      else{
        break;
      }
    }
  }
  
  int Alice = 0, Bob = 0;
  for( int i=0; i<N; i++ ){
    if( (i % 2) == 0 ){
      Alice += a.at(i);
    }
    else{
      Bob += a.at(i);
    }
  }
  
  cout << (Alice - Bob) << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;



int main() {
  string a, b;
  cin >> a >> b;
  int c = stoi(a + b);
  bool ans = false;
  rep(i,1000){
    if(i*i == c) ans = true;
  }

  cout << (ans ? "Yes" : "No") << endl;
	return 0;
}



Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define M 10005
#define mod 998244353
typedef long long ll;
char A[M], B[M];
int n, m, len, F[M][M];
ll fac[M], fac_inv[M];
int read() {
	char c = getchar(); int ans = 0;
	while (c < '0' || c > '9') c = getchar();
	while (c >= '0' && c <= '9') ans = ans * 10 + c - '0', c = getchar();
	return ans;
}
void Write(int x) {
	if (x < 10) putchar(x + '0');
	else Write(x / 10), putchar(x % 10 + '0');
}
ll invs(int x) {return x == 1 ? 1 : (mod - mod / x) * invs(mod % x) % mod;}
ll binom(int x, int y) {return x < y || y < 0 ? 0 : fac[x] * fac_inv[y] % mod * fac_inv[x - y] % mod;}
int main() {
	scanf("%s%s", A + 1, B + 1), len = strlen(A + 1);
	for (int i = 1; i <= len; i++) {
		if (A[i] == '1' && B[i] == '1') n++;
		if (A[i] == '1' && B[i] == '0') m++;
	}
	fac[0] = 1;
	for (int i = 1; i <= len; i++) fac[i] = fac[i - 1] * i % mod; fac_inv[len] = invs(fac[len]);
	for (int i = len; i; i--) fac_inv[i - 1] = fac_inv[i] * i % mod;
	for (int i = 0; i <= m; i++) F[0][i] = fac[i] * fac[i] % mod;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			F[i][j] = ((ll)F[i - 1][j] * (i * j) % mod + (ll)F[i][j - 1] * (j * j)) % mod;
	ll ans = 0;
	for (int i = 0; i <= n; i++)
		ans = (ans + binom(n + m, i) * fac[i] % mod * fac[i] % mod * binom(n, i) % mod * F[n - i][m]) % mod;
	return Write(ans), 0;
}


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

const long long MOD = 1000000007;

// 二項定理ライブラリ
const int MAX = 1000000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// int main() {
// 	COMinit();
// 	cout << COM(100000, 50000) << endl;
// }

int main(){
    int x, y;
    cin >> x >> y;
    if (!(y <= 2*x && y >= (x+1)/2 && (x+y)%3 == 0)){
        cout << 0 << endl;
        return 0;
    }
    int n = (x+y) / 3;
    int k = x - n;
    COMinit();
    int ans = COM(n, k);
    cout << ans << endl;
}


Measured memory_bytes: 23680
N, Y = map(int, input().split())
rx, ry, rz = -1, -1, -1

for x in range(N+1):
    for y in range(N+1-x):
            if Y - 10000*x - 5000*y - 1000*(N-x-y) == 0:
                rx, ry, rz = x, y, (N-x-y)
                break
    
print(rx, ry, rz)

Measured memory_bytes: 3060
N, K = map(int, input().split())
lst = [False] * (N+1)
for i in range(K):
    d = int(input())
    for j in map(int, input().split()):
        lst[j] = True
ans = -1
# print(lst)
for i in lst:
    if not i:
        ans += 1
print(ans)

Measured memory_bytes: 67748
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include<vector>

using namespace std;
typedef long long ll;

ll ans,mx,sum,mn=1e8,cnt;


int main(){
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0; i<n; i++){
		cin>>a[i];
	}
	sort(a,a+n);
	for(ll i=0; i<n; i++){
		for(ll j=i+1; j<n; j++){
			for(ll k=j+1; k<n; k++){
				if(a[i]<(a[j]+a[k]) && a[j]<(a[i]+a[k]) && a[k]<(a[i]+a[j])){
					ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define vec vector<ll>
#define mat vector<vector<ll>>

using namespace std;
//using namespace atcoder;

const ll mod=1000000007;
const ll inf=LONG_LONG_MAX;
ll dx4[4]={1,0,-1,0};
ll dy4[4]={0,-1,0,1};
ll dx8[8]={1,0,-1,1,-1,1,0,-1};
ll dy8[8]={1,1,1,0,0,-1,-1,-1};

int main(){

  ll m,k;
  cin >> m >> k;

  if(k>=(ll)pow(2,m))cout << -1 << endl;
  else if(m==0){
    if(k==0)cout << 0 << " " << 0 << endl;
    else cout << -1 << endl;
  }
  else if(m==1){
    if(k==0)cout << 0 << " " << 1 << " " << 1 << " " << 0 << " " << endl;
    else cout << -1 << endl;
  }
  else{
    vec ans;
    for(ll i=0;i<(ll)pow(2,m);i++)if(i!=k)ans.push_back(i);
    ans.push_back(k);
    for(ll i=(ll)pow(2,m)-1;i>=0;i--)if(i!=k)ans.push_back(i);
    ans.push_back(k);
  
    for(ll i=0;i<ans.size();i++)cout << ans[i] << " ";
    cout << endl;
  }



  return 0;
}

Measured memory_bytes: 5852
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
int n;
int bit[100010];
void add(int v, int x) {

	while (v <= n)
	{
		bit[v] += x;
		v += v & -v;
	}
}

ll sum(int v) {
	ll r = 0;
	while (v > 0)
	{
		r += bit[v];
		v -= v & -v;
	}
	return r;
}
void put(string v) {
	cout << "a" << v<< "b" << endl;
}
void solv() {
	int a, b,c;
	cin >> a >> b >> c;
	cout << min(a, min(b, c)) << " " << max(min(a,b), max(min(b,c),min (a,c))) << " " << max(a, max(b, c)) << endl;

}


int main() {
	//	COMinit();
	solv();

	return 0;
}



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

int main(){
	
	int time,t=0,i;
	
	for(i=0;i<4;i++){
		cin >> time;
		
		t += time;
	}
	
	cout << t/60 << '\n' << t%60<< endl;
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>

using namespace std;

int n;
long double ans;

int main()
{
    scanf("%d", &n);
    for(int i = 0; i < n; i++)
    {
        int t;
        scanf("%d", &t);
        ans += (long double)1 / t;
    }
    printf("%.9llf", 1 / ans);
    return 0;
}


Measured memory_bytes: 256
def calc_game_result card_lines
  card_lines
    .lazy
    .map {|l| l.split(" ").map(&:to_i) }
    .map {|(a, b)|
      if a > b
        [a + b, 0]
      elsif a < b
        [0, a + b]
      else
        [a, b]
      end
    }
    .reduce([0, 0]) {|(a_ac, b_ac), (a_gain, b_gain)|
      [a_ac + a_gain, b_ac + b_gain]
    }
end

a_sum, b_sum = Enumerator.new {|y|
  until ((n = gets.to_i) == 0)
    y << n.times.map { gets }
  end
}
  .map{|lines| calc_game_result lines }
  .each {|(a_sum, b_sum)| puts "#{a_sum} #{b_sum}" }

Measured memory_bytes: 6876
from math import ceil

A = [int(input()) for _ in range(5)]

mmin = 10
ans = 0
for ai in A:
    ans += 10*ceil(ai/10)
    if ai%10 != 0:
        mmin = min(mmin, ai%10)
if mmin%10 == 0:
    print(ans)
else:
    print(ans - 10 + mmin)



Measured memory_bytes: 2940
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
 
     String[] nyu=sc.nextLine().split(" ");

//     String nyu=sc.nextLine();
int A=Integer.parseInt(nyu[0]);
int B=Integer.parseInt(nyu[1]);
//int C=Integer.parseInt(nyu[2]);
//int D=Integer.parseInt(nyu);

if(A==1)A=14;
if(B==1)B=14;



//StringBuffer sb = new StringBuffer(nyu);
//		String dst = sb.reverse().toString();

//     String nyu2=sc.nextLine();
//int E=Integer.parseInt(nyu2);



//double A=Double.parseDouble(nyu[0]);
//double B=Double.parseDouble(nyu[1]);
/*
switch(nyu){
case "H H":
System.out.println("H") ;
break;

case "D D":
System.out.println("H") ;
break;

case "H D":
System.out.println("D") ;
break;

case "D H":
System.out.println("D") ;
break;


default:
System.out.println("NO") ;

break;
}
*/

//int res=Math.min((A*B),C);

//for(String tem:nyu){
//if(tem.equals("1"))res++;
//}
//int res=0;
//for(int i=0;i<300;i++){
//if(num[i]==1)res=i;
//}

//char[] c = nyu.toCharArray();


//System.out.println(nyu+"-"+line_r_2+"-"+nyu2+"-"+line_r_1);



if(A==B){
//double res=Math.ceil((AB)/2);

System.out.println("Draw");
}else if(B<A){
System.out.println("Alice");

}else{
System.out.println("Bob");

}




	}
}

Measured memory_bytes: 21844
n=map(str,raw_input().split())
a=[]
ai=0
for i in n:
    if i=="+" :
        a.append(a[ai-1]+a[ai-2])
        a.pop(ai-1);a.pop(ai-2)
        ai-=1
    elif i=="-":
        a.append(a[ai-2]-a[ai-1])
        a.pop(ai-1);a.pop(ai-2)
        ai-=1
    elif i=="*":
        a.append(a[ai-1]*a[ai-2])
        a.pop(ai-1);a.pop(ai-2)
        ai-=1
    else:
        a.append(int(i))
        ai+=1
print(a[0])

Measured memory_bytes: 6468
import itertools

h,w,k=map(int,input().split())

m=[input() for i in range(h)]


ans=0
for i in itertools.product([0,1],repeat=h):
    for j in itertools.product([0,1],repeat=w):
        nij=0
        for a in range(h):
            for b in range(w):
                if i[a]!=1 and j[b]!=1 and m[a][b]=="#":
                    nij+=1
        if nij==k:
            ans+=1

print(ans)

Measured memory_bytes: 9204
#!/usr/bin/ruby
# encoding: utf-8

a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i

def kiriage(n)
  if n%10 != 0
    return (n/10 + 1) * 10
  else
    return n
  end
end

ans = 650
ary = [a,b,c,d,e].permutation(5).to_a

(0..ary.size-1).each do |i|
  sum = 0
  (0..4).each do |j|
    if j == 4 then
      sum += ary[i][j]
    else
      sum += kiriage(ary[i][j])
    end
  end

  if ans >= sum then
    ans = sum
  end
end

puts ans


Measured memory_bytes: 1788
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))

for i in  range(n):
    h[i] = t-h[i]*0.006

ans = 0
diff = 10000000000000000000
for i in range(n):
    if diff > abs(a-h[i]):
        ans = i+1
        diff = abs(a-h[i])
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF LLONG_MAX
#define eps LDBL_EPSILON
#define moder 100000
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
using namespace std;
int n,m;
set<int>st;
signed main() {
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		st.insert(i);
	}
	rep(i,n){
		int k;
		cin>>k;
		set<int> st2;
		rep(j,k){
			int a;
			cin>>a;
			st2.insert(a);
		}
		for(int j=1;j<=m;j++){
			if(st2.find(j)==st2.end())st.erase(j);
		}
	}
	cout<<st.size()<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
using namespace std;
typedef long long llong;
// static const int max_n = 110;
// static const llong max_cost = 2000000000000000;
// // vector<vector<llong>> matrix(max_n, vector<llong>(max_n, 0));
// // vector<vector<llong>> adj_matrix(max_n, vector<llong>(max_n, max_cost));
// vector<vector<pair<llong, int>>> adj_list(max_n);
// vector<llong> distance_table(max_n, max_cost);
// set<pair<llong, int>> points_sort_x;
// set<pair<llong, int>> points_sort_y;

// int N;



int main(){
    // int u, v;
    // bool updated = false;
    llong N, K, res, subbed_left;
    scanf("%lld %lld", &N, &K);
    if(N < K){
        subbed_left = K - N;
        if(subbed_left > N){
            printf("%lld\n", N);
        }else{
            printf("%lld\n", subbed_left);
        }
    }else{
        res = N % K;
        subbed_left = K - res;
        printf("%lld\n", min(res, subbed_left));
    }
    // double limit = 1. / (double)(4 * M);



    return 0;

}

Measured memory_bytes: 256
# completed
def print_list(ele_list):
    print(" ".join(map(str, ele_list)))

def bubble_sort(ele_list):
    len_ele_list = len(ele_list)
    num_swap = 0
    for i in range(0, len_ele_list):
       for j in range(len_ele_list-1, i, -1):
           if ele_list[j] < ele_list[j-1]:
               key = ele_list[j]
               ele_list[j] = ele_list[j-1]
               ele_list[j-1] = key
               num_swap += 1
    print_list(ele_list)
    print(num_swap)

N = int(input())
ele_list = list(map(int, input().split()))

bubble_sort(ele_list)

Measured memory_bytes: 7668
# greedyな選択：数字が小さいほうを増やし大きいほうを減らす。等しい場合どっちでもいい（とりあえず左を増やす）。
# 
# 初手 1 1 1 なら絶対成功 (greedy)
# どこかの状態で 1 1 1 を作れるなら絶対成功 (greedy)
# 0 1 2 なら絶対成功 (greedy)
# 0 0 3 で、初手がAB以外なら絶対成功 (greedy)
# 0 0 0 なら絶対失敗
#
# 初手で成否が分からないのは
# 0 1 1
# 0 0 2
# 0 0 1
#
# 0 0 1 は greedyにやるしかない
# 0 0 2 は、少なくとも1回はgreedy
#
# 結局、各回のgreedyでは問題になるのは
# 0 1 1 で 1 1 のペアでどっちを増やすか選ぶときのみ
# これは1個先を読めば十分


def select(x, y, ops, i, z):
    # true -> x を増やす
    if not(x == 1 and y == 1 and z == 0 and i < len(ops) - 1):
        if x <= y:
            return True
        else:
            return False

    # x = y = 1, z = 0, i < len(ops) - 1
    # 先読みして xz なら x を増やす
    # 先読みして xy なら y を増やす
    # 先読みして xy なら どっちでもいい
    op = ops[i]
    nop = ops[i+1]

    oo = (op, nop)
    if oo in [("AB", "AC"), ("BC", "AB"), ("AC", "AB")]:
        return True

    return False

def main():
    nabc = [int(_x) for _x in input().split()]
    n = nabc[0]
    a = nabc[1]
    b = nabc[2]
    c = nabc[3]

    ops = []
    for i in range(n):
        ops.append(input())

    result = []
    for i in range(n):
        op = ops[i]
        if op == "AB":
            if select(a, b, ops, i, c):
                result.append("A")
                a+=1
                b-=1
            else:
                result.append("B")
                a-=1
                b+=1
        if op == "AC":
            if select(a, c, ops, i, b):
                result.append("A")
                a+=1
                c-=1
            else:
                result.append("C")
                a-=1
                c+=1
        if op == "BC":
            if select(b, c, ops, i, a):
                result.append("B")
                b+=1
                c-=1
            else:
                result.append("C")
                b-=1
                c+=1
        if a <0 or b<0 or c<0:
            print("No")
            return

    print("Yes")
    for r in result:
        print(r)

main()


Measured memory_bytes: 16932
a, b = input().split()
a2 = []
b2 = []
for _ in range(int(b)):
  a2.append(a)
for _ in range(int(a)):
  b2.append(b)
a3 = int("".join(a2))
b3 = int("".join(b2))
if a3 > b3:
  print(a3)
else:
  print(b3)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <assert.h>
 
#define int          long long
#define pb          push_back
#define pii         pair<int,int> 
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007 
#define mem(x)      memset(x,0,sizeof(x));
#define what_is(x)  cout << #x << " is " << x << flush << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
 
using namespace std;
const int maxn = 100010;
int indegree[maxn];
vector<int> adj[maxn];
bool vis[maxn];
int dist[maxn];
int n,m,x,y;
void dfs(int src)
{
	assert(!vis[src]);
	vis[src] = true;

	for(auto i : adj[src])
	{
		dist[i] = max(dist[i], 1+dist[src]);
		indegree[i]--;
		if(indegree[i]==0)
				dfs(i);
	}

}
void solve(){
	cin>>n>>m;
	memset(vis, false, sizeof(vis));
	rep(i,0,m)
	{
		cin>>x>>y;
		adj[x].push_back(y);
		indegree[y]++;
	}
	rep(i,1,n+1)
	{
		if(!vis[i] && indegree[i]==0)dfs(i);
	}
	int ans = 0;

	rep(i,1, n+1)
	{
		ans = max(ans, dist[i]);
	}


	cout<<ans;











}
 
signed main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int t=1;
     //cin>>t;
 
    while(t--)
        solve();
    
    return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> P;

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e18;
const ll mod = 1e9 + 7;

int main(){
	int n;
	cin >> n;
	vector<ll> x,y,h,xx,yy,hh; 
	REP(i,n){
		int a,b,c;
		cin >> a >> b >> c;
		if(c != 0){
			x.push_back(a);
			y.push_back(b);
			h.push_back(c);
		}
		else{
			xx.push_back(a);
			yy.push_back(b);
			hh.push_back(c);
		}
	}
	REP(i,101)REP(j,101){
		int t = abs(i - x[0]) + abs(j - y[0]) + h[0];
		bool ok = true;
		FOR(k,1,x.size()){
			int s = abs(i - x[k]) + abs(j - y[k]) + h[k];
			if(t != s)ok = false;
		}
		REP(k,hh.size()){
			int p = abs(i - xx[k]) + abs(j - yy[k]);
			if(p < t)ok = false;
		}
		if(ok){
			cout << i << ' ' << j << ' '<< t << endl;
			return 0;
		}
	}
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    ll A,B; cin >> A >> B;
    int K; cin >> K;
    for(int i=0;i<K;i++){
        if(i+A>B) break;
        cout << i+A << endl;
    }
    for(int i=1;i<=K;i++){
        if(B-K+i<K+A) continue;
        cout << B-K+i << endl;
    }
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int sum=0;
    int N,M;
    cin>>N>>M;
    vint A(N);rep(i,N)cin>>A[i];
    vint cnt(N);
    for(int i=0;;i+=M){
        int ma=-1,mi=LLONG_MAX;
        for(int j=0;j<M;j++){
            chmax(ma,A[(i+j)%N]);
            chmin(mi,A[(i+j)%N]);
            cnt[(i+j)%N]++;
        }
        sum+=ma-mi;
        if(count(all(cnt),cnt[0])==N)break;
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3092
<?php

$stdin = fopen('php://stdin', "r");
fscanf($stdin, "%s", $str);
$arr = str_split($str);
sort ($arr);
if ($arr[0] != $arr[2] && $arr[0] == $arr[1] && $arr[2] == $arr[3]) {    
    echo "Yes\n";
} else {
    echo "No\n";
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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

#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    vi x(5);
    REP(i,5) cin>>x[i];

    FOR(i,1,5+1){
        if(i!=x[i-1]){
            cout<<i<<endl;
            return 0;
        }
    }

    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<ll> vl ;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;

#define rep(i,N) for(int i=0; i < (int)N; i++)
#define all(v) (v).begin(),(v).end()

const int INF = 1001001001;

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

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
typedef long long ll;
int INF=1<<29;

int main(){
    ios::sync_with_stdio(false);
	int H,W,N;
	cin>>H>>W>>N;
	vector<int> a(N);
	queue<int> q;
	for(int i=0;i<N;i++) cin>>a[i];
	for(int i=0;i<N;i++){
		for(int j=0;j<a[i];j++){
			q.push(i+1);
		}
	}
	for(int i=0;i<H;i++){
		vector<int> tmp;
		for(int j=0;j<W;j++){
			tmp.push_back(q.front());
			q.pop();
		}
		if(i%2==1) reverse(tmp.begin(),tmp.end());
		for(int j=0;j<W;j++) cout<<tmp[j]<<" ";
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include<list>
#include<map>
#include<utility>
#include<tuple>
#include<numeric>
#include<set>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) a.begin(),a.end()
using namespace std;

int main()
{
	int n,t,a;
	cin >> n >> t >> a;
	float cl;
	int ans;
	rep(i, n) {
		int x;
		cin >> x;
		float tmp = t - x * 0.006f;
		float gap = abs(tmp - a);
		if (i == 0) {
			cl = gap;ans = i + 1;
		}
		else if (gap<cl) {
			cl = gap;ans = i + 1;
		}
		

	}
	cout << ans << endl;



}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
string S;
long long K;
int main(){
	cin >> S >> K;
	int count = 0;
	for(int i=0;i<S.size();i++){
		if(S[i]=='1') count++;
		else break;
	}
	if(K==1) cout << S[0] << endl;
	else if(S.size()==1) cout << S[0] << endl;
	else if(S[0]!='1') cout << S[0] << endl;
	else if(S[0]=='1'){
		if(K<=count) cout << '1' << endl;
		else cout << S[count] << endl;
	}
}

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

int a, b, c;

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> a >> b >> c;
    if (c-b==b-a) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

using namespace std;

#define TEMP_T template<typename T>
TEMP_T void sort(T& v){ sort(v.begin(), v.end()); }
TEMP_T void revs(T& v){ reverse(v.begin(), v.end()); }
TEMP_T void uniq(T& v){ sort(v); v.erase(unique(v.begin(), v.end())); }
TEMP_T T    cums(T& v){ T r(v.size()); partial_sum(v.begin(), v.end(), r); return r; }
TEMP_T void show(T& v, char delim=' ', char end='\n'){ for(int i=0; i<v.size()-1; i++) cout << v[i] << delim; cout << v[v.size()-1] << end; }
TEMP_T T    acum(vector<T>& v, T b=0){ return accumulate(v.begin(), v.end(), b); }
TEMP_T vector<T> inpt(int n){ vector<T> v(n); for (int i=0; i<n; i++) cin >> v[i]; return v; }

static inline int in(){ int x; scanf("%d", &x); return x; }

vector<int> divisor(int n){
  vector<int> res;
  for (int i = 1; i * i <= n; i++){
    if (n % i == 0){
      res.push_back(i);
      if (i * i != n) res.push_back(n / i);
    }
  }
  return res;
}

struct Solver {
  Solver(){}
  int solve(){
  }
};

int main()
{
  int n;
  while (n = in()){
    vector<int> ds = divisor(n);
    int s = acum(ds) - n;
    if (s == n){
      puts("perfect number");
    }
    else if (s < n){
      puts("deficient number");
    }
    else {
      puts("abundant number");
    }
  }
  return (0);
}

Measured memory_bytes: 1188
#pragma region def
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

using llint = long long;
using vint = vector<int>;
using vvint = vector<vector <int>>;
using pint = pair<int, int>;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const long long llINF = 1e18;
#pragma endregion

int main () {
    int n;
    cin >> n;
    if (n % 2 == 0) cout << n / 2 << endl;
    else cout << n / 2 + 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define MAX_N 10001

using namespace std;

int data[MAX_N];

int main(){
  int i = 0;
  while(1){
    cin >> data[i];
    if(data[i] == 0) break;
    i++;
  }

  for(int j=0;j < i;j++){
    cout << "Case " << j+1 << ": " << data[j] << endl;
  }
  return 0;
}


Measured memory_bytes: 3044