akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

vector<long long> fac;
vector<long long> fac_inv;
vector<long long> inv;

void init_combination(long long n, long long mod)
{
	fac.resize(n+1);
	fac_inv.resize(n+1);
	inv.resize(n+1);
	fac[0] = 1;
	fac[1] = 1;
	fac_inv[0] = 1;
	fac_inv[1] = 1;
	inv[1] = 1;
	for (long long i = 2; i <= n; i++) {
		fac[i] = fac[i-1]*i%mod;
		inv[i] = mod - (inv[mod%i] * (mod / i)) % mod;
		fac_inv[i] = fac_inv[i-1] * inv[i] % mod;
	}
}

long long modcomb(long long n, long long r, long long mod)
{
	if (n < r)
		return 0;
	long long result = fac[n]%mod;
	result *= (fac_inv[r] * fac_inv[n-r]) % mod;
	result %= mod;
	return result;
}
int main(void)
{
	const long long p = (long long)1e9+7;
	int x, y;
	cin >> x >> y;
	if ((2*y-x)%3 != 0 || (2*x-y)%3 != 0) {
		cout << 0 << endl;
		return 0;
	}

	int a = (2*y-x)/3;
	int b = (2*x-y)/3;
	if (a < 0 || b < 0) {
		cout << 0 << endl;
		return 0;
	}

	init_combination(a+b, p);
	cout << modcomb(a+b, a, p) << endl;

	return 0;
}

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

int main(){

	int n, m;
	while (std::cin >> n >> m){
		if (n == 0 && m == 0)break;

		std::vector<int>p(m, 0);
		for (int i = 0; i < n; i++){
			for (int j = 0; j < m; j++){
				int a;
				std::cin >> a;
				if (a == 1)p[j]++;
			}
		}

		bool f = true;
		for (int i = n; i >= 0; i--){
			for (int j = 0; j < m; j++){
				if (p[j] == i){
					if (f){
						std::cout << j + 1;
						f = false;
					}
					else std::cout << " " << j + 1;
				}
			}
		}
		std::cout << std::endl;

	}

	return 0;
}

Measured memory_bytes: 1196
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAX_N 100000
 
int main(){
    int N,a[MAX_N];
    scanf("%d",&N);
    for(int i=0;i<N;i++)scanf("%d",&a[i]);

    sort(a,a+N);

    int b=1;
    
    for(int i=0;i<N-1;i++)
      if(a[i]!=a[i+1])b++;

    int c[b],j=0,x=0,y=0,d[b];
    for(int i=0;i<b;i++)c[i]=1;

    while(j<b){
      d[j]=a[x];
      for(int i=x;i<N-1;i++){
        if(a[i]==a[i+1])c[j]++;
        else{
          x=i+1;
          break;
        }
      }
      j++;
    }

    for(int i=0;i<b;i++){ 
    if(c[i]>d[i])y = y+c[i]-d[i];
    else if(c[i]<d[i])y+=c[i];
    }
    printf("%d",y);
    return 0;
}

Measured memory_bytes: 1280
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def solve():
    a, b, x = map(int, input().split())
    hoge = b // x
    huga = (a-1) // x
    print(hoge-huga)
    return 0

if __name__ == "__main__":
    solve()

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

typedef long long ll;
typedef pair<int,int> P;
typedef unsigned int uint;
typedef vector<int> VI;
typedef vector<double> VD;
typedef vector<vector<int> > VV;

const int INF = 1 << 28;
const double EPS = 1e-9;

int n;
VV par;
VD x, y, r;
VI c;
map<int,int> m;

string toString (int era) {
    string str;
    for (int i = 0; i < n; i++) {
        str = (era % 2 ? "1" : "0") + str;
    }

    return str;
}

int dfs (int era) {
    if (era == ((1 << n) - 1)) return 0;
    int cera = ((1 << n) - 1) ^ era;
    if (m.find(cera) != m.end()) {
        return m[cera];
    }
    
    VV count(5);
    rep (i,n) {
        bool flag = true;
        if (era & (1 << i)) continue; 
        rep(j,par[i].size()) {
            if (cera & (1 << par[i][j])) {
                flag = false;
                break;
            }
        }
        if (flag) {
            count[c[i]].push_back(i);
        }
    }

    int ret = 0;
    REP(i,1,5) {
        if (count[i].size() >= 2) {
            rep(j,count[i].size()-1) REP(k,j+1,count[i].size()) {
                int tera = era;
                tera |= (1 << count[i][j]);
                tera |= (1 << count[i][k]);
                ret = max(ret, dfs(tera) + 2);
            }
        }
    }

    return m[cera] = ret;
}

int main()
{
    while (cin >> n, n) {
        x.resize(n), y.resize(n), r.resize(n), c.resize(n);
        m.clear();
        
        rep(i, n) {
            cin >> x[i] >> y[i] >> r[i] >> c[i];
        }
        
        par.clear();
        par.resize(n);
        rep(i,n) rep(j,i) {
            double dis = pow(x[i] - x[j], 2.) + pow(y[i] - y[j], 2.);
            if (sqrt(dis) < r[i] + r[j]) {
                par[i].push_back(j);
            }
        }

        cout << dfs(0) << endl;
    }
                
    return 0;
}

Measured memory_bytes: 50444
#155_B
n = int(input())
a = list(map(int, input().split()))

judge = True
for i in range(n):
    if a[i]%2 == 0:
        if a[i]%3 != 0 and a[i]%5 != 0:
            judge = False
            break

if judge:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
vector<int>adj[2003];
int dis[2003], res[2003];
queue<int>q;
int main()
{
    int n, x, y;
    scanf("%d %d %d", &n, &x, &y);
    adj[x].push_back(y);
    adj[y].push_back(x);
    for(int i=1; i<n; i++)
    adj[i].push_back(i+1),
    adj[i+1].push_back(i);
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)dis[j]= n;
        dis[i]= 0;
        q.push(i);
        while(!q.empty())
        {
            x= q.front();
            q.pop();
            for(int j=0; j<adj[x].size(); j++)
            {
                y= adj[x][j];
                if(dis[y]>dis[x]+1)
                dis[y]= dis[x]+1, q.push(y);
            }
        }
        for(int j=1; j<=n; j++)res[ dis[j] ]++;
    }
    for(int i=1; i<n; i++)printf("%d\n", res[i]/2);
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <numeric>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	string s;
	cin >> s;
	int k;
	if (s=="SUN") {
		k = 7;
	}
	else if(s == "SAT") {
		k = 1;
	}
	else if (s == "FRI") {
		k = 2;
	}
	else if (s == "THU") {
		k = 3;
	}
	else if (s == "WED") {
		k= 4;
	}
	else if (s == "TUE") {
		k = 5;
	}
	else if (s == "MON") {
		k = 6;
	}
	
	cout <<k << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, D, A = map(int, input().split())
XH = [list(map(int, input().split())) for _ in range(N)]
XH.sort(key = lambda x:x[0])
X = [XH[i][0] for i in range(N)]
ans = 0
res = 0
from bisect import bisect_left
cnt = [0]*(N+1)
for i in range(N):
    x, h = XH[i]
    res-=cnt[i]
    h-=res
    if h<=0:
        continue
    n = ((h-1)//A+1)
    j = bisect_left(XH, [x+D*2+1, -1])
    cnt[j] += n*A
    res += n*A
    ans+=n
print(ans)
    





Measured memory_bytes: 96348
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <stdio.h>
#include <queue>
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define inf 1001001001000
#define mod 1000000007
using namespace std;
int main(void){
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll ans = 0;
    rep(j,60){
        ll count = 0;
        rep(i,n) if(a[i]>>j&1) count++;
        ll now = ((n-count)*count)%mod;
        rep(i,j) now = (now*2)%mod;
        ans = (ans+now)%mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int read() {
	int x = 0, f = 1; char ch;
	while(! isdigit(ch = getchar())) (ch == '-') && (f = -f);
	for(x = ch ^ 48; isdigit(ch = getchar()); x = (x << 3) + (x << 1) + (ch ^ 48));
	return x * f;
}
template <class T> T Max(T a, T b) { return a > b ? a : b; }
template <class T> T Min(T a, T b) { return a < b ? a : b; }
int n;
int main() {
	n = read();
	if((n & (n - 1)) == 0) return puts("No"), 0;
	puts("Yes"); puts("1 2"); puts("2 3");
	printf("%d %d\n", 3, n + 1); printf("%d %d\n", n + 1, n + 2); printf("%d %d\n", n + 2, n + 3);
	for(int i = 4, j; i + 1 <= n; i += 2) {
		j = i + 1;
		printf("%d %d\n", 1, i); printf("%d %d\n", i, j + n);
		printf("%d %d\n", 1, j); printf("%d %d\n", j, i + n);
	}
	if(n % 2 == 0) {
		for(int i = 4, j; i <= n; ++ i) {
			j = n ^ i ^ 1;
			if(j == 3 || j >= n) continue;
			printf("%d %d\n", i, n); printf("%d %d\n", j, 2 * n);
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 2304
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<algorithm>
#include<cstdio>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int bm = 3010;
ll BIT[bm];
void add(int A, ll B) {
	while (A <= bm) {
		BIT[A] = max(BIT[A], B);
		A += A & -A;
	}
}
ll query(int A) {
	ll kotae = 0;
	while (A > 0) {
		kotae = max(BIT[A], kotae);
		A -= A & -A;
	}
	return kotae;
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

ll V[200000], tmp[200000];

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


	int R = getint(), C = getint(), K = getint();

	rep(i, K) {
		ll r = getint(), c = getint(), v = getint();
		V[i] = v << 30 | r << 12 | c;
	}

	const int b = 12;
	int kazu[1 << b] = {}, kazu2[1 << b] = {};
	rep(i, K) kazu[V[i] & ((1 << b) - 1)]++;
	rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
	for (int i = K - 1; i >= 0; i--) tmp[--kazu[V[i] & ((1 << b) - 1)]] = V[i];
	rep(i, K) kazu2[tmp[i] >> b & ((1 << b) - 1)]++;
	rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
	for (int i = K - 1; i >= 0; i--) V[--kazu2[tmp[i] >> b & ((1 << b) - 1)]] = tmp[i];

	int mae = -1;
	ll A[4] = {};
	ll L[3001];
	int l = 0;
	rep(k, K) {
		int v = V[k] >> 30;
		int i = V[k] >> 12 & 4095;
		int j = V[k] & 4095;
		if (mae != i) {
			mae = i;
			A[0] = 0;
			A[1] = 0;
			A[2] = 0;
			A[3] = 0;
			rep(a, l) add(L[a] & 4095, L[a] >> 12);
			l = 0;
		}
		ll kari = query(j);
		A[0] = kari;
		chmax(A[3], kari);
		chmax(A[2], kari);
		chmax(A[1], kari);
		chmax(A[3], A[2] + v);
		chmax(A[2], A[1] + v);
		chmax(A[1], A[0] + v);
		L[l++] = A[3] << 12 | j;
	}

	rep(a, l) add(L[a] & 4095, L[a] >> 12);
	ll kotae = query(C);

	printf("%lld\n", kotae);

	Would you please return 0;
}

Measured memory_bytes: 6564
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n; string s,t;
    cin>>n>>s>>t;
    if(s==t){cout<<n<<endl; return 0;}
    else{
        int ans=n;
        rep(i,n){
            if(s==t){
                break;
            }
            else{
                ans--;
                s=s.substr(1);
                t.pop_back();
            }
        }
        cout<<2*n-ans<<endl;
    }
}


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

int main() {

  int a[3];
  for (int i = 0; i<3; i++) cin >> a[i];
  sort(a,a+3,greater<int>());
  if (a[0] == 7 && a[1] == 5 && a[2] == 5) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
N=int(input())

k=10**9+7
def njou(x,n):

    ans=1
    for i in range(n):
        ans=ans*x
        if ans>k:
            ans=ans%k
    return(int(ans))
print((njou(10,N)+njou(8,N)-2*njou(9,N))%k)

Measured memory_bytes: 9184
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    double d = sc.nextDouble();
    int count =0;
    for(int i=0;i<n;i++){
      int a = sc.nextInt();
      int b = sc.nextInt();
      double f = Math.sqrt(Math.pow(a,2)+Math.pow(b,2));
      if(f<=d){
        count++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 60244
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
using namespace std;
typedef long long LL;
int dx[5] = {1, 0, -1, 0, 0};
int dy[5] = {0, 1, 0, -1, 0};

const int MAX_T = 10 * 30 / 4;

int W, H;
string grid[30];
char memo[30][30][30][30][MAX_T];
bool valid(int x, int w) {
    return 0 <= x && x < w;
}
int dfs(int x1, int y1, int x2, int y2, int t) {
    //printf("%d %d %d %d %d %c %c\n", x1, y1, x2, y2, t, grid[y1][x1], grid[y2][x2]);
    if(t >= MAX_T) return 2;
    char& res = memo[y1][x1][y2][x2][t];
    if(res != -1) return res;

    if(y1 == y2 && x1 == x2) return res = 1;

    int turn = t % 2;
    if(turn == 0) {
        if(grid[y1][x1] == 'E') return res = 0;

        bool draw = false;
        REP(r, 5) {
            int nx = x1 + dx[r];
            int ny = y1 + dy[r];
            if(valid(nx, W) && valid(ny, H) && grid[ny][nx] != '#') {
                int check = dfs(nx, ny, x2, y2, t + 1);
                if(check == 0) {
                    return res = 0;
                } else if(check == 2) {
                    draw = true;
                }
            }
        }
        return res = (draw ? 2 : 1);
    } else {
        bool draw = false;
        REP(r, 5) {
            int nx = x2 + dx[r];
            int ny = y2 + dy[r];
            if(valid(nx, W) && valid(ny, H) && grid[ny][nx] != '#') {
                int check = dfs(x1, y1, nx, ny, t + 1);
                if(check == 1) {
                    return res = 1;
                } else if(check == 2) {
                    draw = true;
                }
            }
        }
        return res = (draw ? 2 : 0);
    }
}

int main(){
    while(cin >> W >> H && W > 0){
        REP(y, H) cin >> grid[y];
        int x1 = -1, y1 = -1, x2 = -1, y2 = -1;
        REP(y, H) REP(x, W) if(grid[y][x] == 'Q') x1 = x, y1 = y;
        REP(y, H) REP(x, W) if(grid[y][x] == 'A') x2 = x, y2 = y;

        memset(memo, -1, sizeof(memo));
        int ans = dfs(x1, y1, x2, y2, 0);
        if(ans == 0) {
            cout << "Queen can escape." << endl;
        } else if(ans == 1) {
            cout << "Army can catch Queen." << endl;
        } else {
            cout << "Queen can not escape and Army can not catch Queen." << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 60540
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

using namespace std;

int main(void)
{
  long long int n,k,count = 0;
  cin >> n >> k;
  
  if(n <= k)
  {
    cout << 0;
    return 0;
  }
  
  vector<long long int> h(n);
  for(int i = 0; i < n; i++)
  {
    cin >> h[i];
  }
  
  sort(h.begin(),h.end());
  
  for(int i = 0; i < k; i++)
  {
    h.pop_back();
  }
  
  for(int i = 0; i < h.size();i++)
  {
    count += h[i];
  }
  
  cout << count;
  
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

ll f[200005], g[200005];

ll c(int n, int m) {
    return f[n + m - 2] * g[n - 1] % mod * g[m - 1] % mod;
}

int main() {
    ios::sync_with_stdio(false);
    int n, m, a, b;
    ll z = 0;
    f[0] = 1; g[200000] = 750007460;
    cin >> n >> m >> a >> b;
    for (int i = 1; i <= 200000; i++) f[i] = f[i - 1] * i % mod;
    for (int i = 199999; i >= 0; i--) g[i] = g[i + 1] * (i + 1) % mod;
    for (int i = 1; i <= n - a; i++) z = (z + c(i, b) * c(n - i + 1, m - b)) % mod;
    cout << z;
}


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

const int MAXN = 2005;

bitset<MAXN*MAXN> st;

int n, a[MAXN];

int main()
{
	scanf("%d", &n);
	int sum = 0;
	st[0] = 1;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		st = st|(st<<a[i]);
		sum += a[i];
	}
	int cnt = 0;
	int tot = (st.count()+2)/2;
	for (int i = 0; i <= sum; i++) {
		cnt += st[i];
		if (cnt == tot) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int r;
    scanf("%d", &r);
    if(r < 1200) printf("ABC\n");
    else if(1200 <= r && r < 2800) printf("ARC\n");
    else printf("AGC\n");
    return 0;
}

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

const int maxn = 110;
int n;
int a[maxn],cnt[maxn];

bool yes(int mx)
{
	if(cnt[mx] == 1) return 0;
	cnt[mx] = 0;
	int cur = mx - 1,i = 0;
	while(cur >= (mx+1)/2)
	{
		if(!(mx&1) && cur == (mx+1)/2)
		{
			if(cnt[cur] < 1) return 0;
			cnt[cur]--;
			cnt[cur+1] = 0;
		}
		else
		{
			if(cnt[cur] < 2) return 0;
			cnt[cur] -= 2;
			cnt[cur+1] = 0;
		}
		--cur;
	}
	for(int i=1;i<=mx;++i) if(cnt[i]) return 0;
	return 1;
}

int main()
{
	scanf("%d",&n);
	int mx = 0;
	for(int i=0;i<n;++i) scanf("%d",a+i),cnt[a[i]]++,mx = max(mx,a[i]);
	puts(yes(mx)?"Possible":"Impossible");
	return 0;
}

Measured memory_bytes: 256
n=int(input())
arr1=[input() for _ in range(n)]
m=int(input())
arr2=[input() for _ in range(m)]
max=0
for i in range(n):
  tmp=arr1.count(arr1[i])-arr2.count(arr1[i])
  if tmp>max:
    max=tmp
print(max)

Measured memory_bytes: 3064
#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<ll, ll>;

int main(){
    int h,w,a,b;
    cin >> h >> w >> a >> b;
    rep(i,h){
        rep(j,w){
            if(i<b){
                if(j<a)printf("%c", '0');
                else printf("%c", '1');
            }else{
                if(j<a)printf("%c", '1');
                else printf("%c", '0');
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a, cont = 1;
    scanf("%d", &a);
    printf("Case %d: %d\n", cont, a);
    while(a != 0)
    {
        scanf("%d", &a);
        cont += 1;
        if (a != 0)
        {
            printf("Case %d: %d\n", cont, a);
        }
    }

return 0;
}


Measured memory_bytes: 2024
#include<bits/stdc++.h>
using namespace std;
string a="6 7 8 9 5 4 3 2 1 0 1 2 3 4 5 6 7 8 9 5 4 3 2";
main(){
  int n,s,t,i,j;
  cin>>n;
  while(n--){
    cin>>s>>t;
    for(i=0;s!=a[i]-'0';i++);
    for(j=i;t!=a[j]-'0';j++)if(a[j]-'0'==s)i=j;
    cout<<a.substr(i,j-i+1)<<endl;
  }
}

Measured memory_bytes: 3068
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

int main(){
	
	int m;
	cin>>m;
	vector<int>vis(m);

	int cur = 0,ret = -1;

	for(int i=0; ;i++){
		cur = (cur * 10 + 7) %m;
		if(vis[cur]){
			break;
		}
		vis[cur] = true;
		if(cur == 0){
			ret = i+1;
			break;
		}
	}

	cout<<ret<<endl;
	

	return 0;
}

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

int main() {
    int N;
    cin >> N;
    int h[N];
    long dp[N];
    for(int i=0; i<N; i++){
        cin >> h[i];
    }

    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for(int i=2; i<N; i++){
        dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i] - h[i-2]));
    }

    cout << dp[N-1] << endl;
}

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

int main()
{
    int n;
    cin >> n;
    int h[n];
    for (int i = 0; i < n; i++) cin >> h[i];

    int cnt = 0, cnt_mx = 0;

    for (int i = 1; i < n; i++) {
        if (h[i - 1] < h[i]) {
            cnt_mx = max(cnt_mx, cnt);
            cnt = 0;
        }
        else {
            cnt++;
        }
    }
    cnt_mx = max(cnt, cnt_mx);
    cout << cnt_mx << "\n";
}


Measured memory_bytes: 640
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,gcd;
int GCD(int a,int b){
	return a? GCD(b%a,a):b;
}
int main(){
	scanf("%d",&n);
	for(int i=0,num;i<n;i++)
		scanf("%d",&num),
		gcd=gcd? GCD(gcd,num):num;
	printf("%d\n",gcd);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
W = [0 for _ in range(N)]
for i in range(N):
    W[i] = input()
W_set = set(W)
        
for i in range(N - 1):
    # print(W[i][-1:])
    if W[i][-1:] != W[i + 1][0]:
        print('No')
        break
    elif len(W_set) != len(W):
        print('No')
        break
    else:
        if i == N - 2:
            print('Yes')


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

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}"<<endl;
  return o;
}

//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
  long long b = m, u = 1, v = 0;
  while (b) {
    long long t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m; 
  if (u < 0) u += m;
  return u;
}
ll const mod = 1e9+7;

// combination
const int MAX = 510000;
const ll MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int H,W,K;
  cin >> H >> W >> K;
  vector<vector<char>> C(H,vector<char> (W));
  rep(i,H) rep(j,W) {
    cin >> C[i][j];
  }
  int ans=0,cnt=0;

  rep(i,1<<H){
    rep(j,1<<W) {
      cnt = 0;
      rep(x,H) rep(y,W) {
        // if (y==0) cout << endl;
        
        if (((i>>x)&1)==0 && ((j>>y)&1)==0) {
          // cout << x << ',' << y << endl;
          if (C[x][y]=='#') cnt++;
        }
      }
      if (cnt==K) ans++;
      // cout << i << ' ' << j << ' ' << ans << endl;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
A,B,C,K = map(int,input().split())
s = 0
if A <= K:
    s += A*1
    K = K-A
else:
    s += K*1
    K = 0
    
if B <= K:
    s += B*0
    K = K-B
else:
    s += K*0
    K = 0
    
if C >= K:
    s += K*(-1)
else:
    s += C*(-1)
    
print(s)

Measured memory_bytes: 9192
n = 0
S = 0
xylst = []
while True:
    try:
        x, y = map(float, input().split(','))
        xylst.append([x,y])
        n += 1


    except EOFError:
        break


for i in range(-1, n-1):
    S = S + abs(xylst[i][0]*xylst[i+1][1] - xylst[i][1]*xylst[i+1][0])/2

print(S)


Measured memory_bytes: 5584
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define ll long long int
#define ull unsigned long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mod 1000000007
int main()
{
    fast;
    int n,k;
    cin>>n>>k;
    int a[n+2]; 
    for(int i=0;i<n;i++)cin>>a[i];
    int dp[n+3]={0};
    for(int i=n-2;i>=0;i--)
    {
        dp[i]=INT_MAX;
        for(int j=1;j<=k && (i+j)<n;j++)
        {            
            dp[i]=min(dp[i],dp[i+j]+abs(a[i]-a[i+j]));
        }
    }
    cout<<dp[0]<<"\n";
return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a, b; cin >> a >> b;
    for (int i = 1; i <= 10000; i++) {
        int p = i * 8;
        int q = i * 10;
        if (p / 100 == a && q / 100 == b) {
            cout << i << "\n";
            return 0;
        }
    }
    cout << -1 << "\n";
    return 0;
}

Measured memory_bytes: 256
(let* ((n (read))
    (k (read))
    (ans (make-array (list n))))

    (loop for i below n do
        (setf (aref ans i) (list (read) (read)))
    )
    (setf ans (sort ans #'< :key #'car))

    (loop for i below n do
        (if (> k (second (aref ans i)))
            (decf k (second (aref ans i)))
            (progn
                (decf k (second (aref ans i)))
                (princ (car (aref ans i)))
                (return)
            )
        )
    )
)

Measured memory_bytes: 80816
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    set<char> s;
    char a, b, c;
    cin >> a >> b >> c;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    if (s.size() == 3) cout << "Yes"; else cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int input;
	int min = 10000000,max = -10000000;
	long sum = 0;
	int i,n;

	scanf("%d",&n);

	for(i = 0; i < n;i++){
		scanf("%d",&input);
		if(input < min) min = input;
		if(input > max) max = input;

		sum = sum + input;
	}

	printf("%d %d %ld\n",min,max,sum);

	return 0;
}

Measured memory_bytes: 1832
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

int main()
{
  int n,a[20000],m,ans;
  m=0;
  ans=0;
  cin >> n;
  rep(i,n)cin >> a[i];
  rep(i,n)m=max(m,a[i]);
  rep(i,n)ans+=a[i];
  printf("%d",ans-m/2);
}

Measured memory_bytes: 256
local mce, mfl, msq, mmi, mma = math.ceil, math.floor, math.sqrt, math.min, math.max
local n = io.read("*n")
local a, b = {}, {}
for i = 1, n do
  a[i] = io.read("*n")
  b[i] = a[i]
end
table.sort(b)
local m1, m2 = b[n], b[n - 1]
for i = 1, n do
  if a[i] == m1 then
    print(m2)
  else
    print(m1)
  end
end


Measured memory_bytes: 5888
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  ll X,Y;
  cin >> X >> Y;
  ll n = X;
  int ans = 0;
  while(n<=Y) {
    ans++;
    n *= 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a<=b){
		if (a<=c){
			if (b<=c){
				cout << a << " " << b << " " << c << "\n";
			}
			else{
				cout << a << " " << c << " " << b << "\n";
			}
		}
		else cout << c << " " << a << " " << b << "\n";
	}else if (a<=c){
		cout << b << " " << a << " " << c << "\n";
	}
	else if (b<=c){
		cout << b << " " << c << " " << a << "\n";
	}else cout << c << " " << b << " " << a << "\n";
	cin >> a;
}



Measured memory_bytes: 3104
N = int(input())
h = list(map(int,input().split()))

dp = [10000000]*(N)
dp[0]=0
for i in range(1,N):
  if i==1:
  	dp[i]=abs(h[i]-h[i-1])
  else:
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))

print(dp[-1])

Measured memory_bytes: 20572
($A,$B)=glob<>;
@_=(map([('.')x100],1..50),map([('#')x100],1..50));
for$y(0..24){
	for$x(0..49){
		if(--$B>0){
			$_[$y*2][$x*2]='#';
		}
	}
}
for$y(25..49){
	for$x(0..49){
		if(--$A>0){
			$_[$y*2+1][$x*2]='.'
		}
	}
}
print"100 100\n";
print@$_,$/for@_


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD=1000000007;
using namespace std;
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
int gcd (int x, int y) {
    if (x < y) swap(x, y);
    if (y == 0) return x;
    return gcd(x % y, y);
}
int lcm (int x, int y) {
    return x/gcd(x, y)*y;
}

int main(){
    int n;
    cin>>n;
    vector<double> v(n);
    rep(i,0,n) cin>>v.at(i);
    sort(all(v));
    
    double ans=v.at(0);
    rep(i,1,n){
        ans=(ans+v.at(i))/2;
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;
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; }

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

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

    llong N;
    cin >> N;

    vecllong V(N);
    FOR(i, N) {
        cin >> V[i];
    }

    vvecllong count(2, vecllong(100100, 0));
    FOR(i, N) {
        count[i % 2][V[i]]++;
    }

    llong maxIndex[2] = {0, 0};
    FOR(i, 100100) {
        if(count[0][maxIndex[0]] < count[0][i]) {
            maxIndex[0] = i;
        }
        if(count[1][maxIndex[1]] < count[1][i]) {
            maxIndex[1] = i;
        }
    }

    llong ans = 0;
    if(maxIndex[0] != maxIndex[1]) {
        ans = N - count[0][maxIndex[0]] - count[1][maxIndex[1]];
    } else {
        llong even = N - count[0][maxIndex[0]];
        llong odd = N - count[1][maxIndex[1]];
        count[0][maxIndex[0]] = 0;
        count[1][maxIndex[1]] = 0;
        maxIndex[0] = 0;
        maxIndex[1] = 1;
        FOR(i, 100100) {
            if(count[0][maxIndex[0]] < count[0][i]) {
                maxIndex[0] = i;
            }
            if(count[1][maxIndex[1]] < count[1][i]) {
                maxIndex[1] = i;
            }
        }
        ans = min(
            even - count[1][maxIndex[1]],
            odd - count[0][maxIndex[0]]
        );
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3456
/*

 Remember, Hope is a good thing... May be the best of things... and No Good thing ever Dies !!!

*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define IOS ios::sync_with_stdio(0); cout.tie(0);
#define endl "\n"
#define MOD 1000000007
const ll inf=(1LL<<60)-1;
int dx[]= {-1,1,0,0};
int dy[]= {0,0,-1,1};
void solve()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    string s;
    cin>>s;
    ll mul=0;
    for(ll i=0;i<s.size();i++)
    {
        mul+=s[i]-'0';
    }
    if(mul%9==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}
int main()
{
    IOS;
    //ll t;
    //cin>>t;
    //while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3760
fun main(args: Array<String>) {
    val S = readLine()!!
    var n = S.length
    var ans = S.length
    var prev = S[0]
    for ((k, c) in S.withIndex()) {
        if (c != prev) {
            var t = arrayOf(k, n - k).max()!!
            ans = arrayOf(ans, t).min()!!
        }
        prev = c
    }
    println(ans)
}


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

typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll,ll> lll;

const ll MOD = 1000000007;
const ll INF = 1e9+5;
const double eps = 1e-7;
const double PI = acos(-1.0);

#define FOR(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
#define RFOR(i,a,b) for(long long i = (long long)(a); i >= (long long)(b); i--)
#define ull unsigned long long
#define deb(x )     cerr << #x << " = "<< x << endl;
#define endl    "\n"
#define coud(a,d) cout << fixed << showpoint << setprecision(d) << a;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define fill(x, y) memset(x, y, sizeof(y))
#define all(x) (x).begin(), (x).end()
#define bitcount(x) __builtin_popcount(x)
#define cps CLOCKS_PER_SEC

inline void debug_vi(vi a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void debug_vll(vll a) {FOR(i, 0, a.size()) cout<<a[i]<<" ";}
inline void print_case(int tn) {cout<<"Case #"<<tn<<": ";}

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;

template<typename T>
using maxpq = priority_queue<T>;
/*----------------------------------------------------------------------*/

int main(){
    std::ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    clock_t clk = clock();

    int n; cin>>n;
    vi arr(n);
    FOR(i, 0, n) cin>>arr[i];
    int res = 0;
    FOR(i, 0, n) {
        FOR(j, i+1, n) {
            res += arr[i]*arr[j];
        }
    }
    cout<<res;
    cerr << endl << "Time (in ms): " << double(clock() - clk) * 1000.0 / cps << endl;
    return 0;
}

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


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

	vector<ll> A(N), B(N);
	for(auto& e : A) {
		cin >> e;
	}
	for (auto& e :B) {
		cin >> e;
	}

	priority_queue<ll> que;
	int ans = 0;
	ll need = 0;
	for(int i=0;i<N;i++) {
		if(B[i] < A[i]) {
			que.emplace(A[i] - B[i]);
		}else if(B[i] > A[i]) {
			need += B[i] - A[i];
			ans++;
		}
	}

	ll gain = 0;
	while(gain < need && !que.empty()) {
		gain += que.top();
		que.pop();
		ans++;
	}

	if(gain < need) {
		cout << -1 << endl;
	}else {
		cout << ans << endl;
	}

	return 0;
}


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

#define inf 2000000009
#define ff first 
#define ss second 
#define ll long long 

int main(){
	int n; cin>>n; 
	int a[n]; 
	vector<int> dist(n,0); 
	for(int i=0;i<n;i++){cin>>a[i]; }
		int ans=0; 
	for(int i=0;i<n-1;i++){
		if(dist[i]==1) continue; 
		if(a[i]==a[i+1]){
			ans++; 
			dist[i+1]=1; 
		}

	}
	cout<<ans; 


}

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

using namespace std;

#define lli long long int
#define scin(x) scanf("%lld",&x)

lli dp[2][200005],profit[2000005],val[2000005],w[2000005],knapsack_weight,items;

lli bottomup(void)
{
    lli ans;
    for(int i=1; i<=items; i++)
    {
        for(int j=1; j<=knapsack_weight; j++)
        {
            if(i%2==1)
            {
                if(w[i]<=j)
                {
                    ans=dp[1][j]=max(dp[0][j],dp[0][j-w[i]]+profit[i]);
                }
                else
                {
                   ans= dp[1][j]=dp[0][j];
                }
            }
            else
            {
                if(w[i]<=j)
                {
                    ans=dp[0][j]=max(dp[1][j],dp[1][j-w[i]]+profit[i]);
                }
                else
                {
                    ans=dp[0][j]=dp[1][j];
                }
            }
        }
    }
    return ans;
}

int main()
{
    scin(items),scin(knapsack_weight);
    for(int i=1; i<=items; i++)
    {
        scin(w[i]),scin(profit[i]);
    }
    lli ans = bottomup();
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6400
#include <stdio.h>
int main(void)
{
	int e,y,i;
	scanf("%d %d",&e,&y);
	if(e==0){
		if(y>=1868 && y<=1911){
			i=y-1867;
			printf("M%d\n",i);
		}
		if(y>=1912 && y<=1925){
			i=y-1911;
			printf("T%d\n",i);
		}
		if(y>=1926 && y<=1988){
			i=y-1925;
			printf("S%d\n",i);
		}
		if(y>=1989 && y<=2016){
			i=y-1988;
			printf("H%d\n",i);
		}
	}
	if(e==1){
		i=y+1867;
		printf("%d\n",i);
	}
	if(e==2){
		i=y+1911;
		printf("%d\n",i);
	}
	if(e==3){
		i=y+1925;
		printf("%d\n",i);
	}
	if(e==4){
		i=y+1988;
		printf("%d\n",i);
	}
	return 0;
}


Measured memory_bytes: 2048
#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() {
    ll n, a, b; cin >> n >> a >> b;
    vector<ll> x(n);
    rep(i, n) cin >> x[i];
    ll ans = 0;
    rep(i, n-1) {
        ans += min((x[i+1]-x[i])*a, b);
    }
    cout << ans;
}


Measured memory_bytes: 1024
#include <cstdio>
using namespace std;

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

//     	1   2   3   4   5
//    1   2   3   4   5
//  1   2   3   4   5

int W, H;
int map[200][200];
int s[200][200];

void Search(int i, int j)
{
	s[i][j] = 0;
	
	for (int d = 0; d < 6; d++){
		if (s[i + dy[d]][j + dx[d]] && map[i + dy[d]][j + dx[d]] == 0){
			Search(i + dy[d], j + dx[d]);
		}
	}
}

int main()
{
	scanf("%d %d", &W, &H);
	
	for (int i = 2; i <= H + 1; i++){
		for (int j = 2 + i / 2; j <= W + 1 + i / 2; j++){
//			printf("%d %d:", j, i);
			scanf("%d", &map[i][j]);
		}
	}
	
	for (int i = 1; i < W + H; i++){
		for (int j = 1; j < W + H; j++){
			s[i][j] = 1;
		}
	}
	
	Search(1, 1);
	
	int sum = 0;
	for (int i = 0; i < 200; i++){
		for (int j = 0; j < 200; j++){
			if (s[i][j]){
				int cnt = 0;
				for (int d = 0; d < 6; d++){
					cnt += s[i + dy[d]][j + dx[d]];
				}
				
				sum += (6 - cnt);
			}
		}
	}
	
	printf("%d\n", sum);
	
	return 0;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()

template<typename T>
T mod(T a, T b){
    return (a + b) % b;
}

template<typename T>
T gcd(T a, T b){
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

// n を素因数分解
map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    if (n > 1) {
        mp[n]++;
    }

    return mp;
}

// 文字列に "hoge" が含まれているか
// string str = "hogepiyo";
// if (str.find("hoge") != string::npos) {
//     cout << "文字列が含まれています" << endl;
// }

// char to string
// char c = 'a';
// string str = {c};

void solve(){
    int A, B;
    cin >> A >> B;

    cout << 6 - (A+B) << endl;

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 301
using namespace std;
typedef complex <double> P;
const double EPS = 1e-8;
P p[N];
int n;

int cnt(P c){
  int res=0;
  for(int i=0;i<n;i++)if(abs(c-p[i])<1+EPS) res++;
  return res;
}

P get_C(P a,P b){
  double x=abs(b-a);
  if(x>2||a==b) return a;
  return P(x/2,sqrt(1-x*x/4))*(b-a)/abs(b-a)+a;  
}


int main(){
  while(1){
  cin>>n;
  if(!n)break;
  double a,b;
  for(int i=0;i<n;i++)cin>>a>>b,p[i]=P(a,b);
  
  int ans=0;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      ans=max(ans,cnt(get_C(p[i],p[j])));
  cout <<ans<<endl;  
  }
  return 0;
}

Measured memory_bytes: 3296
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

const int INF=100000000;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
using namespace std;
typedef pair<int ,int > P;
typedef long long ll;

void add(vector<P> &segs,int a,int b) {
    if(b<a) swap(a,b);
    bool f=true;
    rep(i,segs.size()) {
        if(!((b<segs[i].fr)||(segs[i].sc<a))) {
            segs[i].fr=min(segs[i].fr,a);
            segs[i].sc=max(segs[i].sc,b);
            f=false;
        }
    }
    if(f) segs.pb(P(a,b));
}
int N,m;


int main() {
    vector<P> segs,in;
    cin>>N>>m;
    rep(i,m) {
        int c,d;
        cin>>c>>d;
        in.pb(P(c,d));
    }
    sort(all(in));
    ll ans=0;
    rep(i,m) {
        add(segs,in[i].fr,in[i].sc);
    }

    rep(i,segs.size()) {
        //printf("%d %d\n",segs[i].fr,segs[i].sc);
        ans+=(segs[i].sc-segs[i].fr)*2;
    }
    ans+=N+1;
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    char ch;
    bool four = false;
    rep(i, n){
        cin >> ch;
        if(ch == 'Y'){
            four = true;
            break;
        }
    }
    cout << (four ? "Four\n" : "Three\n");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
char line[100000];
int min(int a, int b)
{
	if (a <= b)
		return a;
	else
		return b;
}
int main()
{
	long n,k;
	long i;
	long sum;
	cin >> n;
	cin >> k;
	for (i = 0; i < n; i++)
	{
		cin >> line[i];
	}
	int m = 0;
	for (i = 0; i < n - 1; i++)
	{
		if (line[i] != line[i + 1])
			m++;
	}
			sum = n - 1 - m + 2 * k;
		sum = min(sum, (n - 1));
	cout << sum;
	return 0;
}

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

using namespace std;

int main()
{
    int n, k;    
    cin >> n >> k;
    int a[n+1];
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
     
    for (int i = k + 1; i <= n; i++) {
        if (a[i - k] < a[i]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4424
package main

import (
	"fmt"
	"sort"
)

func main() {
	n := readInt()
	vec := make([]int, 0)
	for i := 0; i < n; i++ {
		vec = append(vec, readInt())
	}
	// vec := readIntLine()

	// copy
	cpVec := make([]int, len(vec))
	copy(cpVec, vec)
	sort.Ints(cpVec)

	left := cpVec[n/2-1]
	right := cpVec[n/2]

	for _, v := range vec {
		if v <= left {
			fmt.Println(right)
		} else if v >= right {
			fmt.Println(left)
		} else {
			fmt.Println("ERR")
		}
	}

	// fmt.Println(n)
	// fmt.Println(vec)
	// fmt.Println(cpVec)
}

func readInt() int {
	var a int
	fmt.Scan(&a)
	return a
}

// func readIntLine() []int {
// 	var sc = bufio.NewScanner(os.Stdin)
// 	sc.Scan()
// 	line := sc.Text()
// 	vals := strings.Split(line, " ")
// 	vec := make([]int, 0)
// 	for _, v := range vals {
// 		// n, err := strconv.ParseInt(v, 10, 64)
// 		n, err := strconv.Atoi(v)
// 		if err != nil {
// 			panic(err)
// 		}
// 		vec = append(vec, n)
// 	}
// 	return vec
// }


Measured memory_bytes: 10240
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))  # 整数のリスト
    B = [0] * N

    for j in range(min(K, 41)):
        for i in range(N):
            l = max(0, i-A[i])
            r = min(N-1, i+A[i])
            B[l] += 1
            if r+1 < N: B[r+1] -= 1
        for i in range(1,N):
            B[i] += B[i-1]
        A = B
        B = [0] * N

    for i in A:
        print(i, end=" ")

if __name__ == '__main__':
    main()


Measured memory_bytes: 147312
N = int(input())
S = 0
 
for i in range(1, N+1):
    if i % 3 == 0 and i % 5 == 0:
        i = "FizzBuzz"
    elif i % 3 == 0:
        i = "Fizz"
    elif i % 5 == 0:
        i = "Buzz"
    else:
        S += i
 
print(S)


Measured memory_bytes: 9112
S = input()

x1 = int(S[0:2])
x2 = int(S[2:4])

if 1 <= x1 <= 12:
    month1 = True
else:
    month1 = False

if 1 <= x2 <= 12:
    month2 = True
else:
    month2 = False

if month1 and month2:
    out = "AMBIGUOUS"
elif month1 and (not month2):
    out = "MMYY"
elif (not month1) and month2:
    out = "YYMM"
else:
    out = "NA"

print(out)

Measured memory_bytes: 3064
from math import factorial

N, K = map(int, input().split())

modulo = 10 ** 9 + 7

def C(n, m):
    return factorial(n) // factorial(m) // factorial(n - m) if n >= m else 0

for i in range(1, K + 1):
    # 赤玉と赤玉の間 N - K + 1 箇所からi個選ぶ
    s = C(N - K + 1, i) % modulo

    # 青玉 K個をi箇所に分ける (仕切りの置き方)
    t = C(K - 1, i - 1) % modulo
    print(s * t % modulo)


Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;

int main()
{
  int n,max,p,q;
  max=0;
  cin>>n;
  vector<int> a(n);
  vector<int> aa(n);
  for(int i=0;i<n;i++)
  {
    cin>>a.at(i);
    if(max<a.at(i))
    {
      max=a.at(i);
      p=i;
    }
  }
  for(int i=0;i<n;i++)
  {
    aa.at(i)=a.at(i);
  }
  sort(aa.begin(),aa.end());
  reverse(aa.begin(),aa.end());
  for(int i=0;i<n-1;i++)
  {
    if(aa.at(i)!=aa.at(i+1))
    {
      q=aa.at(i+1);
      break;
    }
  }
  if(aa.at(0)==aa.at(1))
  {
    for(int i=0;i<n;i++)
    {
      cout<<max<<endl;
    }
  }
  else
  {
    for(int i=0;i<n;i++)
    {
      if(i!=p)
        cout<<max<<endl;
      else
        cout<<q<<endl;
    }
  }
}

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

ll lcm(ll a, ll b){
    ll g = gcd(a, b);
    return a / g * b;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ac = (a-1)/c, bc = b/c;
    ll ad = (a-1)/d, bd = b/d;
    ll l = lcm(c, d);
    ll acd = (a-1)/l, bcd = b/l;
    ll ans = (bc + bd - bcd) - (ac + ad - acd);
    ans = b - a + 1 - ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3616
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
using namespace std;
const int MAXN=100000;
int a[MAXN+5],x[MAXN+5],y[MAXN+5],vis[MAXN+5];
int n,m,ans;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)
		scanf("%d%d",&x[i],&y[i]);
	for(int i=1;i<=n;i++)
		a[i]=1;
	vis[1]=1;
	for(int i=1;i<=m;i++)
	{
		if(vis[x[i]])
		{
			vis[y[i]]=1;
			if(a[x[i]]==1)
				vis[x[i]]=0;
		}
		a[x[i]]--;
		a[y[i]]++;
	}
	for(int i=1;i<=n;i++)
		if(vis[i])
			ans++;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 1792