akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

struct node_t {
	int id;
	int parent;
	int childs[2];
};
typedef struct node_t Node;

void preorder_walk(Node *data, int index, int out[25], int *ptr) {
	Node *p;

	p = &data[index];
	out[(*ptr)++] = p->id;
	if (p->childs[0] >= 0) {
		preorder_walk(data, p->childs[0], out, ptr);
	}
	if (p->childs[1] >= 0) {
		preorder_walk(data, p->childs[1], out, ptr);
	}
}

void inorder_walk(Node *data, int index, int out[25], int *ptr) {
	Node *p;

	p = &data[index];
	if (p->childs[0] >= 0) {
		inorder_walk(data, p->childs[0], out, ptr);
	}
	out[(*ptr)++] = p->id;
	if (p->childs[1] >= 0) {
		inorder_walk(data, p->childs[1], out, ptr);
	}
}

void postorder_wark(Node *data, int index, int out[25], int *ptr) {
	Node *p;

	p = &data[index];
	if (p->childs[0] >= 0) {
		postorder_wark(data, p->childs[0], out, ptr);
	}
	if (p->childs[1] >= 0) {
		postorder_wark(data, p->childs[1], out, ptr);
	}
	out[(*ptr)++] = p->id;
}


int main(void) {
	Node data[25], *p;
	int n, id, left, right, start, out[25], i;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		data[i].parent = -1;
	}
	for (i = 0; i < n; i++) {
		scanf("%d %d %d ", &id, &left, &right);
		p = &data[id];
		p->id = id;
		p->childs[0] = left;
		p->childs[1] = right;
		if (left >= 0) {
			data[left].parent = id;
		}
		if (right >= 0) {
			data[right].parent = id;
		}
	}

	for (i = 0; i < n; i++) {
		if (data[i].parent == -1) {
			start = data[i].id;
			break;
		}
	}

	puts("Preorder");
	i = 0;
	preorder_walk(data, start, out, &i);
	for (i = 0; i < n; i++) {
		printf(" %d", out[i]);
	}
	puts("\nInorder");
	i = 0;
	inorder_walk(data, start, out, &i);
	for (i = 0; i < n; i++) {
		printf(" %d", out[i]);
	}
	puts("\nPostorder");
	i = 0;
	postorder_wark(data, start, out, &i);
	for (i = 0; i < n; i++) {
		printf(" %d", out[i]);
	}
	putchar('\n');
	return 0;
}

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

int main() {

	int h, w; cin >> h >> w;
	vector<vector<char>> c(h + 2, vector<char>(w + 2, 'e'));
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> c[i][j];
		}
	}
	vector<vector<int>> u(h + 2, vector<int>(w + 2, 0));
	vector<vector<int>> d(h + 2, vector<int>(w + 2, 0));
	vector<vector<int>> l(h + 2, vector<int>(w + 2, 0));
	vector<vector<int>> r(h + 2, vector<int>(w + 2, 0));
	for (int j = 1; j <= w; j++) {
		for (int i = h; i >= 1; i--) {
			if (c[i][j] == '.') u[i][j] += u[i + 1][j] + 1;
			else u[i][j] = 0;
		}
	}
	for (int j = 1; j <= w; j++) {
		for (int i = 1; i <= h; i++) {
			if (c[i][j] == '.') d[i][j] += d[i - 1][j] + 1;
			else d[i][j] = 0;
		}
	}
	for (int i = 1; i <= h; i++) {
		for (int j = w; j >= 1; j--) {
			if (c[i][j] == '.') l[i][j] += l[i][j + 1] + 1;
			else l[i][j] = 0;
		}
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {			
			if (c[i][j] == '.') r[i][j] += r[i][j - 1] + 1;
			else r[i][j] = 0;
		}
	}
	int ans = 0;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (c[i][j] == '#') continue;
			int tmp = -3;
			tmp += u[i][j];
			tmp += d[i][j];
			tmp += l[i][j];
			tmp += r[i][j];
			tmp = max(0, tmp);
			ans = max(ans, tmp);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 69976
#include<stdio.h>
#define MAX 1000


int main(){
  int i,j,A[MAX],n,key;

  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&A[i]);

  for(i=1;i<n;i++){
    for(j=0;j<n;j++){
      if ( j != 0 ) printf(" ");
      printf("%d",A[j]);
    }
    printf("\n");
    key=A[i];
    j=i-1;
    while(j>=0 && A[j]>key){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]=key;
  }
  
  for(j=0;j<n;j++){
    if ( j != 0 ) printf(" ");
    printf("%d",A[j]);
  }
  printf("\n");
  
  return 0;
}



Measured memory_bytes: 2108
N,Y = map(int,input().split())

"""
x #10,000円
y #5,000円
z #1,000円
z = n - x - y
"""

for x in range(N+1):
    for y in range(N+1):
        if N-x-y >= 0:
            if 10000*x + 5000*y + 1000*(N-x-y) == Y:
                print(x,y,N-x-y)
                exit()

print(-1,-1,-1)


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

void solve() 
{
    string s,t;cin>>s>>t;int c=0;REP(i,s.size())if(s[i]!=t[i])c++;cout<<c<<endl;
}

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

Measured memory_bytes: 3772
import java.util.Scanner;
 
public class Main {
    public static int n;
    public static int q;
    public static int[] p;
    public static int[] rank;
 
    public static boolean same(int x, int y) {
        return findSet(x) == findSet(y);
    }
 
    public static void unite(int x, int y) {
        int i = findSet(x);
        int j = findSet(y);
 
        if (i == j){
	    return;
	}
        if (rank[i] > rank[j]){
            p[j] = p[i];
        }
        else {
            p[i] = p[j];
            if(rank[i] == rank[j]){
            rank[j]++;
            }
        }	
    }
 
    public static int findSet(int i) {
       if(p[i] == i){ 
           return i;
        }else{
          return p[i] = findSet(p[i]);
        }
    }
 
    public static void DisjointSet() {
        p = new int[n];
        rank = new int[n];
 
        for (int i = 0; i < n; i++) {
            p[i] = i;
            rank[i] = 0;
        }
    }
 
 
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        q = scanner.nextInt();
 
        DisjointSet();
        for (int i = 0; i < q; i++) {
            int com = scanner.nextInt();
            int x = scanner.nextInt();
            int y = scanner.nextInt();
 
            if (com == 0){
                unite(x, y);
            }
            if (com == 1){
                if (same(x, y)){
                    System.out.println(1);
                }else{
                    System.out.println(0);
		}
            }
        }
    }
}

Measured memory_bytes: 102072
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

class edge{
public:
	Int cost;
	size_t from, to;
	edge(Int c, size_t f, size_t t){
		cost = c;
		from = f;
		to = t;
	}
};
typedef vector<edge> edges;
typedef vector<edges> graph;
void readgraph(graph &g, size_t E, bool D, bool C, bool Z){ // E:num_of_edges, D:directed, C:costed, Z:already 0-indexed
	for(size_t i=0; i<E; ++i){
		edge e(1, 0, 0);
		if(!C) cin >> e.from >> e.to;
		else cin >> e.from >> e.to >> e.cost;
		if(!Z){
			--e.from;
			--e.to;
		}
		g[e.from].push_back(e);
		if(!D){
			swap(e.from, e.to);
			g[e.from].push_back(e);
		}
	}
}
class unionfind{ // 0-indexed
public:
	vector<int> parent;
	vector<size_t> size;
	size_t num_of_disjointsets;
	unionfind(size_t n){
		parent.resize(n, -1);
		size.resize(n, 1);
		num_of_disjointsets = n;
	}

	size_t find(size_t x){
		if(parent[x] == -1) return x;
		return parent[x] = find(parent[x]);
	}

	size_t unite(size_t x, size_t y){
		x = find(x);
		y = find(y);
		if(x == y) return -1;
		if(size[x] < size[y]){
			parent[x] = y;
			size[y] += size[x];
			size[x] = 0;
			--num_of_disjointsets;
			return y;
		}else{
			parent[y] = x;
			size[x] += size[y];
			size[y] = 0;
			return x;
			--num_of_disjointsets;
		}
	}

	bool united(size_t x, size_t y){
		return find(x) == find(y);
	}
};
bool operator < (const edge &e, const edge &f){
	return e.cost != f.cost ? e.cost > f.cost : e.from != f.from ? e.from < f.from : e.to < f.to;
}
vector<edge> kruskal(graph &g){
	priority_queue<edge> pq;
	for(size_t i=0; i<g.size(); ++i)
		for(size_t j=0; j<g[i].size(); ++j)
			if(i < g[i][j].to)
				pq.push(g[i][j]);
	unionfind uf(g.size());
	vector<edge> res;
	while(!pq.empty()){
		edge e = pq.top(); pq.pop();
		if(!uf.united(e.from, e.to)){
			uf.unite(e.from, e.to);
			res.push_back(e);
		}
		if(uf.num_of_disjointsets == 1) break;
	}
	return res;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int v, e;
	cin >> v >> e;
	graph g(v);
	readgraph(g, e, false, true, true);
	vector<edge> mst = kruskal(g);
	Int ans = 0;
	for(auto &i:mst) ans += i.cost;
	cout << ans << "\n";
}


Measured memory_bytes: 13860
#include<stdio.h>

int main(void){
	int n,i;
	int debt = 100000;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		debt *= 1.05;
		
		if((debt % 1000) != 0){
			debt /= 1000;
			debt++;
			debt *= 1000;
		}
	}
	
	printf("%d\n", debt);
	
	return 0;
}

Measured memory_bytes: 592
import sys

#+++++
		
def main():
	s = input()
	
	base=753
	min_diff=2000
	
	for i in range(len(s) - 2):
		vv=int(s[i:i+3])
		min_diff = min(min_diff, abs(base-vv))

	print(min_diff)
	

	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
using namespace std;
void a(){
    int A,B; cin >> A >> B;

    int ans = 0;
    if (A > B){
        ans +=A;A--;
    } else {
        ans += B;
        B--;
    }

    if (A > B){
        ans +=A;A--;
    } else {
        ans += B;B--;
    }

 cout << ans;

}

void b(){

    int N; cin >> N;
    vector<int> H(N);
    for(int i = 0; i < N; i++){
        cin >> H[i];
    }

    int c = 0;
    int max_h = 0;
    for(int i = 0; i < N ;i++){

        if(max_h <= H[i]){
            c++;
            max_h = H[i];
        }
    }

    cout << c;

}

int main(){
    b();
    return 0;
}


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

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int a, b, c;
  cin >> a >> b >> c;

  cout << min(c, b / a) << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector> 
#define MN 201000

std::vector<int> v1[MN], v2[MN];
int dep[MN], fa[MN];
int Max = 0;

void dfs2(int x, int f)
{
	fa[x] = f; 
	for(auto y : v2[x]) 
	{
		if(y == f) continue;
		dep[y] = dep[x] + 1;
		dfs2(y, x);
	}
}

void dfs1(int x, int f, int t)
{
	if(dep[x] <= t) return;
	Max = std::max(Max, dep[x]);
	for(auto y : v1[x])
	{
		if(y == f) continue;
		if(fa[x] == fa[y] || fa[x] == y || fa[y] == x || fa[fa[x]] == y || fa[fa[y]] == x)
			dfs1(y, x, t + 1);
		else Max = 1e9;
	}
}

int main()
{
	int n, x, y; scanf("%d%d%d", &n, &x, &y);
	for(int i = 1; i < n; i++)
	{
		int u, v; scanf("%d%d", &u, &v);
		v1[u].push_back(v);
		v1[v].push_back(u);
	}
	for(int i = 1; i < n; i++)
	{
		int u, v; scanf("%d%d", &u, &v);
		v2[u].push_back(v);
		v2[v].push_back(u);
	}
	dfs2(y, 0); dfs1(x, 0, 0);
	if(Max >= 1e9) puts("-1");
	else printf("%d\n", 2 * Max);
} 

Measured memory_bytes: 38272
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        s: String,
    }

    let vc: Vec<char> = s.chars().collect();
    let mut ans = 0;
    let mut prev = vc[0];
    for i in 1..vc.len() {
        if vc[i] != prev {
            ans += 1;
            prev = vc[i];
        }
    }
    println!("{}", ans);
}


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

using namespace std;

int n;
vector<int> v;
int MAX = 1<<15;
int cnt[(1<<15) + 10], scnt[(1<<15) + 10], tcnt[(1<<15) + 10], fcnt[(1<<15) + 10];

void sqrs() {
	int p = sqrt(MAX);
	for (int i = 1; i <= p; i++) v.push_back(i * i);
	
	memset(cnt, 0, sizeof(cnt));
	int vsize = (int)v.size();
	for (int i = 0; i < vsize; i++) cnt[v[i]]++;
	
	memset(scnt, 0, sizeof(scnt));
	for (int i = 0; i < vsize; i++) {
		for (int j = i; j < vsize; j++) {
			if (v[i] + v[j] <= MAX) scnt[v[i] + v[j]]++;
		}
	}
	
	memset(tcnt, 0, sizeof(tcnt));
	for (int i = 0; i < vsize; i++) {
		for (int j = i; j < vsize; j++) {
			for (int k = j; k < vsize; k++) {
				if (v[i] + v[j] + v[k] <= MAX) tcnt[v[i] + v[j] + v[k]]++;
			}
		}
	}
	
	memset(fcnt, 0, sizeof(fcnt));
	for (int i = 0; i < vsize; i++) {
		for (int j = i; j < vsize; j++) {
			for (int k = j; k < vsize; k++) {
				for (int l = k; l < vsize; l++) {
					if (v[i] + v[j] + v[k] + v[l] <= MAX) fcnt[v[i] + v[j] + v[k] + v[l]]++;
				}
			}
		}
	}
}

int main() {
	sqrs();
	
	while (cin >> n, n) {
		int ans = 0;
		ans += cnt[n];
		ans += scnt[n];
		ans += tcnt[n];
		ans += fcnt[n];
		cout << ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1736
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}

int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    int sum = accumulate(a.begin(),a.end(),0);
    int s = 0;
    int ans = INT_MAX;
    show(sum);
    rep(i,n-1){
        s += a[i];
        ans = min(ans, abs(sum-s*2));
        show(s);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/*input
abc
arc
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}



int main()
{
	//IOS;
	string s,t;
	cin>>s>>t;
	int n=SZ(s);
	REP(i,n){
		bool f=1;
		for(int j=0;j<n;j++){
			if(s[j]!=t[(i+j)%n]) f=0;
		}
		if(f){
			cout<<"Yes\n";
			return 0;
		}
	}
	cout<<"No\n";

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
    #include <math.h>
     
     
    int main(void){
    	int x, h;
    	double side;
    	double bottom;
     
    	while( 1 ) {
    		scanf( "%d%d", &x, &h );
    		if( x == 0 && h == 0 ) break;
    		side = ( double ) ( x ) * sqrt( (double)( x * x / 4.0 ) + h * h ) ;
    		bottom = ( double ) ( x * x );
    		printf( "%.8lf\n", 2.0*side + bottom );
    	}
    	return 0;
    }

Measured memory_bytes: 1060
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,i,j,m,a,c,z;
int main(){
  cin>>n;z=n;if(n%2==1)n--;
  for(i=n;i>=0;i-=2){
    for(a=i,c=1;a>0&&a%2==0;c++,a/=2)if(c>m)z=i,m=c;
  }
  cout<<z<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int n,m; 
char a[45][45];
int tot[45][45];
int dp[45][45];

int sub(int x1, int y1, int x2, int y2)
{
	int ans=dp[x2][y2];
	if(x1) ans-=dp[x1-1][y2];
	if(y1) ans-=dp[x2][y1-1];
	if(x1&&y1) ans+=dp[x1-1][y1-1];
	return ans;
}

int f[45][45][45][45];

int calc(int x1, int y1, int x2, int y2)
{
	if(x1==0&&y1==0&&x2==n-1&&y2==m-1) return 0;
	if(f[x1][y1][x2][y2]!=-1) return f[x1][y1][x2][y2];
	int ans = int(1e9);
	for(int x3=x2+1;x3<n;x3++)
	{
		for(int y3=y2+1;y3<m;y3++)
		{
			ans=min(ans,calc(min(x3,x1),min(y3,y1),max(x3,x2),max(y3,y2))+sub(x1,y2+1,x2,y3)+sub(x2+1,y1,x3,y2));
		}
	}
	for(int x3=x2+1;x3<n;x3++)
	{
		for(int y3=0;y3<y1;y3++)
		{
			ans=min(ans,calc(min(x3,x1),min(y3,y1),max(x3,x2),max(y3,y2))+sub(x1,y3,x2,y1-1)+sub(x2+1,y1,x3,y2));
		}
	}
	for(int x3=0;x3<x1;x3++)
	{
		for(int y3=0;y3<y1;y3++)
		{
			ans=min(ans,calc(min(x3,x1),min(y3,y1),max(x3,x2),max(y3,y2))+sub(x3,y1,x1-1,y2)+sub(x1,y3,x2,y1-1));
		}
	}
	for(int x3=0;x3<x1;x3++)
	{
		for(int y3=y2+1;y3<m;y3++)
		{
			ans=min(ans,calc(min(x3,x1),min(y3,y1),max(x3,x2),max(y3,y2))+sub(x3,y1,x1-1,y2)+sub(x1,y2+1,x2,y3));
		}
	}
	return (f[x1][y1][x2][y2]=ans);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	memset(f,-1,sizeof(f));
	cin>>n>>m; int px=0; int py=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='P') px=i,py=j;
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			dp[i][j]=(a[i][j]=='#');
			if(i) dp[i][j]+=dp[i-1][j];
			if(j) dp[i][j]+=dp[i][j-1];
			if(i&&j) dp[i][j]-=dp[i-1][j-1];
		}
	}
	int ans = int(1e9);
	for(int x1=0;x1<n;x1++)
	{
		for(int y1=0;y1<m;y1++)
		{
			for(int x2=x1;x2<n;x2++)
			{
				for(int y2=y1;y2<m;y2++)
				{
					if(px>=x1&&px<=x2&&py>=y1&&py<=y2)
					{
						int ext = calc(x1,y1,x2,y2);
						int s2 = sub(x1,y1,px,py);
						s2 = min(sub(px,y1,x2,py),s2);
						s2 = min(sub(px,py,x2,y2),s2);
						s2 = min(sub(x1,py,px,y2),s2);
						//cerr<<x1<<' '<<y1<<' '<<x2<<' '<<y2<<' '<<ext<<' '<<s2<<'\n';
						ans=min(ans,s2+ext);
					}
				}
			}
		}
	}
	cout<<ans<<'\n';
}


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

vector<int> par;
vector<int> friends;
//UF
void init(const int &N){
  par.resize(N); friends.resize(N); //friend[i]は、root(i)が属する友好関係の人数を表す
  for(int i = 0; i < N; i++){ par[i] = i; friends[i] = 1; } 
  //自分自身はカウントしないように出力を調整
}

int root(const int &a){
  if( a == par[a] ){ return a;}
  else{ return par[a] = root(par[a]);}
}

bool issame(const int &a, const int &b){
  return root(a) == root(b);
}

void unite(const int &a, const int &b){
  if( issame(a,b) ){ return;}
  else{ 
    int s1 = friends[root(a)]; int s2 = friends[root(b)];
    par[root(a)] = root(b);
    friends[root(b)] = s1+s2;
  }
}


signed main(void){ 
  
  int n,m,k; cin >> n >> m >> k;
  
  init(n);
  vector<int> f(n);
  for(int i = 0; i < m; i++){ 
    int a,b; cin >> a >> b; a--; b--;
    f[a]++; f[b]++;
    unite(a,b);
  }
  
  vector<int> block(n,0);
  
  for(int i = 0; i < k; i++){ 
    int c,d; cin >> c >> d; c--; d--;
    if( issame(c,d) ) { block[c]++; block[d]++;}
  }
  
  for(int i = 0; i < n; i++){ cout << friends[root(i)]-1-f[i]-block[i]<< " ";}
  cout<< endl;
  
  return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){
    string S;
    cin >> S ;
    ll n ;
    ll ans = 0;
    if(S.size()%2 == 0){
        n = S.size() / 2;
        REP(i,n){
            if(S[i] != S[S.size()-1-i]){
                ans += 1;
            }
        }
    }
    else{
        n = S.size() / 2 + 1;
        REP(i,n-1){
            if(S[i] != S[S.size()-1-i]){
                ans += 1;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int sei(int a){
  return a>0 ? a : 0;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  int A,B,C;
  scanf("%d %d %d",&A,&B,&C);
  if(A+B >= C)printf("Yes");
  else printf("No");
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<queue>
#include<string>
#include<limits.h> 
#include<bitset> 
using namespace std;
int r,c;
bitset<10000>	arr[50];
//int arr[10][10000];
int res;
void dfs(int row){
	if(row==r){
		int num=0;
		int temp;
		for(int j=0;j<c;j++){
			temp=0;
			for(int i=0;i<r;i++){
					temp+=arr[i][j];
			}
			//取1表示该列不翻转，取0表示该列翻转 
			num=num+max(temp,r-temp);
		}
		res=max(res,num);
		return;
	}
	//翻转 
	arr[row].flip();
	dfs(row+1);
	//不反转 
	arr[row].flip();
	dfs(row+1);
}
int main(){
	while(scanf("%d%d",&r,&c)!=EOF){
		if(r==0&&c==0){
			break;
		}
		for(int i=0;i<r;i++){
			for(int j=0;j<c;j++){
				int x;
				scanf("%d",&x);
				arr[i].set(j,x);
			}
		}
		res=-1;
		dfs(0);
		printf("%d\n",res);
	}
	return 0;
} 


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

long long r,g,b,n,ans;

int main(){

	cin>>r>>g>>b>>n;
	
	for(int i=0;i<=3000;i++){
	    for(int j=0;j<=3000;j++){
	        
	        if(i*r+j*g<=n && (n-i*r-j*g)%b==0)ans++;
	        
        }
    }
    
    cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N;
	cin >> N;
	vector<char> A(N), B(N);
	REP(i, N)cin >> A[i];
	REP(i, N)cin >> B[i];
	reverse(B.begin(), B.end());

	map<pair<string,string>, int>mp;

	REP(i, 1 << N) {
		string S = "", T = "";
		REP(j, N) {
			if (i&(1 << j)) {
				S += A[j];
			}
			else {
				T += A[j];
			}
		}
		//cout << S << " " << T << endl;
		mp[make_pair(S, T)]++;
	}
	int ans = 0;
	REP(i, 1 << N) {
		string S = "", T = "";
		REP(j, N) {
			if (i&(1 << j)) {
				S += B[j];
			}
			else {
				T += B[j];
			}
		}
		//cout << S << " " << T << endl;
		ans += mp[make_pair(S, T)];
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 91904
from collections import deque

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

g = [[] for i in range(N)]

for _ in range(M):
  A, B = list(map(int, input().split()))
  g[A-1].append(B-1)
  g[B-1].append(A-1)

visited = [-1] * N
q = deque([0])

while q:
  p = q.popleft()
  for node in g[p]:
    if visited[node] == -1:
      visited[node] = p + 1
      q.append(node)

print ('Yes')
print ('\n'.join(map(str, visited[1:])))

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

int main(){
    int n,ans=0,cnt = 1;
    cin >> n;
    vector<ll> a(n),s(n);
    for(int i = 0;i < n;i ++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    for(int i = 0;i < n;i ++){
        s[i] = a[i] + (i?s[i-1]:0);
    }
    for (int i = n-1;i >= 1;i --){
        if(a[i-1]*2>=a[i]) cnt ++;
        else {
            ans += cnt;
            if(s[i-1]*2<a[i]) break;
            cnt = 1;
        }
        if(i==1) ans += cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cassert>
#include <vector>

int main()
{
  // Input
  int numChoice;
  int numStone;
  std::cin >> numChoice >> numStone;
  assert(1 <= numChoice and numChoice <= 100);
  assert(1 <= numStone and numStone <= 1.0e+5);
  std::vector<int> amount(1 + numChoice);
  for (int n = 1; n <= numChoice; ++n) {
    std::cin >> amount[n];
    assert(amount[n] >= ((n == 1) ? 1 : amount[n - 1]));
    assert(amount[n] <= numStone);
  }

  // Initialization and Initial condition
  std::vector<bool> dp(1 + numStone, false);

  // DP main
  for (int i = 0; i <= numStone; ++i) {
    for (int n = 1; n <= numChoice; ++n) {
      if (i + amount[n] > numStone)
        break;
      if (not dp[i])
        dp[i + amount[n]] = true;
    }
  }

  // Output
  std::string result = dp[numStone] ? "First" : "Second";
  std::cout << result << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int N[10000],E[10000],W[10000],S[10000],U[10000],D[10000];
  int n,i,sum;

  for(;;){
    scanf("%d", &n);
    if(n==0) break;

    N[0]=5,E[0]=3,W[0]=4,S[0]=2,U[0]=1,D[0]=6,sum=1;
  
    for(i=1;i<n+1;i++){
      char ope[10];
      scanf("%s", ope);
      if(strcmp(ope,"North")==0){
	U[i]=S[i-1],N[i]=U[i-1],S[i]=D[i-1],D[i]=N[i-1],E[i]=E[i-1],W[i]=W[i-1];
      }
      else if(strcmp(ope,"East")==0){
	U[i]=W[i-1],E[i]=U[i-1],W[i]=D[i-1],D[i]=E[i-1],N[i]=N[i-1],S[i]=S[i-1];
      } 
      else if(strcmp(ope,"West")==0){
	U[i]=E[i-1],E[i]=D[i-1],W[i]=U[i-1],D[i]=W[i-1],N[i]=N[i-1],S[i]=S[i-1];
      } 
      else if(strcmp(ope,"South")==0){
	U[i]=N[i-1],N[i]=D[i-1],S[i]=U[i-1],D[i]=S[i-1],E[i]=E[i-1],W[i]=W[i-1];
      } 
      else if(strcmp(ope,"Right")==0){
	N[i]=W[i-1],E[i]=N[i-1],W[i]=S[i-1],S[i]=E[i-1],U[i]=U[i-1],D[i]=D[i-1];
      } 
      else if(strcmp(ope,"Left")==0){
	N[i]=E[i-1],E[i]=S[i-1],W[i]=N[i-1],S[i]=W[i-1],U[i]=U[i-1],D[i]=D[i-1];
      } 
      sum=sum+U[i];
    }
    printf("%d\n", sum);
  }

  return 0;
}


Measured memory_bytes: 744
#!/mnt/c/Users/moiki/bash/env/bin/python
N = int(input())
import math 

num = 0
def f(st):
    global num
    if int(st) > N:
        return 
    else:
        if '3' in st and '5' in st and '7' in st:
            num += 1
    for c in '753':
        f(st + c)


f("0")
print(num)

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

int main() {
  string s, t; cin >> s >> t;
  cout << t << s << endl;
  return 0;
}


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

#define INFINITY 2147483647

void inItRMQ(int);
void update(int,int);
int findMin(int,int);
int query(int,int,int,int,int);
int min(int,int);
void initRMQ(int);

int n=1; // the size of target array
int D[2000000];

int main()
{
    int rn,q,i;
    int com,s,t;
    int ans[100000];
    int count=0;
    scanf("%d %d", &rn, &q);
    
    while(n<=rn){
        n = n*2;
    }

    for(i=0;i<(2*n-1-1);i++){
        D[i] = INFINITY;
    }
    
    for(i=0;i<q;i++){
        scanf("%d %d %d", &com, &s, &t);
        if(com==0) update(s,t);
        if(com==1){
            ans[count] = findMin(s,t);
            count++;
        }
    }

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

    return 0;
}

void update(int k, int a){
    k+=n-1;
    D[k]=a;
    while(k>0){
        k=(k-1)/2;
        D[k] = min(D[k*2+1],D[k*2+2]);
    }
}

// [a,b]
int findMin(int a,int b){
    return query(a,b+1,0,0,n);
}

// [a,b)
int query(int a,int b,int k,int l,int r){
    int vl,vr;
    //case1
    if(r<=a || b<=l) return INFINITY;

    //case2
    if(a<=l&&r<=b) return D[k];

    //case3
    vl = query(a,b,k*2+1,l,(l+r)/2);
    vr = query(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
}

int min(int x,int y){
    if(x<=y) return x;
    else return y;
}


Measured memory_bytes: 3076
n,q=map(int,input().split())
t=input()
a=[0]*n
for i in range(n-1):
    if t[i]=="A"and t[i+1]=="C":
        a[i]=a[i-1]+1
    else:a[i]=a[i-1]
for _ in range(q):
    l,r=map(int,input().split())
    l,r=l-1,r-2
    print(a[r]-a[l-1])

Measured memory_bytes: 11628
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import kotlin.math.min

object Solve {

  private val br = BufferedReader(InputStreamReader(System.`in`))
  private val out = PrintWriter(System.out)

  fun solve() {

    val s = br.readLine()!!
    val t = br.readLine()!!

    var ans = t.length

    for(shift in 0..(s.length-t.length)){
      var tmp = 0
      t.forEachIndexed{ idx, c ->
        if(c != s[idx+shift]) tmp++
      }
      ans = min(ans, tmp)
    }

    out.println(ans)
    out.flush()
  }
}

fun main(args: Array<String>) {
  Solve.solve()
}

Measured memory_bytes: 34308
solve :: [Int] -> [Int] -> [Int] -> Int -> [Int]
solve [] ls rs i
  | even i = ls ++ reverse rs
  | otherwise = rs ++ reverse ls
solve (x:xs) ls rs i
  | odd i = solve xs (x:ls) rs (i+1)
  | otherwise = solve xs ls (x:rs) (i+1)

main :: IO ()
main = do
  _ <- read <$> getLine :: IO Int
  as <- map read.words <$> getLine :: IO [Int]
  putStrLn $ unwords $ map show $ solve as [] [] 1


Measured memory_bytes: 121724
#from math import *
from collections import *
from random import *
from bisect import *
import sys
input=sys.stdin.readline
def lis():
    return list(map(int,input().split()))
def ma():
    return map(int,input().split())
def inp():
    return int(input())
n=inp()
s=input().rstrip('\n')
x=s.count('R')
if(x==0 or x==n):
    print(0)
    exit(0)
ind=[]
for i in range(n):
    if(s[i]=='R'):
        ind.append(i)
r=0
for i in range(x):
    if(s[i]=='R'):
        continue
    r+=1
print(r)
            

        
            
        
    
        
    


Measured memory_bytes: 89324
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
vector<int> v;
int main() {
	int n; ll s; cin >> n >> s;
	ll x[100000]; ll p[100000];
	rep(i, n) {
		cin >> x[i] >> p[i];
	}
	int j, k; j = 0; k = n - 1;
	while (j < k) {
		if (p[j] < p[k]) {
			p[k] += p[j];
			if (s > x[j]) {
				v.push_back(j);
			}
			j++;
		}
		else if (p[j] >= p[k]) {
			p[j] += p[k];
			if (s < x[k]) {
				v.push_back(k);
			}
			k--;
		}
	}
	v.push_back(j);
	int len = v.size();
	ll sum = 0; ll now = s;
	per(i, len) {
		sum += abs(x[v[i]] - now);
		now = x[v[i]];
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N;
    string S;
    cin >> N >> S;

    bool flag = true;
    if (N % 2 == 0) {
        int index = N / 2;
        rep(i, index) {
            if (S[i] != S[i + index]) {
                flag = false;
                break;
            }
        }
    }
    else flag = false;

    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

string divided[4] = {"dream", "dreamer", "erase", "eraser"};

int main () {
    string S;
    cin >> S;

    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; i++) reverse(divided[i].begin(), divided[i].end());

    bool can = true;
    for (int i = 0; i < S.size();) {
        bool can2 = false;
        for (int j = 0; j < 4; j++) {
            string d = divided[j];
            if (S.substr(i, d.size()) == d) {
                can2 = true;
                i += d.size();
            }
        }
        if (!can2) {
            can = false;
            break;
        }
    }

    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;


}

Measured memory_bytes: 512
house = [[[0 for i in range(10)]for j in range(3)]for k in range(4)]
n = int(raw_input())
for i in range(n):
  a = raw_input().split()
  house[int(a[0])-1][int(a[1])-1][int(a[2])-1] += int(a[3])
for i in range(4):
  if i != 0:
    print "#"*20
  for j in range(3):
    line = ""
    for k in range(10):
      line += " " + str(house[i][j][k])
    print line

Measured memory_bytes: 6472
/*  -*- coding: utf-8 -*-
 *
 * 2833.cc: Displayed tweets
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100000;
const int INF = 1 << 30;

/* typedef */

typedef pair<int,int> pii;

/* global variables */

int rts[MAX_N], rns[MAX_N], ds[MAX_N];

/* subroutines */

/* main */

int main() {
  int n, k;
  scanf("%d%d", &n, &k);

  for (int i = 0; i < n; i++) {
    int ai;
    scanf("%d", &ai);
    ai--;

    rts[i] = ai;
    if (ai >= 0) rns[ai]++;
    ds[i] = INF;
  }

  queue<pii> q;
  for (int i = 0; i < n; i++)
    if (rns[i] == 0) {
      ds[i] = 0;
      q.push(pii(i, -1));
    }

  int cnt = 0;
  while (! q.empty()) {
    pii u = q.front(); q.pop();
    int &ui = u.first, &up = u.second;
    int &vi = rts[ui];

    if (ds[ui] < k || vi < 0) cnt++;

    if (vi >= 0) {
      int vd = ds[ui] + 1;
      if (ds[vi] > vd) ds[vi] = vd;
      if (--rns[vi] == 0) q.push(pii(vi, ui));
    }
  }

  printf("%d\n", cnt);
  return 0;
}



Measured memory_bytes: 4628
#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 pair<ll, ll> pll;

typedef vector<int> va;
typedef vector<int> vb;
typedef vector<int> vc;

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 DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG_ARRY(v, n) REP(i, n) cout << " " << v[i]
#define DEBUG_VEC(v)                                                           \
  cout << #v << ":";                                                           \
  REP(i, v.size()) cout << " " << v[i];                                        \
  cout << endl
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a = min((a), (b))
#define CHMAX(a, b) a = max((a), (b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a) % MOD + MOD) % MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(a, b) (abs(a - b) < EPS)
typedef complex<Real> P;

int main() {
  int a, b, res = 0;
  cin >> a >> b;
  REP(i, 2) {
    if (a >= b) {
      res += a;
      a--;
    } else {
      res += b;
      b--;
    }
  }
  cout << res << endl;
  return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if (a > (a + b + 1) / 2 || b > (a + b + 1) / 2) {
    cout << ":(" << endl;
  } else {
    cout << "Yay!" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)  //0index
#define rep1(i,n) for (int i = 1; i < (n); ++i)  //1index
#define REP(i,a,b) for (int i = a; i < (b); ++i)  //aからb - 1まで
#define mREP(i,a,b) for (int i = a; i > (b); --i)  //逆
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;  //最大値兼MOD
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int main(){
  int a;
  cin >> a;
  a %= 7;
  if(a == 0)cout << "thu" << endl;
  else if(a == 1)cout << "fri" << endl;
  else if(a == 2)cout << "sat" << endl;
  else if(a == 3)cout << "sun" << endl;
  else if(a == 4)cout << "mon" << endl;
  else if(a == 5)cout << "tue" << endl;
  else cout << "wed" << endl;
  return 0;
}


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

using namespace std;

#define eb emplace_back
#define ii pair<int, int>
#define OK (cerr << "OK" << endl)
#define debug(x) cerr << #x " = " << (x) << endl
#define ff first
#define ss second
#define int long long
#define tt tuple<int, int, int>
#define all(x) x.begin(), x.end()
#define vvi vector<vector<int>>
#define vvii vector<vector<pair<int, int>>>
#define Mat(n, m, v) vector<vector<int>>(n, vector<int>(m, v))
#define endl '\n'

constexpr int INF = 2e18;
constexpr int MOD = 1e9 + 7;
constexpr int MAXN = 2e5 + 3;

// #define MULTIPLE_TEST_CASES
void solve() {

  string s;
  cin >> s;

  int ans = 0;
  for (char c : s) {
    ans += (c - '0');
  }

  cout << (ans % 9 == 0 ? "Yes" : "No") << endl;
}

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

  int t = 1;
#ifdef MULTIPLE_TEST_CASES
  cin >> t;
#endif
  while (t--)
    solve();
}

Measured memory_bytes: 3780
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

    static int N;
    static int K;
    static int[] A;

    public static void main(String[] args) {
        FastScanner sc = new FastScanner(System.in);
        N = sc.nextInt();
        K = sc.nextInt();
        A = sc.nextIntArray(N);

        System.out.println( solve() ? "POSSIBLE" : "IMPOSSIBLE" );
    }

    static boolean solve() {
        for (int a : A) {
            if( a == K ) return true;
        }

        int gcd = gcd(A);
        return existsAbove() && K % gcd == 0;
    }

    static boolean existsAbove() {
        for (int a : A) {
            if( a > K ) return true;
        }
        return false;
    }

    static int gcd(int[] A) {
        int ret = A[0];
        for (int i = 1; i < N; i++) {
            ret = gcd(ret, A[i]);
        }
        return ret;
    }

    static int gcd(int a, int b) {
        while (b > 0) {
            int c = a;
            a = b;
            b = c % b;
        }
        return a;
    }

    @SuppressWarnings("unused")
    static class FastScanner {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        int[] nextIntArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = nextInt();
            return a;
        }

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


Measured memory_bytes: 35032
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n;cin>>n;
	ll ans=0;
	for(ll t=1;t*t<=n;t++){
		if(n%t==0){
			ll m = (n/t-1);
			if(m!=0 && n/m == n%m) {
				ans+=m;
			}
			m = (t-1);
			if(m!=0 && n/m == n%m) {
				ans+=m;
			}
		}
	}
	cout<<ans<<endl;











	
}

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

ll v[105],w[105],dp[105][100005];

int main() {
  int N,W;
  cin>>N>>W;

  for (int i=0; i<N; i++) {
    scanf("%lld %lld",w+i,v+i);
  }

  for (int i=0; i<N; i++) {
    for (int sum_w=0; sum_w<=W; sum_w++) {
      if (sum_w-w[i]>=0)
	dp[i+1][sum_w]=max(dp[i][sum_w-w[i]]+v[i],dp[i+1][sum_w]);
      dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w]);
    }
  }

  cout<<dp[N][W]<<endl;
  return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> t(N);
    vector<int> x(N);
    vector<int> y(N);
    rep(i,N){
        cin >> t[i] >> x[i] >> y[i];
    }
    bool possible = true;
    if (x[0] + y[0] > t[0] || (x[0] + y[0]) % 2 != t[0] % 2){
        possible = false;
    }
    rep(i,N - 1){
        if ((max(x[i + 1] - x[i], x[i] - x[i + 1]) + max(y[i + 1] - y[i], y[i] - y[i + 1])) > t[i + 1] - t[i] || (max(x[i + 1] - x[i], x[i] - x[i + 1]) + max(y[i + 1] - y[i], y[i] - y[i + 1])) % 2 != (t[i + 1] - t[i]) % 2){
            possible = false;
        }
    }
    if (possible) cout << "Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 1408
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let x = read(&mut stdin_lock, &mut buf, b'\n');
    println!("{}", solve(x));
}

fn solve(x: u8) -> String {
    if x == 7 || x == 5 || x == 3 {
        "YES".to_owned()
    } else {
        "NO".to_owned()
    }
}

#[test]
fn example1() {
    assert_eq!("YES", solve(5))
}

#[test]
fn example2() {
    assert_eq!("NO", solve(6))
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return 1; } return 0; }
int dx[] = { 0, 0, -1, 1 };
int dy[] = { 1, -1, 0, 0 };
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	rep(i, 100) {
		C = C - B;
		if (C < 1) Yes;
		A = A - D;
		if (A < 1) No;
	}

	return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
#define MODULO 1000000007
#define PI 3.14159265359
typedef long long int ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
	
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll max=-1000000000000000000;
	if(max<(a*c))
	max=(a*c);
	if(max<(a*d))
	max=(a*d);
	if(max<(b*c))
	max=(b*c);
	if(max<(b*d))
	max=(b*d);
  
	cout<<max;
   return 0;
}


Measured memory_bytes: 3648