akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>

typedef long long ll;
using namespace std;

ll MOD = 1e9 + 7;

int main() {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;

    vector<ll> dp(26);
    dp[s[0] - 'a'] = 1;
    for (int i = 1; i < n - 1; i++) {
        ll now = dp[t[i] - 'a'];
        dp[s[i] - 'a'] += now;
        dp[s[i] - 'a'] %= MOD;
    }

    cout << dp[t[n - 1] - 'a'] << endl;
    return 0;
}


Measured memory_bytes: 3268
N = int(input())
l =[0]*5
for i in range(N):
    s = input()
    if s[0] =='M':
        l[0] += 1
    elif s[0] =="A":
        l[1] += 1
    elif s[0] =="R":
        l[2] += 1
    elif s[0] =="C":
        l[3] += 1
    elif s[0] =="H":
        l[4] += 1
print(l[0]*(l[1]*(l[2]+l[3]+l[4]) + l[2]*(l[3]+l[4]) + l[3]*l[4]) +l[1]*(l[2]*(l[3]+l[4])+l[3]*l[4])+l[2]*l[3]*l[4])

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int mod = 1000000007;

int main(){
    int n;
    cin>>n;
    ll ans=0,b;
    vector<ll> a(n,0);
    rep(i,n){
        cin>>a[i];
        a[i] -= i+1;
    }
    sort(a.begin(),a.end());
    b=a[n/2];
    rep(i,n) ans+=abs(a[i]-b);
    cout<<ans<<endl;
}


Measured memory_bytes: 1920
import java.util.Scanner;

class Main
{
	public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int [] side = new int[3];
		
		for (int i = 0; i < n; i++){
			for (int j = 0; j < 3; j++){
				side[j] = stdIn.nextInt();
			}
			if (side[0] > side[2]){
				int tmp = side[0];
				side[0] = side[2];
				side[2] = tmp;
			}
			if (side[1] > side[2]){
				int tmp = side[1];
				side[1] = side[2];
				side[2] = tmp;
			}
			
			if (side[0] * side[0] + side[1] * side[1] == side[2] * side[2]){
				System.out.println("YES");
			}
			else {
				System.out.println("NO");
			}
		}
	}
}

Measured memory_bytes: 23400
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    long long a, b, x;
    cin >> a >> b >> x;

    long long ans;
    if (a == 0)ans = b / x + 1;
    else ans = b / x - (a - 1) / x;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    n,m = map(int,input().split())
    a = list(map(int,input().split()))
    dic = {}
    for i in range(n):
        if a[i] not in dic.keys():
            dic[a[i]] = 1
        else:
            dic[a[i]] += 1
    for i in range(m):
        b,c = map(int,input().split())
        if c not in dic.keys():
            dic[c] = b
        else:
            dic[c] += b
    cnt = 0
    ans = 0
    for k in sorted(dic.keys(),reverse=True):
        if cnt + dic[k] < n:
            ans += dic[k]*k
            cnt = cnt + dic[k]
        else:
            ans += k *(n-cnt)
            print(ans)
            return

if __name__ == "__main__":
    main()


Measured memory_bytes: 34336
#include <algorithm>
#include <iostream>
#include <utility>
using namespace std;

int main() {
	int W, H, N, x, y, a;
	cin >> W >> H >> N;
	pair<int, int> b(0, H), c(0, W);
	for (int i = 0; i < N; ++i) {
		cin >> x >> y >> a;
		switch (a) {
		case 1:
			c.first = max(c.first, x);
			break;
		case 2:
			c.second = min(c.second, x);
			break;
		case 3:
			b.first = max(b.first, y);
			break;
		case 4:
			b.second = min(b.second, y);
		}
	}
	cout << max(0, b.second - b.first) * max(0, c.second - c.first);
}

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

int main() {
    int n, q; cin >> n;
    vector<int> S(n);
    rep(i,n){
        cin >> S[i];
    }
    cin >> q;
    vector<int> T(q);
    rep(i,q){
        cin >> T[i];
    }

    int ans = 0;
    rep(i,q){
        rep(j,n){
            if(T[i] == S[j]){
                ans++;
                break;
            }
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 3120
#include <iostream>
using namespace std;
#define REP(x,n) for(int i = x;i < n;i++)

int main(){
    int n;
    cin >> n;
    bool types[4] = {false};
    REP(0,n) {
        char tmp;
        cin >> tmp;
        if (tmp == 'P')
            types[0] = true;
        else if (tmp == 'W')
            types[1] = true;
        else if (tmp == 'G')
            types[2] = true;
        else 
            types[3] = true;
    }
    int cnt = 0;
    REP(i,4) if(types[i]) cnt++;
    cout << ((cnt == 3) ? "Three" : "Four") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//repetition
//------------------------------------------
#define FOR(i, p, b) for (int i = (p); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \<< " " << __FILE__ << endl;

int main() {
    int N;
    string S;
    bool flag = false;
    cin >> N;

    int i = 0;
    REP(i, N) {
        cin >> S;
        if (S == "Y") {
            flag = true;
        }
    }

    if (flag) {
        cout << "Four" << endl;
    } else {
        cout << "Three" << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    map<int, int> mp;

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int k;
        cin >> k;
        mp[k]++;
    }

    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
        int k;
        cin >> k;
        mp[k]--;
    }

    bool chk = true;
    for (auto f : mp) {
        if (f.second < 0) chk = false;
    }

    cout << (chk ? "YES\n" : "NO\n");

}


Measured memory_bytes: 12952
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	set<int> S;
	int s;
	cin >> s;
	S.insert(s);
	int prev = s;
	for (int i = 2; i <= 1000000; i++) {
		int now;
		if (prev % 2 == 0) now = prev / 2;
		else now = prev * 3 + 1;
		if (S.find(now) != S.end()) {
			cout << i << endl;
			break;
		}
		S.insert(now);
		prev = now;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define all(x) begin((x)), end((x))
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { a = b; return true;}
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) { a = b; return true;}
    return false;
}


int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    vector<ll> place;
    rep(i,n) {
        cin>>a[i];
        a[i]--;
    }
    place.push_back(0);
    ll now = 0;
    vector<bool> checked(n,false);
    checked[0] = true;
    ll loop;
    while(true) {
        ll next = a[now];
        if (checked[next]) {
            loop = next;
            break;
        }
        place.push_back(next);
        checked[next] = true;
        now = next;
    }
    ll loop_cur = 0;
    while(place[loop_cur]!=loop) {
        loop_cur++;
    }
    // cout << "place: ";
    // for(auto x:place) {
    //     cout << x << " ";
    // }
    if (k<place.size()) {
        cout << place[k]+1 << endl;
    }
    else {
        // cout << "cursor " << (k-loop_cur) % (place.size()-loop_cur) + loop_cur << endl;
        cout <<  place[(k-loop_cur) % (place.size()-loop_cur) + loop_cur]+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 6784
#include <stdio.h>

#define MAP(a, b, c, d, e, f) {\
	{a-1, b-1, c-1, d-1, e-1, f-1},\
	{a-1, c-1, e-1, b-1, d-1, f-1},\
	{a-1, e-1, d-1, c-1, b-1, f-1},\
	{a-1, d-1, b-1, e-1, c-1, f-1},\
}
int dice_map[6][4][6] = {
	MAP(1, 2, 3, 4, 5, 6),
	MAP(2, 3, 1, 6, 4, 5),
	MAP(3, 6, 5, 2, 1, 4),
	MAP(4, 2, 1, 6, 5, 3),
	MAP(5, 1, 3, 4, 6, 2),
	MAP(6, 5, 3, 4, 2, 1),
};
#undef MAP

struct dice {
	int label[6];
};

void
read_dice(struct dice *a)
{
	for (int i = 0; i < 6; i++)
		scanf("%d", &a->label[i]);
}

int
main(void)
{
	struct dice a[2] = {};
	struct dice m[6 * 4];
	int i, j, k;
	int yes = 0;

	read_dice(&a[0]);
	read_dice(&a[1]);

	for (i = 0; i < 6; i++)
		for (j = 0; j < 4; j++)
			for (k = 0; k < 6; k++) {
				int p = dice_map[i][j][k];
				m[i * 4 + j].label[k] = a[0].label[p];
			}

	for (i = 0; i < 6 * 4; i++) {
		for (j = 0; j < 6; j++)
			if (a[1].label[j] != m[i].label[j])
				break;
		if (j == 6) {
			yes = 1;
			break;
		}
	}

	printf("%s\n", yes ? "Yes" : "No");

	return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const ll MOD = 1e9+7;
ll LLINF = 1LL << 60;
int INF = INT_MAX;

int main(){
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,0,n) cin>>a[i];
    vector<ll> l(n);
    vector<ll> r(n);
    l[0]=a[0];
    rep(i,0,n-1){
        l[i+1]=__gcd(l[i],a[i+1]);
    }
    r[n-1]=a[n-1];
    for(ll i=n-1; i>=1; i--){
        r[i-1]=__gcd(r[i],a[i-1]);
    }
    ll ans=0;
    rep(i,0,n){
        ll temp;
        if(i==0){
            temp=r[1];
        }else if(i==n-1){
            temp=l[n-2];
        }else{
            temp=__gcd(l[i-1],r[i+1]);
        }
        ans=max(ans,temp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
l, r = gets.split.map(&:to_i)

answer = 2019
(l..(r - 1)).each do |i|
  ((i + 1)..r).each do |j|
    res = i * j % 2019
    answer = res if res < answer
    break if answer == 0
  end
  break if answer == 0
end

puts answer

Measured memory_bytes: 3836
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

string s, t;

int main() { 

  getline(cin, s);
  while (sz(t) < sz(s)) {
    t += "hi";
  }

  if (t == s) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		for (int j = i + 1; j <= n; ++j)
			if (i + j != n + 1 - n % 2) ++m;
	printf("%d\n", m);
	for (int i = 1; i <= n; ++i)
		for (int j = i + 1; j <= n; ++j)
			if (i + j != n + 1 - n % 2) {
				printf("%d %d\n", i, j);
			}
}


Measured memory_bytes: 256
n, k = map(int, input().split())
s = list(input())
cnt = 0
tmp = s[0]
t = 0
for i in range(1, n):
    if tmp == s[i]:
        continue
    else:
        cnt += 1
        tmp = s[i]
c = 0
for i in range(1, n):
    if s[i] == s[i-1]:
        c += 1
if cnt <= 2*k:
    print(n-1)
else:
    print(c + 2*k)

Measured memory_bytes: 72828
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#define all(x) (x).begin(), (x).end()
#define xx first
#define yy second

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int parent[1005];
vector<int> child[1005];
int table[1005];
int table2[1005][5005];
int value[1005];

int dp2(vector<ii>& arr, int idx, int remain)
{
	if (remain < 0)
		return 5000005;

	if (idx == arr.size())
		return 0;

	if (table2[idx][remain] != -1)
		return table2[idx][remain];

	int& res = table2[idx][remain];

	res = min(arr[idx].xx + dp2(arr, idx + 1, remain - arr[idx].yy), 
		arr[idx].yy + dp2(arr, idx + 1, remain - arr[idx].xx));

	return res;
}

int dp1(int root)
{
	if (child[root].empty())
		return 0;

	if (table[root] != -1)
		return 0;

	int& res = table[root];

	vector<ii> arr;
	for (int i = 0; i < child[root].size(); i++)
		arr.emplace_back(value[child[root][i]], dp1(child[root][i]));

	for(int i =0; i < child[root].size();i++)
		memset(table2[i], -1, sizeof(int) * 5005);

	res = dp2(arr, 0, value[root]);

	return res;
}

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

	for (int i = 2; i <= n; i++)
	{
		scanf("%d", &parent[i]);
		child[parent[i]].push_back(i);
	}

	for (int i = 1; i <= n; i++)
		scanf("%d", &value[i]);

	memset(table, -1, sizeof(table));

	if (dp1(1) >= 5000005)
		printf("IMPOSSIBLE\n");
	else
		printf("POSSIBLE\n");

	return 0;
}

Measured memory_bytes: 19840
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

string s;

int main(){
	cin>>s;
	s="0"+s+"0";
	int n=s.size(),res=n-2;
	for(int i=1;i<n;i++) if(s[i-1]!=s[i]) res=min(res,max(i-1,n-i-1));
	cout<<res<<endl;
}

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

#define ll long long int
#define pb push_back


int main(){
	int k;
	cin >> k;
	string s;
	cin >> s;
	if( s.size() <= k){
		cout << s << '\n';
	}else{
		cout << s.substr(0, k) << "...\n";
	}
}


Measured memory_bytes: 3624
//0020 Capitalize
//ツ禿シツ療債つウツづェツつスツ閉カツ篠堋療アツづーツ、ツ渉ャツ閉カツ篠堋づ債妥・ツ閉カツ篠堋づ可陛渉環キツつオツつスツ閉カツ篠堋療アツづーツ出ツ療債つケツづヲ
//ツづ按つィツ閉カツ篠堋療アツづ可づ債アツδ仰フツァツベツッツトツ、ツ板シツ角ツスツペツーツスツ、ツピツδ環オツドツつェツ甘慊づ慊づェツづゥ

#include<iostream>
#include<string>
#include<cctype>
using namespace std;

int main(void)
{
	string str;
	getline(cin, str);

	for(int i = 0; i < str.size(); i++)
	{
		if(islower(str[i]))
			str[i] = toupper(str[i]);
	}

	cout << str << endl;

	return 0;
}

Measured memory_bytes: 0
<?php
list($N, $M, $Q) = array_map(function ($n) {
    return (int)$n;
}, explode(' ', fgets(STDIN)));

$pair = [];
for ($i = 0; $i < (int)$Q; $i++) {
    list($a, $b, $c, $d) = array_map(function ($n) {
        return (int)$n;
    }, explode(' ', fgets(STDIN)));
    // if ($c < $b - $a) {
    $pair[$i] = [$a, $b, $c, $d];
    // }
}

$ans = 0;
dfs([0, 1]);
echo $ans;

function dfs($A) {
    global $N, $M, $pair, $ans;
    if (count($A) === $N + 1) {
        $point = 0;
        foreach ($pair as [$a, $b, $c, $d]) {
            $point += $A[$b] - $A[$a] === $c ? $d : 0;
            $ans = max($ans, $point);
        }
    } else {
        for ($i = $A[count($A) - 1]; $i <= $M; $i++) {
            $A[] = $i;
            $ans = max($ans, dfs($A));
            array_pop($A);
        }
    }
    return $ans;
}

Measured memory_bytes: 16288
// 標準入力
var fs = require('fs'),
length = fs.fstatSync(process.stdin.fd).size,
buffer = new Buffer(length),
bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
 
// ここから
function main(){
  for(var line = 1, maxLines = input[0] - 0; line <= maxLines; line++){
    var inputArray = input[line].split(" ").sort(function(a,b){return a-b});
    var longest = inputArray[2];
    var middle = inputArray[1];
    var shortest = inputArray[0];

      console.log((longest*longest == middle*middle + shortest*shortest) ? 'YES' : 'NO');
  }
}

Measured memory_bytes: 10372
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define inf 1e9
#define pi 3.1415926536
#define mod 1000000007
#define fr(i,a,b,in) for(int i=a;i<b;i+=in)
#define frn(i,a,b,dc) for(int i=a;i>=b;i-=dc)
#define test(t) int t; cin>>t; while(t--)
int main()
{
	fastio();
	int n,x,t;
	cin>>n>>x>>t;
	int d=n/x,r=n%x;
	int ans=t*d;
	if(r>0) ans+=t;
	cout<<ans<<endl;
}

Measured memory_bytes: 3668
function Main(input){
  input = input.split("\n");
  var N=Number(input[0]);
  var A=Number(input[1]);
  if(N%500>A){
    console.log('No');
  }else{
    console.log('Yes');
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>

#include <iostream>
#include <algorithm>
#include <cmath>
#include <iterator>
#include <iomanip>
#include <random>
#include <numeric>

// #include <bits/stdc++.h>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>

using namespace std;
// using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<double,double> pd;
typedef priority_queue<int, vector<int>, greater<int> > min_heap;

// template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const double PI = 4*atan(1);
const ll INF = 1e18;
const int MX = 100001;



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

    char c;
    cin >> c;
    int diff = 'Z' - c;
    if (diff >= 0) {
        cout << "A\n";
    } else {
        cout << "a\n";
    }

}
/*
    Potential bugs:
    - Not resetting the arrays properly
    - Out of bounds
*/

Measured memory_bytes: 3648
# C
n = int(input())
plan = []
for _ in range(n):
    t, x, y = map(int, input().split())
    plan.append((t, x, y))

flag = 'Yes'
elapsed = 0
now = (0, 0)
for p in plan:
    t, x, y = p[0], p[1], p[2]
    nx, ny = now[0], now[1]

    time = t - elapsed
    distance = abs(x - nx) + abs(y - ny)
    buff = time - distance
    if (buff>=0) and (buff%2 == 0):
        elapsed = t
        now = (x, y)
    else:
        flag = 'No'
        break
print(flag)

Measured memory_bytes: 17372
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll A,B,C;
  cin>>A>>B>>C;
  ll K;
  cin>>K;
  bool judge=false;
  while(K>0){
    if(B>A&&C>B){
      judge=true;
      break;
    }
    else if(C<=B||C<=A){
      C*=2;
    }
    else if(B<=A){
      B*=2;
    }
    K--;
  }
  if(B>A&&C>B) judge=true;
  if(judge){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long  ll; typedef vector<int> VI; typedef pair<int,int> pii; typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <class F,class ...S> void dbg(const F& f, const S&...s){cerr <<f <<": "; dbg(s...);}



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	ll h,w, m;
	cin >>h >>w >>m;
	set<ll> st;
	VL smh(h+3), smw(w+3);

	rep(i, m){
		int yy, xx;
		cin >>yy >>xx;
		st.insert(yy *w + xx);
		smw[xx]++;
		smh[yy]++;
	}
	
	auto ck=[&](ll a, ll b){
		return st.count(a*w +b) > 0;
	};

	vector<pii> srh, srw;
	rep(i, h+1) if(smh[i]>0) srh.emplace_back(smh[i], i);
	rep(i, w+1) if(smw[i]>0) srw.emplace_back(smw[i], i);
	
	sort(srh.rbegin(), srh.rend());
	sort(srw.rbegin(), srw.rend());
	
	ll mx = srh[0].first + srw[0].first;
	int ct = 0;
	for(auto& yy :srh) for(auto& xx :srw){
		ll kei = yy.first + xx.first;
		if(kei < mx) break;
		if(!ck(yy.second, xx.second)){
			cout << mx <<"\n"; return 0;
		}
		if(++ct > m+1) break;
	}
	
	cout << (ct>m? mx: mx-1) <<"\n";
	
	return 0;
}



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

int c[10] = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
int d[10009], p[10009], a[10009];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++)
		cin >> a[i];
	sort(a, a + m); reverse(a, a + m);
	for (int i = 0; i <= n; i++)
		d[i] = -1000000000;
	d[0] = 0;
	for (int i = 1; i <= n; i++)
		for (int j = 0; j < m; j++)
			if (i - c[a[j]] >= 0 && d[i - c[a[j]]] + 1 > d[i]) {
				d[i] = d[i - c[a[j]]] + 1; p[i] = j; 
			}
	int t = n;
	while (t) {
		cout << a[p[t]];
		t -= c[a[p[t]]];
	}
	cout << '\n';
	return 0;
}

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


int main()
{
    string n;
    cin>>n;
    int t=0;
    for(int i=0;i<n.size();i++)
    {
        if(n[i]=='7')
        {
            t=1;
            break;
        }
    }
    if(t==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;



    return 0;
}


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

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

    for(int x = 1; x <= 1000000; x++){
        if(int(x * 0.08) == a && int(x * 0.1) == b){
            cout << x << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (ll i = begin; i < (ll)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    vector<ll> X(N), sorted(N);
    rep(0, i, N)
    {
        cin >> X.at(i);
        sorted.at(i) = X.at(i);
    }
    sort(all(sorted));
    ll med1 = sorted.at(N / 2);
    ll med2 = sorted.at(N / 2 - 1);
    rep(0, i, N)
    {
        if (X.at(i) >= med1)
        {
            cout << med2 << endl;
        }
        else
        {
            cout << med1 << endl;
        }
    }
}

Measured memory_bytes: 6404
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,a,b,x=0;cin>>n>>a>>m>>b;
  while(true){
    m-=a;
    if(m<=0){x=1;break;}
    else{
      n-=b;
      if(n<=0){x=2;break;}
    }
  }
  if(x==1)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3624
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自动生成的方法存根
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		String S=sc.next();
		int x=0;
		int y=0;
		for(int i=0;i<S.length();i++) {
			String c=S.substring(i,i+1);
			if(c.equals("I")) {
				x++;
				if(x>y) {
					y=x;
				}
			}else {
				x--;
				if(x>y) {
					y=x;
				}
			}
		}
		System.out.println(y);
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define ll long long int
#define mod 998244353 
#define pb push_back
//#define mp make_pair
#define INF 2000000011LL
#define INFLL 1000000000000000011LL
#define eps 1e-9
#define pp pair < pair<ll,ll> , ll> 
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define foll(i,j,k) for(ll i=j;i<=k;i++)
#define clr(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vll vector<ll>
#define sz(a) a.size()
#define len(a) a.length()
#define all(a) a.begin(),a.end()
#define io_file freopen("Contest/input_file.in", "r", stdin); freopen("Contest/output_file.in", "w", stdout)

const int MAXN = 2e5+5;
using namespace std;
ll power(ll x, ll y)
{
  ll res = 1;
  while(y>0)
  {
    if(y&1)
       {
         res = (res*x)%mod;
        }
     x = (x*x)%mod;
     y = y>>1;
  }
    return res;
}
// std::vector<ll> divi[100004];
// void divisor(int n)
// {
//    for(ll i=1;i<=n;i++)
//    {
//      for(ll j=i;j<=n;j+=i)
//      {
//        divi[j].pb(i);
//      }
//    }
// }



ll n;
string a[305];
map<ll,ll>m;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    for(int i=0;i<n;i++)
    {
      cin>>a[i];
    }
    ll ans = 0;
    // cout<<"hi"<<endl;
    for(int x=1-n;x<=n-1;x++)
    {
      bool flag = true;
      // cout<<"hihi"<<endl;
      for(int i=0;i<n;i++)
      {
        for(int j = 0;j<n;j++)
        {
          // int xind = (j-x + n)%n;
          // int yind = (i+x + n)%n;
          // if(x==1)
          //   cout<<i<<" "<<j<<" "<<xind<<" "<<yind<<endl;
          if(a[i][j]!=a[(j-x + n)%n][(i+x + n)%n])
          {
            flag = false;
            break;
          }
        }
        if(!flag)
          break;
      }
      if(flag)
      {
        m[x] = 1;
        // cout<<x<<" ";
        
      }
    }
    for(int i=0;i<n;i++)
    {
      for(int j = 0;j<n;j++)
      {
        if(m[i-j]==1)
          ans++;
      }
    }
    cout<<ans<<endl;
    return 0;

}



Measured memory_bytes: 384
N,M=map(int,input().split())
lists=list(map(int,input().split()))
dp=[float("inf") for i in range(N+1)]
dp[0]=0
for i in range(1,N+1):
    for num in lists:
        if i>=num:
            dp[i]=min(dp[i],dp[i-num]+1)
print(dp[N])


Measured memory_bytes: 7384
#include <stdio.h>
int main(){
  int i,j,n,maxv=0,minj=0;
  scanf("%d",&n);
    int R[n];
  for(j=0;j<n;j++)
    {
      scanf("%d",&R[j]);
    }
  maxv=R[1]-R[0];
  minj=R[0];
  for(i=1;i<n;i++)
    {
      if(maxv<R[i]-minj) maxv=R[i]-minj;
      if(minj>R[i])minj=R[i];
    }
printf("%d\n",maxv);
return 0;
}

Measured memory_bytes: 1376
#include<stdio.h>
#include<math.h>
int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    int i;
    int p = 1000000007;
    unsigned long long int ans = 1;
    if (n == m)
    {
        for (i = 1; i <= n; i++)
        {
            ans *= i;
            ans %= p;
            ans *= i;
            ans %= p;
        }
        ans *= 2;
        ans %= p;
    }
    else if (n - m == 1)
    {
        for (i = 1; i <= m; i++)
        {
            ans *= i;
            ans %= p;
            ans *= i;
            ans %= p;
        }
        ans *= n;
        ans %= p;
    }
    else if (m - n == 1)
    {
        for (i = 1; i <= n; i++)
        {
            ans *= i;
            ans %= p;
            ans *= i;
            ans %= p;
        }
        ans *= m;
        ans %= p;
    }
    else
        ans = 0;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
def gcd(x, y):
    if y == 0:
        return x
    else:
        return (gcd(y, x % y))


n, x = map(int, input().split())
l = list(map(int, input().split()))
sa = []
for i in range(n):
    t = abs(l[i] - x)
    sa.append(t)
sa = list(set(sa))
sa.sort()

q = len(sa)
t = sa[0]

for i in range(1, q):
    t = gcd(t, sa[i])
print(t)


Measured memory_bytes: 17684
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**6)
# buff_readline = sys.stdin.buffer.readline
buff_readline = sys.stdin.readline
readline = sys.stdin.readline

INF = 2**62-1


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


def read_float():
    return float(buff_readline())


def read_float_n():
    return list(map(float, buff_readline().split()))


def read_str():
    return readline().strip()


def read_str_n():
    return readline().strip().split()


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, X):
    C = X.count('1')
    cmr = 0
    cpr = 0
    for b in X:
        if C-1 != 0:
            cmr = ((cmr * 2) + int(b)) % (C-1)
        cpr = ((cpr * 2) + int(b)) % (C+1)

    ans = []
    for i in range(N):
        t = 1
        if X[i] == '0':
            x = (cpr + pow(2, N-i-1, C+1)) % (C+1)
        elif X[i] == '1' and C-1 != 0:
            x = (cmr - pow(2, N-i-1, C-1)) % (C-1)
        else:
            x = 0
            t = 0

        while x != 0:
            x = x % bin(x).count('1')
            t += 1

        ans.append(t)

    return ans


def main():
    N = read_int()
    X = read_str()
    print(*slv(N, X), sep='\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 89808
#include<stdio.h>

int main(){
    int n;
    int half;
    int flag;

    char s[100];

    scanf("%d", &n);
    half = n / 2; 
    flag = n % 2;

    scanf("%s", s);

    int i = 0;
    
    if(flag == 0){
        for(i = 0; i < half; i++){
            if(s[i] != s[half + i]){
                flag =  1;
            }
        }
    }

    if(flag == 0){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0035
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            var Ps = Console.ReadLine().Split(' ').Select(int.Parse).ToList<int>();

            int result = int.MaxValue;

            Ps.Sort();

            for (int i = Ps[0]; i <= Ps[Ps.Count - 1]; i++)
            {
                int t = 0;

                for (int j = 0; j < Ps.Count; j++)
                {
                    t += (int)Math.Pow(i - Ps[j], 2);
                }

                if (t <= result)
                {
                    result = t;
                }
            }

            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 28120
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll a;
  cin>>a;
  ll b;
  cin>>b;
  ll c=-100;
  ll d=100;
  ll e,f;
  cin>>e>>f;
  for(ll i=0; i<a;i++){
    ll g;
    cin>>g;
    c=max(g,c);
  }
  for(ll i=0;i<b;i++){
    ll h;
    cin>>h;
    d=min(h,d);
  }
  if(c+1>d){
    cout<<"War"<<endl;
    return 0;
  }
  
    for(ll i=e+1;i<=f;i++){
      if(c+1<=i&&i<=d){
        cout<<"No War"<<endl;
        return 0;
      }
    }
    cout<<"War"<<endl;
  return 0;
}


Measured memory_bytes: 3568
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
using namespace std;
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) repi(i,0,(n))
typedef long long lint;
int main(){
	string s;cin>>s;
	lint ans=0;
	rep(i,4){
		ans+=(s[i]=='2');
	}cout<<ans<<endl;
}


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

int main(){
	int n,b,f,r,v,house[4][3][10];

	for(int i=0;i<4;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<10;k++){
				house[i][j][k]=0;
			}
		}
	}

	cin >> n;
	for(int i=0;i<n;i++){
		cin >> b >> f >> r >> v;
		house[b-1][f-1][r-1]=house[b-1][f-1][r-1]+v;
	}

	for(int i=0;i<4;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<10;k++){
				cout << " " << house[i][j][k];
			}
			cout << endl;
		}
		if(i<3){
			cout << "####################" << endl;
		}
	}
}

Measured memory_bytes: 1164
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <list>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	int n;
	cin >> n;
	string s;
	cin >> s;

	// ( の数 == ) の数としたい
	// このときの辞書順最小とは・・・？
	// ( のほうが辞書順で小さいのかも
	// 足りない分を足してあげる
	// 一番左に( を追加しまくるのが一番辞書順で小さくなる

	// 解が正しくなる条件は？
	// ( ) の間に ( もしくは ) だけが入らない
	// もしかして間に挿入することはない？
	char str[300];
	rep(i, n) {
		str[i + 100] = s[i];
	}
	// 開始位置と終了位置を示している
	int head = 100;
	int tail = 100 + n - 1;
	*/

	string x;
	cin >> x;

	// 最終的にtt...tss...sに変換できる
	int tnum = 0;
	int snum = 0;
	rep(i, (int)x.size()) {
		if (x[i] == 'S')snum++;
		else {
			if (snum != 0) {
				snum--;
			}
			else {
				tnum++;
			}
		}
	}
	int sumtnum = 0;
	rep(i, (int)x.size()) if (x[i] == 'T') sumtnum++;
	cout << (int)x.size() - (sumtnum - tnum) * 2 << endl;
	
}


Measured memory_bytes: 720
use proconio::{fastout, input, marker::Chars};

#[fastout]
fn main() {
    input! {
        s: Chars
    };

    let mut s: Vec<char> = s;
    let mut zero = s.iter().filter(|x| **x == '0').count();
    let mut one = s.iter().filter(|x| **x == '1').count();

    println!("{}", std::cmp::min(zero, one) * 2);
}


Measured memory_bytes: 2592
void main()
{
    long x, y, z, k;
    rdVals(x, y, z, k);
    long[] a = rdRow;
    long[] b = rdRow;
    long[] c = rdRow;

    a.sort!"a > b";
    b.sort!"a > b";
    c.sort!"a > b";

    auto que = new BinaryHeap!(Array!Cake, "a.t > b.t")();
    foreach (i; 0 .. k)
    {
        que.insert(Cake(0, 0, 0));
    }

    foreach (u; 0 .. x)
    {
        foreach (v; 0 .. y)
        {
            if (u * v > k) break;
            foreach (w; 0 .. z)
            {
                if (u * v * w > k) break;
                Cake cake = Cake(a[u], b[v], c[w]);
                if (que.front.t < cake.t)
                {
                    que.popFront;
                    que.insert(cake);
                }
            }
        }
    }

    long[] results = new long[k];
    while (!que.empty)
    {
        results[que.length-1] = que.front.t;
        que.popFront;
    }

    foreach (r; results)
    {
        r.writeln;
    }
}

struct Cake
{
    long a, b, c, t;

    this(long a, long b, long c)
    {
        this.a = a, this.b = b, this.c = c;
        t = a + b + c;
    }
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int m, k;
    cin >> m >> k;
    if(k >= (1<<m)){
        cout << -1 << endl;
        return 0;
    }
    if(m == 0){
        cout << "0 0" << endl;
        return 0;
    }
    if(m == 1){
        if(k == 0) cout << "0 0 1 1" << endl;
        else cout << -1 << endl;
        return 0;
    }
    if(k == 0){
        vector<int> ans(1<<m);
        iota(all(ans), 0);
        repe(j, ans)rep(i, 2) cout << j << (i==1 && j==(1<<m)-1 ? "" : " ");
        cout << endl;
    }else{
        vector<int> tmp((1<<m)-1);
        iota(all(tmp), 1);
        vector<int> ans;
        ans.push_back(0);
        ans.push_back(k);
        repe(i, tmp)if(i != k) ans.push_back(i);
        ans.push_back(k);
        ans.push_back(0);
        reverse(all(tmp));
        repe(i, tmp)if(i != k) ans.push_back(i);

        rep(i, ans.size()) cout << ans[i] << (i == ans.size()-1 ? "":" ");
        cout << endl;
    }




}

Measured memory_bytes: 3444
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)

map<string, int> mp;

int main() {
    string s;
    cin >> s;
    int a[26] = {};
    for (int i = 0; i<s.size(); i++) {
        a[s[i] - 'a']++;
    }
    for (int i = 0; i<26; i++) {
        if (a[i] >= 2) {
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
}

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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

typedef pair<int,int> pi;

int w,h;

inline bool in(int x, int y)
{
    return (0<=x&&x<=(w+1) && 0<=y&&y<=(h+1));
}

int main()
{
    cin >>w >>h;

    //0:???????????????,1:???????????????,2:???????¢????,3:???????¢????
    int f[102][102];

    for(int i=1; i<=h; ++i)for(int j=1; j<=w; ++j) scanf(" %d", &f[j][i]);

    //?????´????????????
    rep(i,w+2) f[i][0]=f[i][h+1]=2;
    rep(i,h+2) f[0][i]=f[w+1][i]=2;

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

    //????????????????????????
    for(int i=1; i<=h; ++i)for(int j=1; j<=w; ++j)
    {
        if(f[j][i]!=0) continue;

        bool out=false;

        int vis[102][102]={0};
        vis[j][i]=1;
        queue<pi> que;
        que.push(pi(j,i));

        while(!que.empty())
        {
            pi now=que.front();
            que.pop();
            rep(k,6)
            {
                int nx=now.fi+dx[now.se%2][k],ny=now.se+dy[k];

                if(!in(nx,ny)) continue;

                if(f[nx][ny]==2) out=true;
                if(f[nx][ny]==0 && !vis[nx][ny])
                {
                    vis[nx][ny]=1;
                    que.push(pi(nx,ny));
                }
            }
        }

        int num=3;
        if(out) num=2;

        rep(x,w+2)rep(y,h+2) if(vis[x][y]) f[x][y]=num;
    }

    int ans=0;
    for(int y=1; y<=h; ++y)for(int x=1; x<=w; ++x)
    {
        if(f[x][y]==1)
        {
            rep(i,6)
            {
                int nx=x+dx[y%2][i],ny=y+dy[i];
                if(f[nx][ny]==2) ++ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    vector<int> s;
    int ans = 0;
    string S;
    cin >> S;
    for(int i =0;i<S.size(); i++){
        if (S[i] == '0') s.push_back(0);
        else s.push_back(1);
    }

    for(int i = 0;i<S.size();i++){
        if (i%2 == s[i]) ans++;
    }
    int b = S.size() - ans;
    cout << min(ans, b) << endl;

}

Measured memory_bytes: 1020
from collections import Counter
N = int(input())
S = input()
Sc = Counter(S)
rgb = Sc["R"] * Sc["G"] * Sc["B"]
for j in range(1, N-1):
    for i in range(j):
        k = j + (j-i)
        assert i < j < k
        if k < N:
            if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                rgb -= 1
print(rgb)

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main()
{
    int a, b, c;
  cin >> a >> b >> c;
  cout << a + b + c - max(max(a, b), c) << endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        f: [[usize; 10]; n],
        p: [[i64; 11]; n],
    }

    let mut m = std::i64::MIN;
    for i in 1..1 << 10 {
        let mut sum = 0;
        for k in 0..n {
            let mut cnt_a_haur = 0;
            for j in 0..10 {
                if (i >> j) & 1 == 1 {
                    if f[k][j] == 1 {cnt_a_haur+=1;};
                }
            }
            sum+=p[k][cnt_a_haur];
        }
        m= std::cmp::max(sum, m);
    }
    println!("{}", m);
}

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

using namespace std;

int const maxn = 1e5 + 5;
int a[maxn];

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];
    int lef = 0, righ = n + 1;
    while (righ - lef > 1) {
        int mid = (righ + lef) / 2;
        multiset < int > Q;
        for (int i = 1; i <= mid; ++i) {
            Q.insert(-1);
        }
        int oks = 1;
        for (int i = 1; i <= n; ++i) {
            auto it = Q.lower_bound(a[i]);
            if (it == Q.begin()) {
                oks = 0;
                break;
            }
            it--;
            Q.erase(it);
            Q.insert(a[i]);
        }
        if (oks) righ = mid;
        else lef = mid;
    }
    cout << righ << '\n';
    return 0;
}



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

int main() {
  int H, W;

  while (true) {
    cin >> H >> W;
    if (H == 0 && W == 0)
      break;
    for (int h = 0; h < H; h++) {
      for (int w = 0; w < W; w++) {
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define INF (1<<30)-1
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,x,t; cin >> n >> x >> t;
  int cnt = 0, ans = 0;
  while(cnt < n){
    cnt += x;
    ans += t;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int x[26],y[26];

int main(){
  int h,w;
  cin >> h >> w;
  char a[h][w];
  rep(i,h)rep(j,w)cin >> a[i][j];
  int c[26]={};
  rep(i,h)rep(j,w)c[a[i][j]-'a']++;
  int cnt=0;
  rep(i,26)if(c[i]%2)cnt++;
  if(cnt!=(h*w)%2){
    cout << "No" << endl;
    return 0;
  }
  int p=0;
  rep(i,26)if(c[i]%4)p++;
  if(h%2==0 && w%2==0){
    if(p){
      cout << "No" << endl;
      return 0;
    }
  }
  else if(h%2 && w%2){
    if(p>(h+w)/2){
      cout << "No" << endl;
      return 0;
    }
  }
  else if(h%2==0){
    if(p>h/2){
      cout << "No" << endl;
      return 0;
    }
  }else{
    if(p>w/2){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
return 0;}

Measured memory_bytes: 256