akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
using namespace std;


int main()
{
  int a,b,c,A[9];
  cin>>a>>b>>c;
  A[0]=a;A[1]=b;A[4]=c;
  for(int i=0;i<=100;i++){
    bool flag=true;
    int K[3]={};
    A[2]=i;
    A[8]=b-c+A[2];
    A[5]=a+c-A[2];
    A[7]=a-c+A[2];
    A[3]=b-2*c+2*A[2];
    A[6]=2*c-A[2];
    for(int j=0;j<3;j++){
      for(int k=0;k<=6;k+=3){
	K[j]+=A[j+k];
      }
    }
    if(K[0]!=K[1]||K[0]!=K[2])flag=false;
    K[0]=0;K[1]=0;K[2]=0;
    for(int j=0;j<=6;j+=3){
      for(int k=0;k<3;k++){
	K[j/3]+=A[j+k];
      }
    }
    if(K[0]!=K[1]||K[0]!=K[2])flag=false;
    K[0]=0;K[1]=0;K[2]=0;
    K[0]=A[0]+A[4]+A[8];
    K[1]=A[2]+A[4]+A[6];
    if(K[0]!=K[1])flag=false;
    
    if(flag)break;
  }
  cout<<A[0]<<" "<<A[1]<<" "<<A[2]<<endl;
  cout<<A[3]<<" "<<A[4]<<" "<<A[5]<<endl;
  cout<<A[6]<<" "<<A[7]<<" "<<A[8]<<endl;

  /*
  for(int i=0;i<9;i++){
    cout<<A[i];
    if(i==2||i==5)cout<<endl;
  }
  */
  return 0;
}


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

int main(){
  
  long long x;
  cin>>x;

  if(x/11==0){
    if(x>6){
      cout<<2<<endl;
    }else{
      cout<<1<<endl;
    }
    return 0;
  }else{
    
    if(x%11==0){
      cout<<x/11*2<<endl;
    }else if((x-x/11*11)>6){
      cout<<x/11*2+2<<endl;
    }else{
      cout<<x/11*2+1<<endl;
    }
  }
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)
#define SORT(s) sort(s.begin(), s.end())
#define P pair<int, int>
#define mp make_pair
using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
    ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
    ostr << "}";
    return ostr;}

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

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

int lcm(int a, int b)
{return a * b / gcd(a, b);}

vector<int> uniq(vector<int> vec){
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  return vec;}

vector<ll> divisor(ll n) {
vector<ll> ret;
for(int64_t i = 1; i * i <= n; i++) {
  if(n % i == 0) {
    ret.push_back(i);
    if(i * i != n) ret.push_back(n / i);
  }
}
  sort(begin(ret), end(ret));
  return (ret);
}
void permu(int n){
  vector<int> perm(n);
  REP(i, n) perm[i] = i;
do{
  cout << perm  << endl;
}
while (next_permutation(perm.begin(), perm.end()));
return;}

vector<pair<ll, int>> prime_div(ll n){
  vector<pair<ll, int>> res;
  for (ll i=2; i*i <= n;i++){
    if (n%i == 0){
      int a = 0;
      while(n%i == 0){
        n /= i;
        a++;
      }
      pair<ll, int> tmp;
      tmp.first = i;
      tmp.second = a;
      res.push_back(tmp);
    }
  }
  if (n != 1){
    pair<ll, int> now;
    now.first = n;
    now.second = 1;
    res.push_back(now);}
  return res;
}


// printf("%.10f\n" , ans);
int main(void){
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  vector<int> x(n);
  REP(i, n) cin >> x[i];
  int ans = 0;
  REP(i, n){
    ans += min(x[i], k-x[i]) * 2;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3628
#include <cstdio>
int x;
int main(){
	scanf("%d",&x);
	if (x>8){
		puts(":(");
		return 0;
	}
	scanf("%d",&x);
	if (x>8){
		puts(":(");
		return 0;
	}
	puts("Yay!");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i,a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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()
{
    int r;
    cin >> r;
    double a = 6.28318530717958623200;
    cout << fixed << setprecision(10);
    cout << r*a << endl;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1e6 + 3, N = 2 * mod + 110;

ll pw(ll a, ll b) {
	ll r = 1;
	for( ; b ; b >>= 1, a = a * a % mod) {
		if(b & 1) {
			r = r * a % mod;
		}
	}
	return r;
}

ll fac[N], inv[N], invfac[N];

int main() {
	fac[0] = invfac[0] = 1;
	for(int i = 1 ; i < mod ; ++ i) {
		fac[i] = fac[i - 1] * i % mod;
	}
	invfac[mod - 1] = pw(fac[mod - 1], mod - 2);
	for(int i = mod - 2 ; i ; -- i) {
		invfac[i] = invfac[i + 1] * (i + 1) % mod;
	}

	inv[1] = 1;
	for(int i = 2 ; i < mod ; ++ i) {
		inv[i] = (-(mod / i) * inv[mod % i] % mod + mod) % mod;
	}
	int q; scanf("%d", &q);
	while(q --) {
		ll x, d, n;
		scanf("%lld%lld%lld", &x, &d, &n);
		if(d == 0) {
			printf("%lld\n", pw(x, n));
		} else if(n >= mod || !x) {
			puts("0");
		} else {
			x = x * inv[d] % mod;
			// x * (x + 1) * ... * (x + n - 1)
			// printf("%lld\n", x + n - 1);
			if(x + n - 1 >= mod) {
				puts("0");
			} else {
				printf("%lld\n", fac[x + n - 1] * invfac[x - 1] % mod * pw(d, n) % mod);
			}
		}
	}
}


Measured memory_bytes: 29568
walk = [(1,0),(0,-1),(0,1),(-1,0)]
warp = [
( 2,-2),( 2,-1),( 2, 0),( 2, 1),( 2, 2),
( 1,-2),( 1,-1),        ( 1, 1),( 1, 2),
( 0,-2),                        ( 0, 2),
(-1,-2),(-1,-1),        (-1, 1),(-1, 2),
(-2,-2),(-2,-1),(-2, 0),(-2, 1),(-2, 2)]

H, W = map(int, input().split())
sh, sw = map(lambda x:int(x)-1, input().split())
eh, ew = map(lambda x:int(x)-1, input().split())
S = [input() for _ in range(H)]

INF = 10**9
dst = [[INF]*W for _ in range(H)]
dst[sh][sw] = 0

from collections import deque
dq = deque([(sh, sw)])
while dq:
    h, w = dq.popleft()

    for dh, dw in walk:
        nh = h + dh; nw = w + dw
        if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.' and dst[h][w] < dst[nh][nw]:
            dst[nh][nw] = dst[h][w]
            dq.appendleft((nh, nw))

    for dh, dw in warp:
        nh = h + dh; nw = w + dw
        if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.' and dst[h][w] + 1 < dst[nh][nw]:
            dst[nh][nw] = dst[h][w] + 1
            dq.append((nh, nw))

print(-1 if dst[eh][ew]==INF else dst[eh][ew])


Measured memory_bytes: 88900
N = int(input())
CSF = [list(map(int, input().split())) for i in range(N-1)]

ans = []
for i, (ci, si, fi) in enumerate(CSF):
  now = si + ci
  for j in range(i+1, N-1):
    cj, sj, fj = CSF[j]
    now = max((-(-now//fj))*fj, sj) + cj
  ans.append(now)

ans.append(0)
print(*ans, sep='\n')

Measured memory_bytes: 3188
#include<stdio.h>
int main(void)
{
	int n;
	int a[100];
	int i,max,min;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	max=-1;
	for(i=1;i<=n;i++){
		if(max<a[i]){
			max=a[i];
		}
	}
	min=1000000000;
	for(i=1;i<=n;i++){
		if(min>a[i]){
			min=a[i];
		}
	}
	n=max-min;
	printf("%d\n",n);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
	char a,b;
	cin >> a >> b;
	if(a=='H'){
		if(b=='H') cout << 'H' << endl;
		else cout << 'D' << endl;
	}else{
		if(b=='D') cout << 'H' << endl;
		else cout << 'D' << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	int N = rei();
	cout << N*N*N << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
const int N = 1e6+5;
int is_prime[N];

int prime(int n)
{
	for(int i = 0;i <= n;++i)	
		is_prime[i] = true;
	is_prime[0] = 1;is_prime[1] = false;
	int res = 0;
	for(int i = 2;i <= n;++ i)
	{
		if(is_prime[i])
		{
			++res;
			for(int j = i * 2;j <= n;j += i)
				is_prime[j] = false;
		}
	}
	return res;
}

int main()
{
	int n;
	while(cin >> n)	
		cout << prime(n) << endl;
	return 0;
}


Measured memory_bytes: 6896
#include<stdio.h>
#include<math.h>
/*void cplc(int p0[2],int p1[2],int p2[2],int r,double s[2],double t[2]){
  int x1=p1[0]-p0[0],y1=p1[1]-p0[1],x2=p2[0]-p0[0],y2=p2[1]-p0[1];
  int a=x1*x1+y1*y1,b=x1*x2+y1*y2,c=x2*x2+y2*y2-r*r;
  double d=sqrt(b*b-a*c);
  s[0]=p0[0]+x1*((b+d)/a);
  s[1]=p0[1]+y1*((b+d)/a);
  t[0]=p0[0]+x1*((b-d)/a);
  t[1]=p0[1]+y1*((b-d)/a);
  }//*/
void ashi(int p0[2],int p1[2],int p2[2],double p3[2]){
  int x1=p1[0]-p0[0],x2=p2[0]-p0[0],y1=p1[1]-p0[1],y2=p2[1]-p0[1];
  p3[0]=1.0*(x1*x2+y1*y2)/(x1*x1+y1*y1)*x1+p0[0];
  p3[1]=1.0*(x1*x2+y1*y2)/(x1*x1+y1*y1)*y1+p0[1];
}
void cplc(int p0[2],int p1[2],int p2[2],int r,double s[2],double t[2]){
  //int x1=p1[0]-p0[0],y1=p1[1]-p0[1];
  double p3[2],x1=p1[0]-p0[0],y1=p1[1]-p0[1],l;
  ashi(p0,p1,p2,p3);
  l=sqrt(r*r-(p3[0]-p2[0])*(p3[0]-p2[0])-(p3[1]-p2[1])*(p3[1]-p2[1]));
  s[0]=p3[0]+x1/hypot(x1,y1)*l;
  s[1]=p3[1]+y1/hypot(x1,y1)*l;
  t[0]=p3[0]-x1/hypot(x1,y1)*l;
  t[1]=p3[1]-y1/hypot(x1,y1)*l;
}  
int main(){
  int p[4][2],n,i,r,j=0;
  double a[2][2],e=0.000005;
  scanf("%d %d %d %d",&p[2][0],&p[2][1],&r,&n);
  while(n--){
    for(i=0;i<4;i++)scanf("%d",&p[i/2][i%2]);
    cplc(p[0],p[1],p[2],r,a[0],a[1]);
    if(fabs(a[0][0]-a[1][0])<e)j=a[0][1]+e<a[1][1]?0:1;
    else                       j=a[0][0]+e<a[1][0]?0:1;
    printf("%.9f %.9f %.9f %.9f\n",a[j][0],a[j][1],a[1-j][0],a[1-j][1]);
  }
  return 0;
}

Measured memory_bytes: 652
#include <iostream>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int a[5];
	for (int index = 0; index < 5; index++) {
		cin >> a[index];
	}
	for (int index = 0; index < 5; index++) {
		if (a[index] == 0) {
			cout << index + 1 << endl;
		}
	}
}


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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;
const long double PI = (acos(-1));
const ull MOD = 1000000007;


struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main(){
    int N;
    cin >> N;
    vector<int> S(N);
    int sum = 0;
    for(int i = 0; i < N; i++){
        cin >> S[i];
        sum += S[i];
    }
    if(sum % 10) cout << sum << endl;
    else{
        sort(all(S));
        for(int s : S){
            if(s % 10){
                cout << sum - s << endl;
                return 0;
            }
        }
        puts("0");
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
	class Uc{
		int r,x,y;
		Uc(int X,int Y){
			x=X;y=Y;
		}
		void swap(){
			r=x;x=y;y=r;
		}
		void gcd(){
			r=x;
			x=y;
			y=r%y;
		}
	}
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		Uc u=new Uc(sc.nextInt(),sc.nextInt());;
		if(u.x<u.y) {
			u.swap();
		}
		while(u.y>0) {
			u.gcd();
		}
		System.out.println(u.x);
		sc.close();
	}
}



Measured memory_bytes: 26148
n = int(input())
import math
import random
s = [1 for i in range(55555+1)]
s[0], s[1] = 0, 0
for i in range(2, int(math.sqrt(55555))+1):
    if s[i] != 0:
        for j in range(i*2, 55555, i):
            s[j] = 0
prime = []
for i in range(55555+1):
    if s[i] == 1:
        if str(i)[-1] == '1':
            prime.append(i)

def is_prime(q):
    q = abs(q)
    if q == 2:
        return True
    if q < 2 or q & 1 == 0:
        return False
    return pow(2, q - 1, q) == 1




ans = ''
for i in range(n):
    ans += str(prime[i]) + ' '
print(ans[:-1])
# print(is_prime(sum(a)))
quit()


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

using std::cin;
using std::cout;
using std::endl;

int main(void) {
	int m,n_min,n_max;
	cin >> m;
	cin >> n_min;
	cin >> n_max;

	while (m!=0||n_min!=0||n_max!=0) {
		std::vector<int> p(m);
		int num_p = n_min;
		int gap_max;
		int gap;
		for (int i = 0; i < m; i++) {
			cin >> p[i];
		}
		gap_max = p[n_min-1] - p[n_min];	
		for (int i = n_min+1; i < n_max+1; i++) {
			gap = p[i-1] - p[i];	
			if (gap >= gap_max) {
				gap_max = gap;
				num_p = i;
			}
		}
		cout << num_p << endl;

		cin >> m;
		cin >> n_min;
		cin >> n_max;
	}
	return 0;
}

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

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

  int n;
  cin >> n;

  int H[250];
  for (int i = 1; i <= n; i++) {
    cin >> H[i];
  }

  for (int i = 1; i <= n; i++) {
    cout << "node " << i << ": ";
    cout << "key = " << H[i] << ", ";
    if (i / 2 > 0) cout << "parent key = " << H[i / 2] << ", ";
    if (i * 2 <= n) cout << "left key = " << H[i * 2] << ", ";
    if (i * 2 + 1 <= n) cout << "right key = " << H[i * 2 + 1] << ", ";
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3148
n = int(input())

num = 0
x = 100
ans = 0
for i in range(n):
    s = int(input())
    if s % 10 != 0:
        num += 1
        x = min(x, s)
    ans += s

if ans % 10 == 0:
    if num == 0:
        ans = 0
    else:
        ans -= x

print(ans)




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

using namespace std ;

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

	int maxy = miny ,num ;
	long sum = miny ;

	for( int i = 1 ; i < n ; i++ )
	{
		cin >> num ;
		miny > num ? miny = num : maxy < num ? maxy = num : 0 ; 
		sum += num ;
	}

	printf( "%d %d %ld\n" ,miny ,maxy ,sum ) ;

	return 0 ;
}

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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h,w,k;
    cin >> h  >> w >> k;
    int graph[h][w];
    int ans[h][w];
    vector<pair<int,int>> locate;
    vector<int> tate[h];
    int cnt = 1;
    rep(i,0,h){
        rep(j,0,w){
            ans[i][j] = 0;
            char tmp=0;
            cin >>tmp;
            if(tmp == '#'){
                tate[i].push_back(cnt);
                graph[i][j] = cnt;
                cnt++;
                locate.push_back(make_pair(i,j));
            }
            else graph[i][j] = 0;
        }
    }
    rep(i,0,h){
        if(tate[i].empty()) continue;
        rep(j,0,w){
            while(graph[i][j] > tate[i].front()) tate[i].erase(tate[i].begin());
            ans[i][j] = tate[i].front();
        }
    }
    rep(i,0,h){
        if(ans[i][0] == 0){
            int tmp = i+1;
            while(ans[tmp][0] == 0 && tmp != h) tmp++;
            if(tmp == h) continue;
            rep(j,0,w){
                //cout << ans[tmp][j];
                ans[i][j] = ans[tmp][j];
            }
        }
    }
    rel(i,h,0){
        if(ans[i][0] == 0){
            int tmp = i-1;
            while(ans[tmp][0] == 0 && tmp != -1) tmp--;
            if(tmp == -1) continue;
            rep(j,0,w){
                ans[i][j] = ans[tmp][j];
            }
        }
    }

    rep(i,0,h){
        rep(j,0,w){
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }

}

Measured memory_bytes: 2804
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main(){
	int N,P;
	cin>>N>>P;
	int A[50];
	rep(i,50){
		int x;
		cin>>x;
		A[i]=x%2;
	}
	bool alleven=true;
	rep(i,N)if(A[i]==1)alleven=false;
	lli ans;
	if(!alleven)ans=(1ull<<N)/2;
	else if(P==0)ans=1ull<<N;
	else ans=0;
	cout<<ans<<endl;
}

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

int main(){
	string s;
	
	while(cin >> s){
		int joi=0, ioi=0;
	
		int len=(int)s.size();
	
		if(len>=3){
			for(int i=0; i<len-2; ++i){
				if(s[i]=='J'){
					if(s[i+1]=='O' && s[i+2]=='I') ++joi;
				}
				else if(s[i]=='I'){
					if(s[i+1]=='O' && s[i+2]=='I') ++ioi;
				}
			}
		}
	
		printf("%d\n%d\n", joi, ioi);
	}
	
	return 0;
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
    
int main() {
    string s[3];
    cin >> s[0] >> s[1] >> s[2];
    cout << (char)(s[0][0] - 0x20) << (char)(s[1][0] - 0x20) << (char)(s[2][0] - 0x20);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int h, w; cin >> h >> w;
    vector<vector<char>> s(h+1, vector<char>(w+1, '.'));
    rep(i, h) {
        string tmp;
        cin >> tmp;
        for(int j=0; j<tmp.size(); j++){
            s.at(i+1).at(j+1) = tmp.at(j);
        }
    }


    vector<vector<int>> hw(h+2, vector<int>(w+2, 0));
    rep(i, h) rep(j, w){
        if(s.at(i+1).at(j+1)=='.') continue;
        else{
            hw.at(i+2).at(j)++;
            hw.at(i+2).at(j+1)++;
            hw.at(i+2).at(j+2)++;
            hw.at(i+1).at(j)++;
            hw.at(i+1).at(j+2)++;
            hw.at(i).at(j)++;
            hw.at(i).at(j+1)++;
            hw.at(i).at(j+2)++;
        }
    }

    rep(i, h) {
        rep(j, w){
            if(s.at(i+1).at(j+1)=='#'){
                cout << '#';
            }
            else{
                cout << hw.at(i+1).at(j+1);
            }
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>
#include <vector>
#include <set>
#include <string.h>
#include <algorithm>
#define mod 1000000007
#define ll long long
#define pr pair<int,int>
#define all vec.begin(),vec.end()
#define REP(i,a,b) for (int i = a; i < b; i++)
#define fi first
#define se second
#define pushb push_back
#define makep make_pair

using namespace std;

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	REP(i,0,b){
		if((a * i) % b == c){
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
	return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] d = new int[n];
        for (int i = 0 ; i < n ; i++) {
            d[i] = sc.nextInt();
        }
        Arrays.sort(d);
        System.out.println(d[n/2] - d[n/2 -1]);
    }

}

Measured memory_bytes: 51024
import java.util.*;

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

        int num = sc.nextInt();
        int[] nums = new int[num];
        for(int i = 0; i < num; i++){
            nums[i] = sc.nextInt();
        }

        int[] ans = new int[num];
        int ansNum = 0;
        for(int i = num-1; i >= 0; i--){
            int sum = 0;
            for(int j = 2 * i + 1; j < num; j += i+1){
                sum += ans[j];
            }

            if(sum%2 == nums[i]){
                ans[i] = 0;
            }else{
                ans[i] = 1;
                ansNum++;
            }
        }

        System.out.println(ansNum);
        if(ansNum != 0){
            StringBuilder sb = new StringBuilder();
            for(int i = 0; i < num; i++){
                if(ans[i] == 1){
                    sb.append(" ");
                    sb.append(i+1);
                }
            }
            System.out.println(sb.substring(1));
        }
    }
}

Measured memory_bytes: 84572
H, W = map(int, input().split())
S = [input() for _ in range(H)]

def check(i,j):
    if S[i][j] == ".":
        return 0

    if i==0:
        if S[i+1][j] == "#":
            return 0
    elif i==H-1:
        if S[i-1][j] == "#":
            return 0
    else:
        if S[i+1][j] == "#" or S[i-1][j] == "#":
            return 0

    if j==0:
        if S[i][j+1] == "#":
            return 0
    elif j==W-1:
        if S[i][j-1] == "#":
            return 0
    else:
        if S[i][j+1] == "#" or S[i][j-1] == "#":
            return 0

    return 1

if sum([check(i,j) for i in range(H) for j in range(W)]) == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;
	cin>>n;
	vector<int> a(n),b;
	for(int& x:a) cin>>x;
	b=a;
	sort(a.begin(),a.end());
	int hi_median=a[n/2];
	int lo_median=a[n/2-1];
	for(int i=0;i<n;++i){
		if(b[i]<a[n/2]) cout<<hi_median<<'\n';
		else cout<<lo_median<<'\n';
	}
}



Measured memory_bytes: 4780
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back

template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x;
        return true;
    }
    return false;
}

template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x;
        return true;
    }
    return false;
}

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

//scanf("%lld", &);
//cin >> ;
//cout << ans << endl;

ll N, M, K, i, j, k, l, ans, cnt = 0;

typedef struct _F{
    ll sum = 0;
    vector<ll> A;
}F;

bool fCheck(F f, ll X){
    ll i;
    REP(i, f.A.size()){
        if(f.A.at(i) < X){
            return false;
        }
    }
    return true;
}

int main(){
    //cin >> ;
    //cout << ans << endl;

    scanf("%lld", &N);

    switch(N % 10){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
        cout << "hon";
        break;
        case 0:
        case 1:
        case 6:
        case 8:
        cout << "pon";
        break;
        case 3:
        cout << "bon";
        break;
    }

    cout << endl;
    return 0;
}

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

int main()
{
	string S;
	cin >> S;
	
	string T = "ATCG";
	
	int ans = 0;
	for(int i = 0; i < S.length(); i++)
	{
		for(int j = i; j < S.length(); j++)
		{
			bool isATCG = false;
			for(int k = 0; k < T.length(); k++)
			{
				if(S[j] == T[k])
				{
					isATCG = true;
				}
			}
			
			if(isATCG)
			{
				ans = max(ans, j - i + 1);
			}
			
			else
			{
				break;
			}
		}
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <ctype.h>
#include <deque>
#include <queue>
#include <cstring>
#include <set>
#include <list>
#include <map>
#include <random>
#include <unordered_map>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef std::vector<int> vi;
typedef std::vector<bool> vb;
typedef std::vector<string> vs;
typedef std::vector<double> vd;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<int> > vvi;
typedef vector<vvi> vvvi;
typedef vector<vll> vvll;
typedef std::vector<std::pair<int, int> > vpi;
typedef vector<vpi> vvpi;
typedef std::pair<int, int> pi;
typedef std::pair<ll, ll> pll;
typedef std::vector<pll> vpll;

const long long mod = 1000000007;

#define all(c) (c).begin(),(c).end()
#define sz(c) (int)(c).size()
#define forn(i, a, b) for(int i = a; i < b; i++)

#define pb push_back
#define mp make_pair

char a[1000][1011];


ll powM(ll k, ll n, ll modulo) {
    if (n==0) return 1;
    if(n==1) return k;
    ll x = powM(k, n/2, modulo);
    return (((x*x)%modulo)*powM(k, n%2, modulo)) % modulo;
}

vvll mprod(vvll &a, vvll &b) {
    int n = a.size();
    vvll c(n, vll(n,0));
    forn(i,0,n) {
        forn(j,0,n) {
            forn(k,0,n) {
                c[i][j] = (c[i][j] +a[i][k] * b[k][j]) % mod;
            }
        }
    }
    return c;
}

vvll mexp(vvll & a, ll d) {
    int n = a.size();
    vvll res(n, vll(n,0));
    vvll md = a;
    forn(i,0,n) res[i][i] = 1;
    while(d>0) {
        if(d%2) {
            res = mprod(res, md);
        }
        d /= 2;
        md = mprod(md, md);
    }
    return res;
}

int main()
{

    int h,w;
    ll k;
    scanf("%d %d %lld\n" ,&h,&w,&k);
    if(k==0) {
        cout<<1;
        return 0;
    }
    ll cnt = 0;
    forn(i,0,h) {
        scanf("%s\n", a[i]);
        forn(j,0,w) if(a[i][j] == '#') cnt++;
    }
    bool hor = false;
    bool ver = false;
    forn(i,0,w) {
        if(a[0][i] == '#' && a[h-1][i] == '#') ver = true;
    }
    forn(i,0,h) {
        if(a[i][0] == '#' && a[i][w-1] == '#') hor = true;
    }
    if(hor&&ver) {
        cout<<1<<endl;
        return 0;
    }
    if(hor == false && ver == false) {
        ll ans = powM(cnt, k-1, mod);
        cout<<ans;
        return 0;
    }
    if(hor) {
        ll IL = 0;
        ll OL = 0;
        forn(i,0,h) if(a[i][0]=='#' && a[i][w-1]=='#') OL++;
        forn(i,0,h) forn(j,0,w-1) if(a[i][j]=='#' && a[i][j+1]=='#') IL++;
        vvll m(2, vll(2,0));
        m[0][0] = OL;
        m[0][1] = IL;
        m[1][1] = cnt;
        vvll res = mexp(m, k-1);
        cout<< (mod - res[0][1] + res[1][1])%mod << endl;
        return 0;
    }
    if(ver) {
        ll IL = 0;
        ll OL = 0;
        forn(j,0,w) if(a[0][j]=='#' && a[h-1][j]=='#') OL++;
        forn(i,0,h-1) forn(j,0,w) if(a[i][j]=='#' && a[i+1][j]=='#') IL++;
        vvll m(2, vll(2,0));
        m[0][0] = OL;
        m[0][1] = IL;
        m[1][1] = cnt;
        vvll res = mexp(m, k-1);
        cout<< (mod - res[0][1] + res[1][1])%mod << endl;
        return 0;
    }
    
    
    
}



Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void) {
    
    char buf[128];
    int i;
    scanf("%d",&i);
    scanf("%128s",buf);
    
    if(strlen(buf) > i){
        buf[i] = 0;
        printf("%s...\n",buf);
    }else{
        printf("%s\n",buf);
    }
    

    return 0;
}

Measured memory_bytes: 2156
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    vector<ll> S(n+1);
    for (int i = 0; i < n; ++i) {
        scanf("%lld", &S[i+1]);
        S[i+1] += S[i];
    }
    map<ll, int> m;
    int ans = 0;
    for (int i = 0; i <= n; ++i) {
        if(m.count(S[i])) ans = max(ans, i-m[S[i]]);
        else m[S[i]] = i;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 16784
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using P = pair<int, int>;

int N;
int a[200001];
int b[200001] = {0};

int main() {
  cin >> N;
  rep(i, N) {
    cin >> a[i+1];
  }
  for(int i = N; i >= 1; i--) {
    int key = 0;
    for(int j = i; j <= N; j = j + i) {
      if(i == j) continue;
      key += b[j];
    }
    if(key % 2 != a[i]) b[i]++;
    else continue;
  }

  vector<int> v;
  rep(i, N) {
    if(b[i+1] != 0) {
      v.push_back(i+1);
    }
  }
  cout << v.size() << endl;
  rep(i, v.size()) {
    cout << v[i];
    if(i != v.size()-1) cout << " ";
    else cout << endl;
  }

  return 0;
}

Measured memory_bytes: 5192
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
	static Scanner stdIn = new Scanner(System.in);
	static FastScanner sc = new FastScanner();
	static PrintWriter out = new PrintWriter(System.out);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int m = sc.nextInt();
		ArrayList<Integer> s = new ArrayList<Integer>();
		ArrayList<Integer> t = new ArrayList<Integer>();
		ArrayList<Integer> e = new ArrayList<Integer>();
		while(true) {
			int ts = sc.nextInt();
			int tt = sc.nextInt();
			int te = sc.nextInt();
			
			if(ts == 0 && tt == 0 && te == 0) break;
			s.add(ts);
			t.add(tt);
			e.add(te);
		}
		
		int l = sc.nextInt();
		for(int i = 0; i < l; i++) {
			int[] list = new int[m];
			int[] ans = new int[n];
			for(int j = 0; j < m; j++) {
				list[j] = sc.nextInt();
			}
			for(int j = 0; j < s.size(); j++) {
				int ts = s.get(j);
				int tt = t.get(j);
				int te = e.get(j);
			
				ans[ts-1] += list[tt-1] * te;
			}
			out.print(ans[0]);
			for(int j = 1; j < n; j++) {
				out.print(" " + ans[j]);
			}
			out.println();
		}
		out.flush();
		
	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		}else{
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	public boolean hasNext() { skipUnprintable(); return hasNextByte();}
	public String next() {
		if (!hasNext()) throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while(isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			}else if(b == -1 || !isPrintableChar(b)){
				return minus ? -n : n;
			}else{
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	
	public int nextInt() {
		return (int)nextLong();
	}
 
	public double nextDouble() {
		return Double.parseDouble(next());
	}
 
}

Measured memory_bytes: 97340
#include<stdio.h>

int main(void){
  int a,b,c;
  
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  
  if(a==5 && b == 5 && c == 7){
    printf("YES");
  }else if(a == 5 && b == 7 && c == 5){
      printf("YES");
  }else if(a == 7 && b == 5 && c == 5){
      printf("YES");
  }else{
      printf("NO");
    }
  
  
  return 0;
}

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

int main() {
  int n,k,m=1;
  cin >> n >> k;
  
  for(int i=0;i < n;i++) {
    if (2*m < m+k)
      m *=2;
    else
      m +=k;
   }
  cout << m << endl;
}

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

const int INF = 1 << 30;

int main() {
	int N;
	cin >> N;
	int score = 0;
	int tmp = INF;
	for (int i = 0; i < N; i++) {
		int s;
		cin >> s;
		score += s;
		if (s % 10 != 0) tmp = min(tmp, s);
	}
	if (score % 10 != 0)
		cout << score << endl;
	else if (tmp != INF)
		cout << score - tmp << endl;
	else
		cout << 0 << endl;
}


Measured memory_bytes: 256
/*** 𝕒𝕜𝕤𝕙𝕒𝕪𝕜𝕦𝕞𝕒𝕣𝟡𝟡 ***/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=5e5+1;
 
typedef long long ll;
typedef long double ld;

ll blocksize = 1000, n, m, ans = 0;
ll a[N];
ll cont[N];

void remove(ll ind)
{
	if(cont[a[ind]] == 1)
		ans--;
    cont[a[ind]]--;
}
void add(ll ind)
{
    cont[a[ind]]++;
    if(cont[a[ind]] == 1)
		ans++;
}
ll getanswer()
{
    return ans;
}
struct Query
{
    ll l, r, ind;
    bool operator<(Query other) const
    {
        return make_pair(l/blocksize, r)<make_pair(other.l/blocksize, other.r);
    }
};

vector<ll> mosalgo(vector<Query> queries)
{
    vector<ll> answer(queries.size());
    sort(all(queries));
    ll curl=0, curr=-1;
    for(Query q : queries)
    {
        while(curl>q.l)
        {
            curl--;
            add(curl);
        }
        while(curr<q.r)
        {
            curr++;
            add(curr);
        }
        while(curl<q.l)
        {
            remove(curl);
            curl++;
        }
        while(curr>q.r)
        {
            remove(curr);
            curr--;
        }
        answer[q.ind]=getanswer();
    }
    return answer;
}

void test_case()
{
    cin >> n >> m;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    vector<Query> v;
    for(int i = 0; i < m; i++)
    {
        ll x,y;
        cin >> x >> y;
        x--;y--;
        v.pu({x,y,i});
    }
    vector<ll> res = mosalgo(v);
    for(int i = 0; i < m; i++)
        cout<<res[i]<<'\n';

}

int main()
{
    IOS();
   
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 38460
/*
 _ _ _   _    _   _    _   _ _ _   _    _   _ __ _   __       __
|  _ _| | |  | | | |  | | |  _  | | |  | | |  __  | |   \   /   |
| |_ _  | |__| | | |  | | | |_| | | |__| | | |__| | | |\ \_/ /| |
|_ _  | |  __  | | |  | | |  _ <  |  __  | |  __  | | | \   / | |
 _ _| | | |  | | | |__| | | |_| | | |  | | | |  | | | |  \_/  | |  _   _   _
|_ _ _| |_|  |_| |_ __ _| |_ _ _| |_|  |_| |_|  |_| |_|       |_| |_| |_| |_|

*/

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

#define ll long long int
#define fi first
#define se second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define debug(a) cout << #a << " = " << a << " ";
#define endl "\n"
const int  MOD=1000000007;
const int N=1000100;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve(){
    int N; cin >> N;
    vector<int> P(N),Q(N);
    for(int i=0; i<N; i++){
        cin >> P.at(i);
    }
    for(int i=0; i<N; i++){
        cin >> Q.at(i);
    }
    vector<int> order(N);
    for(int i=0; i<N; i++){
        order.at(i)=i+1;
    }
    int a,b;
    int now=1;
    do{
        int cntp=1; int cntq=1;
        for(int i=0; i<N; i++){
            if(order.at(i)!=P.at(i)) cntp=0;
            if(order.at(i)!=Q.at(i)) cntq=0;
        }
        if(cntp==1) a=now;
        if(cntq==1) b=now;
        now++;
    }while(next_permutation(order.begin(),order.end()));
    cout << abs(a-b) << endl;
}

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


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1<<(n))
#define popcount(n) (__builtin_popcountll(n))


using namespace std;

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int inf=1<<28;
int h,w;


int board[10];
int len[15][15];

int min_res=0;
int dfs(int y,int x,int d,int remain){
	if(d+(remain?1:0)>min_res) return inf;

	if(y==h){		
		if(min_res>d) min_res=d;
		return d;
	}

	if(x>=w) return dfs(y+1,0,d,remain);
	
	if(len[y][x]==0) return dfs(y,x+1,d,remain);

	int ret=inf;
	if((board[y]&bit(x))==0){
		int cur=dfs(y,x+1,d,remain);
		if(ret>cur) ret=cur;
	}

	int tboard[10],l=len[y][x];
	rep(i,y,y+l) tboard[i]=board[i];

	int nremain=remain;
	int mask=((1<<l)-1)<<x;
	rep(a,y,y+l){
		nremain-=popcount(board[a]&mask);
		board[a]&=(1023^mask);
	}

	if(remain!=nremain){
		int cur=dfs(y,x+1,d+1,nremain);
		if(ret>cur) ret=cur;
	}
	
	rep(i,y,y+l) board[i]=tboard[i];
	return ret;
}

int main(void){
	while(1){
		scanf("%d %d",&w,&h);
		if(w==0) break;

		rep(i,h){
			board[i]=0;
			rep(j,w){
				int tmp;
				scanf("%d ",&tmp);
				board[i]|=(tmp<<j);
			}
		}

		rep(i,h)rep(j,w){
			len[i][j]=0;
			if((board[i]&bit(j))==0) continue;
			len[i][j]=min(h-i,w-j);
			const int l=len[i][j];
			rep(a,i,i+l)rep(b,j,j+l) if((board[a]&bit(b))==0) len[i][j]=min(len[i][j],max(a-i,b-j));
		}

		int num[10][10],sy[10][10],sx[10][10];
		rep(i,h)rep(j,w) num[i][j]=0;
		rep(i,h)rep(j,w){
			if(i-1>=0 && j-1>=0 && len[i][j] !=1 && len[i][j]+1 == len[i-1][j-1]) len[i][j]=0;
			const int l=len[i][j];
			rep(a,i,i+l)rep(b,j,j+l) num[a][b]++,sy[a][b]=i,sx[a][b]=j;
		}

		int add=0;
		rep(i,h)rep(j,w){
			if(num[i][j]!=1) continue;
			const int cy=sy[i][j],cx=sx[i][j],l=len[cy][cx],mask=((1<<l)-1)<<cx;
			rep(a,cy,cy+l) board[a]&=(1023^mask);
			len[cy][cx]=0,add++;
		}

		int remain=0;
		rep(i,h) remain+=popcount(board[i]);
		min_res=remain;
		printf("%d\n",dfs(0,0,0,remain)+add);
	}
	return 0;
}

Measured memory_bytes: 3136
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<map>

using namespace std;

int main()
{
	long A, B, C, K;
	cin >> A >> B >> C >> K;
	
	
	if(A >= K) cout << K << endl;
	else if(B >= K - A) cout << A << endl;
	else  cout << A - (K - A - B) << endl;
	
	return 0;

}

Measured memory_bytes: 3620
from math import floor,ceil,sqrt,factorial,log
from collections import Counter, deque
from functools import reduce
import numpy as np
def S(): return input()
def I(): return int(input())
def MS(): return map(str,input().split())
def MI(): return map(int,input().split())
def FLI(): return [int(i) for i in input().split()]
def LS(): return list(MS())
def LI(): return list(MI())
def LLS(): return [list(map(str, l.split() )) for l in input()]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def LLSN(n: int): return [LS() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]

S,W = MI()

if W >= S:
    print("unsafe")
else:
    print("safe")



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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
#ifdef MYLOCAL
    ifstream in("input.txt");
    cin.rdbuf(in.rdbuf());
#endif
    ll N, M; cin >> N >> M;
    vector<int> A(M), B(M);
    for (int i = 0; i < M; ++i) {
        cin >> A[i] >> B[i], --A[i], --B[i];
    }

    UnionFind uf(N);

    // 操作を逆順
    ll cur = N * (N-1) / 2;
    vector<ll> res;
    for (int i = 0; i < M; ++i) {
        res.push_back(cur);

        int a = A[M-1-i], b = B[M-1-i];
        if (uf.issame(a, b)) continue;

        ll sa = uf.size(a), sb = uf.size(b);
        cur -= sa * sb;
        uf.merge(a, b);
    }

    // 出力のため反転
    reverse(res.begin(), res.end());
    for (int i = 0; i < res.size(); ++i){
        cout << res[i] <<endl;
    }

    return 0;
}



Measured memory_bytes: 3444
#include <stdio.h>
 
int main(void) {
 
  int am,pm;
  char cls[20];
 
  int i;
 
   
  for(i=0;i<9;i++) {
 
    scanf("%s %d %d",cls,&am,&pm);
     
    printf("%s %d %d\n",cls,am+pm,am*200+pm*300);
     
  }
 
  return 0;
 
}

Measured memory_bytes: 596
import sys
from fractions import gcd

input = sys.stdin.readline

N, X = map(int, input().split())
x = list(map(int, input().split()))

if N == 1:
    print(abs(X - x[0]))
    exit()

x.append(X)
x.sort()
diff = []
ans = []

for i in range(N):
    diff.append(x[i+1] - x[i])

for i in range(N-1):
    ans.append(gcd(diff[i], diff[i+1]))

print(min(ans))

Measured memory_bytes: 16280
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char* argv[]) {
  string s;
  cin >> s;

  long long ret = 0;
  long long last = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == '>') {
      long long count = 0;
      long long j;
      for (j = i; j < s.size(); ++j) {
        if (s[j] == '>') {
          ++count;
          ret += count;
        } else
          break;
      }
      i = j - 1;
      if (last > count)
        ret += last - count;
      if (j == s.size()) {
        break;
      }
      last = 0;
    } else {
      if (i == s.size() - 1) {
        ret += 1;
        break;
      }
      long long count = 0;
      long long j;
      for (j = i; j < s.size(); ++j) {
        if (s[j] == '<') {
          ++count;
          ret += count;
        } else
          break;
      }
      ret -= count;
      last = count;
      if (j == s.size()) {
        ret += count;
        break;
      }
      i = j - 1;
    }
  }

  cout << ret << endl;

  return 0;
}

Measured memory_bytes: 900
#include <math.h>
#include <iostream>
using namespace std;

int main() {
	int lop; cin >> lop;
	long double xa, ya, ra, xb, yb, rb;
	long double d;
	for (; lop > 0; lop--) {
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		d = (xa - xb)*(xa - xb) + (ya - yb)*(ya - yb);
		if (d < ra * ra - 2 * ra*rb + rb * rb) {
			if (ra > rb)
				cout << 2 << endl;
			else
				cout << -2 << endl;
			continue;
		}
		if (d <= rb * rb + 2 * ra*rb + ra * ra) {
			cout << 1 << endl;
			continue;
		}
		cout << 0 << endl;
	}
	return 0;
}


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

char s[10];
int main() {
	int n; cin >> n;
	while (1) {
		sprintf(s, "%05d", n);
		rep(i, 5) {
			if (s[i] <= '4')cout << '*';
			else cout << ' ';
		}cout << endl;
		rep(i, 5) {
			if (s[i] >= '5')cout << '*';
			else cout << ' ';
		}cout << endl;
		rep(i, 5)cout << '='; cout << endl;
		rep(i, 5) {
			rep(j, 5) {
				if ((s[j] - 48) % 5 != i)cout << '*';
				else cout << ' ';
			}
			cout << endl;
		}
		if (!(cin >> n))return 0;
		cout << endl;
	}
}

Measured memory_bytes: 3136
#include <algorithm>
#include<iostream>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;
  int n;
  cin >> n;
  vector<int> prime;
  int cnt;
  for(ii=2;ii<=200;ii++){
    cnt = 0;
    for(jj=2;jj<=sqrt(ii);jj++){
      if(ii % jj == 0){
        cnt ++;
        break;
      }
    }
    if(cnt == 0){
      prime.push_back(ii);
    }
    //cout << "ii:" << ii << endl;
  }

  //for(auto p : prime){
  //  cout << p << endl;
  //}
  int sum=0;
  for(jj=1;jj<=n;jj+=2){
    cnt = 0;

    for(ii=1;ii<=jj;ii++){
      if(jj % ii == 0){
        cnt++;
      }
    }
    
    if(cnt == 8){
      sum++;
    }
    else{
      //cout << "0" << endl;
    }

  }
  
  cout << sum << endl;
  //cout << "n:" << n << endl;
  //for(auto p : prime){
  //
  //  while(true){
  //    if(n % p != 0){
  //      cout << "break p:" << p << endl;    
  //      break;
  //    }
  //    else{
  //      cout << "p:" << p << endl;    
  //      n = n / p;
  //      cnt++;
  //    }
  //  }
  //}
  //cout << cnt;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
from collections import deque
import bisect

color = deque([a.pop(0)])
color_count =0 
for ai in a: 
    index = bisect.bisect_left(color, ai)
    if index > 0:
        color[index -1] = ai
    else:
        color.appendleft(ai)
print(len(color))

Measured memory_bytes: 8080
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
Int printX(Int r, Int D, Int X, int count){
    if(count == 10){
        return 0;
    }
    Int nextX = r*X - D;
    cout<< nextX <<endl;
    printX(r,D,nextX,count+1);

}
int main() {
    string S;
    string ans = "NO";

    cin >> S;

    int size = S.size();
    int win_t = 0;
    rep(i,size){
        if(S[i]=='o'){
            win_t++;
        }
    }

    if( win_t+15-size > 7){
        ans = "YES";
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <unordered_map>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

int main() {
    int a, b;
    cin >> a >> b;
    int n = a + b;
    if (n > 23) n -= 24;
    cout << n << endl;
}


Measured memory_bytes: 256