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

using namespace std;
using ll = long long;

ll max(ll x, ll y) {
	if (x < y) {
		return y;
	} else {
		return x;
	}
}

int main(void) {
	ll ans = 0LL;
	deque<pair<char, ll>> v = {make_pair(getchar(), 1LL)};
	int d;
	while ((d = getchar()) != EOF) {
		if (d == '\n') {
			continue;
		}
		if (d != v.back().first) {
			v.push_back(make_pair(d, 0LL));
		}
		v.back().second++;
	}
	if (v.front().first == '>') {
		ans += (v.front().second + 1LL) * v.front().second / 2LL;
		v.pop_front();
	}
	if (v.back().first == '<') {
		ans += (v.back().second + 1LL) * v.back().second / 2LL;
		v.pop_back();
	}
	while (!v.empty()) {
		ll open, close;
		open = v.front().second;
		v.pop_front();
		close = v.front().second;
		v.pop_front();
		ans += (open - 1LL) * open / 2LL
					 + (close - 1LL) * close / 2LL
					 + max(open, close);
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 4352
#include <iostream>
#include <sstream>
using namespace std;
int main(){
	int n;
	while(cin>>n,n){
		string s;
		cin>>s;
		while(n--){
			string t;
			char before=s[0];
			int count=1;
			for(int i=1;i<s.size();++i){
				if(s[i]==before)count++;
				else{
					string str;
					stringstream ss;
					ss<<count;
					ss>>str;
					t+=str+before;
					before=s[i];
					count=1;
				}
				if(i==s.size()-1){
					string str;
					stringstream ss;
					ss<<count;
					ss>>str;
					t+=str+before;
					before=s[i];
					count=1;
				}
			}
			s=t;
		}
		cout<<s<<endl;
	}
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

const string YES = "YES";
const string NO = "NO";

void solve(long long N, std::vector<long long> p){
    int cnt = 0;
    REP(i, N) {
        if(p[i] != i+1) cnt++;
    }

    cout << (cnt <= 2 ? YES : NO) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, std::move(p));
    return 0;
}


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

H,W = LI()
a  = [list(map(str,input())) for _ in range(H)]

d = defaultdict(int)
for i in range(H):
    for j in range(W):
        d[a[i][j]] += 1

if H%2 == 0 and W%2 == 0:
    for k in d.keys():
        if d[k]%4 != 0:
            print('No')
            exit()
    print('Yes')
elif H%2 == 0 and W%2 != 0:
    count = 0
    for k in d.keys():
        if d[k]%4 != 0:
            if d[k]%2 != 0:
                print('No')
                exit()
            else:
                count += 1
    if count%2 == (H//2)%2 and H//2 >= count:
        print('Yes')
    else:
        print('No')
elif W%2 == 0 and H%2 != 0:
    count = 0
    for k in d.keys():
        if d[k]%4 != 0:
            if d[k]%2 != 0:
                print('No')
                exit()
            else:
                count += 1
    if count%2 == (W//2)%2 and W//2 >= count:
        print('Yes')
    else:
        print('No')
else:
    odd_flag = False
    count = 0
    for k in d.keys():
        if d[k]%4 != 0:
            if d[k]%2 != 0:
                if not odd_flag:
                    odd_flag = True
                else:
                    print('No')
                    exit()
            else:
                count += 1
    if count%2 == ((H-1)//2+(W-1)//2)%2 and (H-1)//2+(W-1)//2 >= count:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 39152
s=gets.chomp.chars
t=gets.chomp.chars
hs=Hash.new(nil)
ht=Hash.new(nil)
z=s.size
k=0
l=0
z.times do |i|
  if hs[s[i]]==nil
    hs[s[i]]=k
    k+=1
  end
  s[i]=hs[s[i]]
  if ht[t[i]]==nil
    ht[t[i]]=l
    l+=1
  end
  t[i]=ht[t[i]]
end
if s==t
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 22780
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
#define ll long long
#define For(i,a,b) for(int (i)=(a);(i) < (b); ++(i))
 
const int N =100;
 
bool isprime(int n)
{
    if (n <= 1)
        return false;
    for (int i = 2; i*i<=n; i++)
        if (n % i == 0)
            return false;
 
    return true;
}
int binarySearch(int arr[], int l, int r, int x)
{
    if (r >= l) {
        int mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}
long long lcm(long long a,long long b)
{
    long long p,r;
    p = a*b;
    r = __gcd(a, b);
    return p/r;
}
bool ispalindrome(string s)
{
    int n = s.length();
    for(int i=0;i<n/2;i++)
    {
        if(s[i]!=s[n-i-1])
            return false;
    }
    return true;
}
bool isPerfectSquare(long double x)
{
  long double sr = sqrt(x);
  return ((sr - floor(sr)) == 0);
 
}
ll f(ll n) {
	return n * (n - 1) / 2;
}
bool cmp(const tuple<int, string, string>& a,
               const tuple<int, string, string>& b)
{
    return (get<0>(a) < get<0>(b));
}
 
void solve()
{
    ll x,a;
    cin>>x>>a;
    if(x<a)
        cout<<0<<endl;
    else
        cout<<10<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define MOD 1000000007
int a[1000010];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0,c=1,res=0;string s;
    cin>>n;
    cin>>s;
    for(int i=0;i<(n-1);++i)
        a[i]=(int)abs(s[i]-s[i+1]);
    --n;
    int f[3];
    for(int i=0;i<n;++i)
        f[a[i]]+=1;
    if(f[1]==0)
    {
        c*=2;
        for(int i=0;i<n;++i)
            a[i]/=2;
    }
    for(int i=0;i<n;++i)
    {
        if(((n-1)&i)==i)
            res^=a[i];
    }
    cout<<(res&1)*c<<endl;
}


Measured memory_bytes: 5276
import bisect,collections,copy,itertools,math,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
O = S()
E = S()
ans = ''
for i in range(len(E)):
    ans += O[i]
    ans += E[i]
if len(O) != len(E):
    ans += O[-1]
print(ans)

Measured memory_bytes: 3888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
ll INF = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int N,M;
int main(){
    ll N,K; cin >> N >> K;
    ll h[N];
    for(ll i = 0; i < N; i++){
        cin >> h[i];
    }
    ll dp[100100];
    for(ll i = 0; i < 100000; i++) dp[i] = INF;
    dp[0] = 0;
    for(ll i = 0; i < N; i++){
        for(ll j = 1; j <= K; j++){
            if(i+j < N){
                dp[i+j] = min(dp[i]+abs(h[i]-h[i+j]), dp[i+j]);
            }
        }
    }
    cout << dp[N-1] << endl;
}



Measured memory_bytes: 1792
def test():
    s = input()
    result = 0
    for i in range(len(s)-1):
        str = s[:i]
        if len(str) % 2 == 0:
            str1 = str[:len(str)//2]
            str2 = str[len(str)//2:]
            if all(str1[j] == str2[j] for j in range(len(str1))):
                result = max(result,len(str))
    print(result)


if __name__ == "__main__":
    test()


Measured memory_bytes: 3060
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
const ll INF = 1e9;
const ll MOD = 1e9+7;

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

ll gcd(vl v)
{
    ll res = v[0];
    for(int i = 1; i < v.size(); i++) res = gcd(res, v[i]);
    return res;
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    
    ll N, K; cin >> N >> K;
    vl A(N); REP(i, N) cin >> A[i];
    ll g = gcd(A);
    REP(i, N)
    {
        if(A[i] >= K && (A[i]-K) % g == 0)
        {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}


Measured memory_bytes: 1792
def main():
    N, M, K = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    
    if a[0] > K and b[0] > K:
        return 0

    a2=[0]
    for i in a:a2.append(a2[-1]+i)
    b2=[0]
    for i in b:b2.append(b2[-1]+i)
    ans = 0
    j = M
    
    for i in range(N + 1):
        if a2[i] > K:
            break
        while b2[j] > K - a2[i]:
            j -= 1
        ans = max(ans, i + j)    
    return ans

if __name__ == '__main__':
    print(main())

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

int main() {
  int N;
  cin >> N;
  int sum = 0;
  
  for(int i = 0; i < N; i++) {
    int A, B;
    cin >> A >> B;
    int people = B - A + 1;
    sum += people;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>=r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(a-1)),y(b){}_RX(int a):_RX(up?0:a,up?a:0){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef int64_t i64;
typedef uint64_t u64;
// const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

using namespace std;

map<int,i64> dfs(int v, int from, vector<vector<int>>& g, vector<int>& colors, vector<i64>& sum) {

	int vc = colors[v];
	map<int,i64> counts;

	counts[0] = 1;

	for(auto w : g[v]) {

		if(w == from) {
			continue;
		}

		auto ch_counts = dfs(w, v, g, colors, sum);

		i64 s = ch_counts[0] - ch_counts[vc];
		sum[vc] += s * (s - 1) / 2 + s;

		if(ch_counts.size() > counts.size()) {
			swap(ch_counts, counts);
		}

		for(auto kv : ch_counts) {
			int c = kv.first;
			int x = kv.second;
			if(c == vc) {
				continue;
			}
			counts[c] += x;
		}
	}

	counts[vc] = counts[0];

	return move(counts);
}

int main() {

	const int N = read_item();
	vector<int> colors(N);
	vector<int> used(N + 1);
	for(auto i : range(N)) {
		colors[i] = read_item();
		used[colors[i]] = true;
	}
	vector<vector<int>> g(N);
	for(auto i : range(N - 1)) {
		int x = (int)read_item() - 1;
		int y = (int)read_item() - 1;
		g[x].push_back(y);
		g[y].push_back(x);
	}

	vector<i64> sum(N + 1);
	auto counts = dfs(0, -1, g, colors, sum);
	for(auto kv : counts) {
		int c = kv.first;
		int x = kv.second;
		i64 s = N - x;
		sum[c] += s * (s - 1) / 2 + s;
	}

	for(auto i : range(1, N + 1)) {
		if(!used[i]) {
			printf("0\n");
		} else {
			printf("%lld\n", (i64)N * (N - 1) / 2 + N - sum[i]);
		}
	}

	return 0;
}

/* wafdayo~~~ */


Measured memory_bytes: 86104
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pii;

int main(){
	double x,h,s;
	while(1){
		cin>>x>>h;
		if(x==0&&h==0) break;
		s=pow(x,2)+2*x*pow(x*x/4+h*h,0.5);
		printf("%.8lf\n",s);
	}

}

Measured memory_bytes: 1292
#include <stdio.h>
int main(void) {
  int N,K;
  char str[100];
  scanf("%d %d",&N,&K);
  scanf("%s",str);
  if( str[K-1] =='A'){
    str[K-1] = 'a';
  }
  if( str[K-1] =='B')
  {
    str[K-1] = 'b'; }

  if( str[K-1] =='C'){
    str[K-1] = 'c'; }
  printf("%s\n",str);
  return 0;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const lli mod = 1e9+7;
template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using mint = ModInt< mod >;


lli h, w;

int main(void){
    cin >> h >> w;
    vector<string> m(h);
    rep(i, h) cin >> m[i];
    vector<vector<mint>> dp(h+1, vector<mint>(w+1));
    dp[0][0] = 1;
    rep(i, h){
        rep(j, w){
            if(m[i][j] == '#') continue;
            if(i+1 < h && m[i+1][j] != '#') dp[i+1][j]+=dp[i][j];
            if(j+1 < w && m[i][j+1] != '#') dp[i][j+1]+=dp[i][j];
        }
    }
    cout << dp[h-1][w-1] << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VL a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));
  int ans = n;
  int j = 0;
  rep(i, n-1) {
    if(j > n-1) break;
    if(2 * a[j] >= a[n-1]) break;
    if(2 * a[j] < a[i+1]) {
      ans -= i + 1 - j;
      a[i+1] += a[j];
      j = i + 1;
    }
    else {
      a[j] += a[i+1];
    }
  }
  out(ans);
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
long long n,a[200010],one[200010],two[200010],par,mx;
int main(){
    ios::sync_with_stdio(0);
    cin>>n;
    for(int i=1; i<=n; i++){
        ll tmp;
        cin>>tmp;
        a[tmp]=i;
    }
    one[1] = 5e+8;
    two[1] = 5e+8;
    for(int i=2; i<=n; i++){
        if (a[i]>a[i-1]){
            one[i] = one[i-1] + 1 + (a[i]-a[i-1]);
            two[i] = two[i-1] - 1;
        }
        else if (a[i] < a[i-1]){
            one[i] = one[i-1] + 1;
            two[i] = two[i-1] - 1 + (a[i]-a[i-1]);
        }
    }
    for(int i=1; i<n; i++) cout<<one[i]<<' ';
    cout<<one[n]<<endl;
    for(int i=1; i<n; i++) cout<<two[i]<<' ';
    cout<<two[n]<<endl;
    return 0;
}

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

using namespace std;

int main() {
  // input
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }

  // solve
  int ans = 0;
  while (true) {
    bool OK = true;
    for(int i = 0; i < n; i++){
      if (a[i] % 2 == 0){
        a[i] /= 2;
      }else{
        OK = false;
        break;
      }
    }
    if(OK){
      ans ++;
    }else{
      break;
    }
  }

  // output
  cout << ans << endl;
}


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

int a[3];

int main()
{
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a+3);
    if(a[0] == a[1] && a[0] != a[2]){
        puts("Yes");
    }
    else if(a[1] == a[2] && a[1] != a[0]){
        puts("Yes");
    }
    else puts("No");

    return 0;
}

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

/*
http://arc061.contest.atcoder.jp/tasks/arc061_b
题意：
H行W列的矩阵中，然后挖了n个洞，输出j(0-9)行，对于第i行输出，有多少个3*3区域中有i个洞；

思路：
对于一个黑色的格子，只有9个3*3的矩阵才能包含他。
所以只有处理m个黑格子就行了。
对于每个黑格子，我默认把3*3的左上角代表这个矩阵。
这样还不够，因为没有那么大的矩阵表示方法，所以换一个表示就是把矩阵中每个格子标记；
处理一下，最后输出就好了；

*/
LL h,w,n;
map<LL,LL>mp;
LL ans[10];
LL dx[9]={-2,-2,-2,-1,-1,-1,0,0,0};
LL dy[9]={-2,-1,0,-2,-1,0,-2,-1,0};

void Add(LL x,LL y)
{
    LL a,b;
    LL temp;
    for(int i=0;i<9;i++)
    {
        a=x+dx[i];
        b=y+dy[i];
        if(a<1||b<1||a>h-2||b>w-2)
            continue;
        temp=(h-2)*(b-1)+a;
        mp[temp]++;
    }
}

int main()
{
    LL x,y;
    scanf("%lld%lld%lld",&h,&w,&n);
    for(LL i=0;i<n;i++)
    {
        scanf("%lld%lld",&x,&y);
        Add(x,y);
    }
    memset(ans,0,sizeof(ans));
    ans[0]=(h-3)*(w-2)+w-2;
    LL temp;
    map<LL,LL>::iterator it;
    for(it=mp.begin();it!=mp.end();it++)
    {
        temp=it->second;
        ans[temp]++;
        ans[0]--;
    }
    for(LL i=0;i<=9;i++)
    {
        printf("%lld\n",ans[i]);
    }
    return 0;
}




Measured memory_bytes: 56448
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    k, a, b = [int(x) for x in input().split()]
    if b - a > 2:
        # i need a - 1 ops to make 1 yen (and one biscuit for the operetion itself)
        # i need even number of ops (which are left now)
        # if there is odd number its just +1 to result
        ops = k - a + 1
        print(max(k + 1, (b - a) * (ops // 2) + a + (ops % 2)))

    else:
        print(k + 1)

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

1 + k



"""


Measured memory_bytes: 9468
#include <stdio.h>

int main(void)
{
	int a = 1;
	int b = 1;
	
	while (a <= 9){
		if ((a <= 9) && (b <= 9)){
			printf("%dx%d=%d\n", a, b, a * b);
			b++;
		}
		else if (b = 10){
			a++;
			b = b - 9;
		}
	}
	
	return (0);
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int main(){
    string st;
    cin>>st;
    st[3]='8';
    cout<<st<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.nextLine());
		String s = scan.next();
		String t = scan.next();
		StringBuffer ans = new StringBuffer();
		
		for(int i = 0; i < n; i++) {
			ans.append(s.charAt(i)).append(t.charAt(i));
		}
		
		System.out.println(ans.toString());
		scan.close();
	}
}


Measured memory_bytes: 21588
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int[] a = getIntArr(in, n);
		long r = solve(n, a);
		System.out.println(r);
		in.close();
	}

	private static long solve(int n, int[] a) {
		long[] max = new long[n + 1];
		long[] min = new long[n + 1];
		for (int i = 1; i <= n; i++) {
			for (int j = 0; j <= n - i; j++) {
				if ((n - i) % 2 == 0) {
					max[j] = Math.max(min[j + 1] + a[j], min[j] + a[j + i - 1]);
				} else {
					min[j] = Math.min(max[j + 1] - a[j], max[j] - a[j + i - 1]);
				}
			}
		}
		return max[0];
	}

	static String str(int[] a) {
		String[] str = new String[a.length];
		for (int i = 0; i < a.length; i++) {
			str[i] = a[i] + "";
		}
		return String.join(" ", str);
	}

	static int[] getIntArr(Scanner in, int size) {
		int[] arr = new int[size];
		for (int i = 0; i < size; i++) {
			arr[i] = in.nextInt();
		}
		return arr;
	}

	static int[][] getIntArr(Scanner in, int row, int col) {
		int[][] arr = new int[row][];
		for (int i = 0; i < row; i++) {
			arr[i] = getIntArr(in, col);
		}
		return arr;
	}

	static char[] getCharArr(Scanner in, int size) {
		char[] arr = in.next().toCharArray();
		return arr;
	}

	static String[] getStringArr(Scanner in, int size) {
		String[] arr = new String[size];
		for (int i = 0; i < size; i++) {
			arr[i] = in.next();
		}
		return arr;
	}

	static Map<Integer, List<Integer>> getEdges(Scanner in, int size, boolean directed) {
		Map<Integer, List<Integer>> edges = new HashMap<>();
		for (int i = 0; i < size; i++) {
			int from = in.nextInt();
			int to = in.nextInt();
			if (!edges.containsKey(from)) {
				edges.put(from, new ArrayList<Integer>());
			}
			edges.get(from).add(to);
			if (!directed) {
				if (!edges.containsKey(to)) {
					edges.put(to, new ArrayList<Integer>());
				}
				edges.get(to).add(from);
			}

		}
		return edges;
	}
}


Measured memory_bytes: 26416
import std.stdio, std.array, std.conv, std.typecons, std.algorithm;

T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }

void main() {
    immutable i = readln.split.to!(ulong[]);
    immutable R = i[0], G = i[1], B = i[2], N = i[3];
    ulong cnt = 0;

    for(ulong r = 0; r <= N / R; r++) {
        const ulong r_val = r * R;
        if (r_val > N) break;
        else if (r_val == N) cnt++;
        else {
            for(ulong g = 0; g <= N / G; g++) {
                const ulong g_val = r*R + g*G;
                if (g_val > N) break;
                else if (g_val == N) cnt++;
                else {
                    const ulong rem = (N - g_val) % B;
                    if (rem == 0) {
                        cnt++;
                    }
                }
            }
        }
    }
    writeln(cnt);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
const int mod=1000000007;
int main(){
    int n;cin>>n;
    vector<int> v(n);
    map<int,int> mp1,mp2;
    rep(i,n)cin>>v[i];
    int max1=0,max2=0,max3=0,max4=0;
    int a1=0,a2=0,a3=0,a4=0;
    for(int i=0;i<n;i+=2){
        mp1[v[i]]++;
        mp2[v[i+1]]++;
    }
    for(auto x:mp1){
        if(max1<=x.second){
            max2=max1;
            max1=x.second;
            a2=a1;
            a1=x.first;
        }
        else if(max2<=x.second){
            max2=x.second;
            a2=x.first;
        }
    }
    for(auto x:mp2){
        if(max3<=x.second){
            max4=max3;
            max3=x.second;
            a4=a3;
            a3=x.first;
        }
        else if(max4<=x.second){
            max4=x.second;
            a4=x.first;
        }
    }
    if(a1==a3){
        if(max1+max4>max2+max3){
            a3=a4;
        }
        else a1=a2;
    }
    int ans=0;
    for(int i=0;i<n;i+=2){
        if(v[i]!=a1)ans++;
        if(v[i+1]!=a3)ans++;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 8264
unittest
{
	assert( [ "101" ].parse.expand.solve == 2 );
	assert( [ "000" ].parse.expand.solve == 0 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto ss = input.front.strip.to!( dchar[] );
	return tuple( ss );
}

auto solve( dchar[] ss )
{
	return ss.map!( ( a ) => a - '0' ).sum;
}


Measured memory_bytes: 256
/*;

THE BEST IS YET TO COME
*/
#include <bits/stdc++.h>
using namespace std;
#define r(i, s, l) for (int i = s; i < l; i++)
#define rr(i,s,l) for(int i=s;i>=l;i--)
#define mod 1000000007
#define int long long
#define INT_BITS 32
#define ld long double
#define pp pair<int,int>
#define ss second
#define ff first
#define INF 1e18
#define N 2000005
#define all(a) a.begin(), a.end()
#define pb push_back
#define endl "\n"
using namespace std;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

signed main()
{


   int x,y;
   cin>>x>>y;

   r(i,0,101)
   r(j,0,101)
   {
        if(i+j==x && 2*i+4*j==y)
        {
            cout<<"Yes";
            return 0;
        }
   }

   cout<<"No";
   return 0;

	return 0;
}



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

using namespace std;
using ll = long long;
int main(){
    ll n,w;
    cin>>n>>w;
    vector<pair<ll,ll>> a(n);
    for(auto &b : a)cin>>b.first>>b.second;
    vector<ll> from(100050);
    auto to = from;
    for(int i=0;i<n;++i){
        ll weight = a[i].first;
        ll value = a[i].second;
        for(int j=0;j<=w;++j){
            if(j+weight<=w) to[j+weight] = max(to[j+weight],from[j]+value);
            to[j] = max(from[j],to[j]);
        }
        swap(from,to);
    }
    cout << from[w] << endl;
return 0;
}

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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  long long a = 0, b = 0;
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    if (i == 0) {
      a = x;
      b = y;
      continue;
    }
    a = (a + x - 1) / x * x;
    if ((a / x * y) < b) {
      b = (b + y - 1) / y * y;
      a = (b / y * x);
    } else {
      b = a / x * y;
    }
  }
  printf("%lld\n", a + b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    lint q;
    tuple<lint,lint,lint,lint> x[100];
    lint ans=0;
    lint cnt=0;
    void dfs(lint n,lint m,lint a,lint num,vector<lint> t){
            t.push_back(a);
        if(num==n){
            rep(i,q){
                lint a,b,c,d;
                tie(a,b,c,d)=x[i];
                if(t[b]-t[a]==c)cnt+=d;
            }
          ans=max(cnt,ans);
        
          cnt=0;
          return ;
        }
            repp(i,1,m+1){
              if(a<=i) {dfs(n,m,i,num+1,t);
              }
            }
    }
  int main(){      
     lint n,m;
     cin>>n>>m>>q;
     rep(i,q){
         lint a,b,c,d;
         cin>>a>>b>>c>>d;
         --a;--b;
         x[i]=make_tuple(a,b,c,d);
     }
     vector<lint> y;
     dfs(n,m,1,1,y);
     cout<<ans<<endl;
        
     

  }
          
  

Measured memory_bytes: 3628
#include <iostream>

int checked[40000][16];
long long dp[40000][16];
long long esum[40000];
using namespace std;
int eds[16][16];
int n,m;
long long calc(int state,int now);
long long calc_sub(int state_base,int state,int dep,int now,int prev) {
	if(dep==n) {
		return esum[state_base-state]+eds[now][prev]+calc(state,prev);
	}
	long long ret=0;
	if(dep==prev) {
		ret=calc_sub(state_base,state+(1<<dep),dep+1,now,prev);
	} else if(dep==now) {
		ret=calc_sub(state_base,state,dep+1,now,prev);
	} else {
		ret=calc_sub(state_base,state,dep+1,now,prev);
		if(state_base&(1<<dep)) {
			long long temp=calc_sub(state_base,state+(1<<dep),dep+1,now,prev);
			if(ret<temp) ret=temp;
		}
	}
	return ret;
}
long long calc(int state,int now) {
	if(checked[state][now]) return dp[state][now];
	checked[state][now]=1;
	if(now==0) {
		dp[state][now]=esum[state];
	} else {
		dp[state][now]=-1e16;
		for(int i=0;i<n;i++) {
			if((state&(1<<i))>0&&i!=now&&eds[i][now]>0) {
				long long temp=calc_sub(state,1,1,now,i);
				if(dp[state][now]<temp) dp[state][now]=temp;
			}
		}
	}
	return dp[state][now];
}
int main() {
	cin >> n >> m;
	for(int i=0;i<m;i++) {
		int va,vb,vc;
		cin >> va >> vb >> vc;
		va--; vb--;
		eds[va][vb]=vc;
		eds[vb][va]=vc;
	}
	for(int i=0;i<(1<<n);i++) {
		for(int j=0;j<n;j++) for(int k=j+1;k<n;k++) {
			if((i&(1<<j))>0&&(i&(1<<k))>0) esum[i]+=eds[j][k];
		}
	}
	cout << esum[(1<<n)-1]-calc((1<<n)-1,n-1) << endl;
	return 0;
}


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

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  ll n,q;
  cin>>n>>q;
  string s;
  cin>>s;
  ll b[n];
  memset(b,0,sizeof(b));
  for(ll i=1;i<n;i++)
  {
    if(s[i]=='C'&& s[i-1]=='A')
    {
         b[i]=1;
         i++;
    }
  }
for(int i=1;i<n;i++)
{
  b[i]=b[i]+b[i-1];
}
//cin>>q;
for(int i=1;i<=q;i++)
{
ll l,r;
cin>>l>>r;
l--;r--;
cout<<b[r]-b[l]<<endl;;
}
}

Measured memory_bytes: 1872
#include <cstdio>

using namespace std;

int main()
{
	int a, b, c, d;

	scanf("%d %d %d %d", &a, &b, &c, &d);

	if (d < a) {
		printf("0\n");
	}
	else if (b < c) {
		printf("0\n");
	}
	else if (a <= c && c <= b && b <= d) {
		printf("%d\n", b - c);
	}
	else if (c <= a && a <= d && d <= b) {
		printf("%d\n", d - a);
	}
	else if (a <= c && d <= b) {
		printf("%d\n", d - c);
	}
	else {
		printf("%d\n", b - a);
	}

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    ll maxi=-mod,mini=mod;
    int s=0,t=0;
    rep(i,n){
        if(maxi<a[i])maxi=a[i],s=i+1;
        if(mini>a[i])mini=a[i],t=i+1;
    }
    if(maxi*mini>=0){
        cout<<n-1<<endl;
        if(maxi>0){
            rep(i,n-1)a[i+1]+=a[i];
            rep(i,n-1)cout<<i+1<<' '<<i+2<<endl;
        }
        else{
            for(int i=n-1;i>0;i--)a[i-1]+=a[i];
            for(int i=n-1;i>0;i--)cout<<i+1<<' '<<i<<endl;
        }
    }
    else if(maxi>=abs(mini)){
        cout<<2*n-1<<endl;
        rep(i,n)a[i]+=maxi;
        rep(i,n)cout<<s<<' '<<i+1<<endl;
        rep(i,n-1)a[i+1]+=a[i];
        rep(i,n-1)cout<<i+1<<' '<<i+2<<endl;
    }
    else {
        cout<<2*n-1<<endl;
        rep(i,n)a[i]+=mini;
        rep(i,n)cout<<t<<' '<<i+1<<endl;
        for(int i=n-1;i>0;i--)a[i-1]+=a[i];
        for(int i=n-1;i>0;i--)cout<<i+1<<' '<<i<<endl;
    }
    return 0;
}


Measured memory_bytes: 3660
<?php

fscanf(STDIN, "%d", $n);

$x_vec = array_map("intval", explode(" ", trim(fgets(STDIN))));
$y_vec = array_map("intval", explode(" ", trim(fgets(STDIN))));

$x_y_diff = array_map(create_function('$x, $y', 'return abs("$x"-"$y");'), $x_vec, $y_vec);
$p_1 = array_sum($x_y_diff);
echo $p_1."\n";
$p_2 = sqrt(array_sum(array_map(create_function('$x', 'return pow("$x", 2);'), $x_y_diff)));
echo $p_2."\n";
$p_3 = third_root($x_y_diff);
echo $p_3."\n";
$p_inf = max($x_y_diff);
echo $p_inf."\n";

function third_root($arr) {
    $target = array_sum(array_map(create_function('$x', 'return pow("$x", 3);'), $arr));
    $x_n = $target / 2;
    
    if ($x_n == 0) {
        return 0;
    }
    
    while (true) {
        $next = $x_n - ((pow($x_n, 3)-$target) / (3 * pow($x_n, 2)));

        if (abs(pow($x_n, 3) - $target) < ($target/pow(10, 6))) {
            break;
        }

        $x_n = $next;
    }
    
    return $x_n;
}


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

/* メモリ食い過ぎ注意 */
#define int long long

typedef long long ll;

ll gcd(ll a, ll b)
{
    if (a < b)
        gcd(b, a);
    if (b == 0)
        return a;
    int r;
    while ((r = a % b))
    {
        a = b;
        b = r;
    }
    return b;
}

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int a, b;
    cin >> a >> b;
    if (a <= 8 && b <= 8)
        cout << "Yay!" << endl;
    else
        cout << ":(" << endl;
}


Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0
inf = float("inf")

S = s()
if S[0] == 'A' and S[2:-1].count('C') == 1 and S[1].islower() == True and S[-1].islower() == True: print('AC')
else: print('WA')


Measured memory_bytes: 9988
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int n,h,w;
    cin >> n >> h >> w;
    cout << (n-h+1)*(n-w+1) <<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bitset>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cstdlib>
#include <ctime>
#include <cstdint>
#include <cmath>

#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define EACH(i,x)   for(auto & i : x)
#define ALL(x)      begin(x),end(x)

using namespace std;

typedef vector<int> vecint;
const int INF=100000000;

void sh(vector<vecint>& t,vecint& bdp,int n){
  priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q;
  q.push(make_pair(0,0));
  while(!q.empty()){
    auto p=q.top();q.pop();
    if(bdp[p.second] < p.first)continue;
    REP(i,n){
      bitset<16> bs(p.second);
      if(bs[i]==false){
        bitset<16> cbs(bs.to_ulong());
        cbs[i]=true;
        int v=cbs.to_ulong();
        int cst=t[i][0];
        REP(j,n){
          if(bs[j]){
            cst=min(cst,t[i][j+1]);
          }
        }
        if(bdp[v] > bdp[p.second] + cst){
          bdp[v]=bdp[p.second]+cst;
          q.push(make_pair(bdp[v],v));
        }
      }
    }
  }
}

int main()
{
  while(true){
    int n;cin>>n;
    if(!n)break;
    vector<vecint> t(n,vecint(n+1));
    REP(i,n)REP(j,n+1)cin>>t[i][j];
    vecint bdp(1<<n,INF);
    bdp[0]=0;
    sh(t,bdp,n);
    cout<<bdp[(1<<n)-1]<<endl;
  }
  return 0;
}

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

using namespace std;


int main(){
    int N;
    cin >> N;
    int x;
    int p = 1;
    int pp = 1;
    for (int i=0;i<N;i++){
        cin >> x;
        if (x==1) pp *= 2;
        else{
            pp *= 3;
            if (x%2==0) p *= 2;
        }
    }
    cout << pow(3,N) - p;

}


Measured memory_bytes: 256
import scala.io.StdIn
import scala.math._

object Main {

  def main(args: Array[String]): Unit = {
    val n = StdIn.readLine.toInt
    val hs = StdIn.readLine.split(" ").map(_.toInt)

    val rec = new Array[Int](n)
    rec(0) = 0
    rec(1) = abs(hs(1) - hs(0))
    for (i <- 2 until n) {
      rec(i) = min(rec(i - 1) + abs(hs(i) - hs(i - 1)), rec(i - 2) + abs(hs(i) - hs(i - 2)))
    }

    println(rec(n - 1))

  }
}

Measured memory_bytes: 41816
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
char s[40];
int a[40];
int main()
{
    bool flag = 0;
    scanf("%s",s);
    memset(a,0,sizeof(a));
    int len = strlen(s);
    for(int i = 0; i < len; i++){
        for(int j = i+1; j < len; j++)
            if(s[i]==s[j])
                flag = 1;
    }
    if(flag == 0) printf("yes\n");
    else printf("no\n");

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    string yes = "YES", no = "NO";
    string s;
    cin >> s;
    rep(i, s.size()) {
        for(int j = 0; j + i <= s.size(); ++j) {
            string t = s.substr(0, i);
            if(j + i != s.size()) t += s.substr(j + i);
            // cout << i << " " << j << " " << t << endl;
            if(t == "keyence") {
                cout << yes << endl;
                return 0;
            }
        }
    }
    cout << no << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

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

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



















int main(){
    ll H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << (H - h) * (W - w) << endl;
}

Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        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)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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<_>>()
    };

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"4 3
1 2
2 3
1 4"# => r#"2
2
1
1"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize, m: usize,
        ab: [(usize, usize); m],
    }
    let mut c = vec![0; n];

    for i in 0..m {
        c[ab[i].0 - 1] += 1;
        c[ab[i].1 - 1] += 1;
    }

    let mut ans = "".to_string();
    for i in 0..n {
        ans.push_str(&c[i].to_string());
        if i != n - 1 {
            ans.push_str(&"\n");
        }
    }

    ans.to_string()
}

Measured memory_bytes: 4352
package main

import "fmt"

func main() {
	var N, P int
	fmt.Scan(&N, &P)
	m := make(map[int]int, 0)
	t := P
	for i := 2; i*i <= P; i++ {
		for t%i == 0 {
			m[i]++
			t /= i
		}
	}
	if t != 1 {
		m[t]++
	}
	ans := 1
	for k, v := range m {
		if v >= N {
			for i := 0; i < v/N; i++ {
				ans *= k
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int A=stdIn.nextInt();
		int B=stdIn.nextInt();
		int C=stdIn.nextInt();
		int X=stdIn.nextInt();
		int Y=stdIn.nextInt();
		int z=0,ans=0;
		if(Y>X){
			z=X;X=Y;Y=z;
			z=A;A=B;B=z;
		}
		if(A+B>C*2){
			ans+=Y*C*2;
			X-=Y;
			if(A>C*2)
				ans+=X*C*2;
			else
				ans+=X*A;
		}
		else{
			ans+=(Y*B)+(Y*A);
			X-=Y;
			if(A>C*2)
				ans+=X*C*2;
			else
				ans+=X*A;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>

using namespace std;

const int inf = 999999;

int func(int n)
{
  int r = inf, w;

  for(int i = 0; i <= 25; i++){
    for(int j = 0; j <= 17; j++){
      for(int k = 0; k <= 10; k++){
	w = i*200+j*300+k*500;
	if(n == w){
	  r = min(r, (i/5)*1520 + (i%5)*380 + 1870*(j/4) + (j%4)*550 + 2244*(k/3) + (k%3)*850);
	} else if(n < w){
	  break;
	}
      }
    }
  }

  return r;
}

int main()
{
  int n;

  while(cin >> n && n){
    cout << func(n) << endl;
  }

  return 0;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int r;cin>>r;

  if(r<1200){
    cout<<"ABC"<<endl;
  }else if(r<2800){
    cout<<"ARC"<<endl;
  }else{
    cout<<"AGC"<<endl;
  }

  return 0;
}


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

using namespace std;
typedef long long ll;

int T, n;
const int maxn = 300+5;

double p[maxn];
double dp[maxn][maxn][maxn]; // dp[1-cnt/2-cnt/3-cnt]
int cnt[4];

double dfs(int n, int i, int j, int k)
{
  if(dp[i][j][k]!=-1) return dp[i][j][k];
  double ans = double(n)/(i+j+k); //000 is not -1
  if(i>0) ans += (double(i)/(i+j+k))*dfs(n, i-1,j,k);
  if(j>0) ans += (double(j)/(i+j+k))*dfs(n, i+1,j-1,k);
  if(k>0) ans += (double(k)/(i+j+k))*dfs(n, i,j+1,k-1);
  return dp[i][j][k] = ans;
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for(int i = 0; i < 4; i++) cnt[i] = 0;
  int a;
  for(int i = 0; i < n; i++) cin >> a, cnt[a]++;
  for(int i = 0; i < maxn; i++)for(int j = 0; j < maxn; j++)for(int k = 0; k < maxn; k++)
    dp[i][j][k] = -1;
  dp[0][0][0] = 0;
  double ans = dfs(n, cnt[1], cnt[2], cnt[3]);
  cout << fixed << setprecision(10) <<  ans << endl;

  return 0;
}


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

int main(){
    int N, L, ans;
    std::cin >> N >> L;

    ans = (L - 1) * N + (N + 1)*N/2;

    if(L >= 0){
        ans = ans - L;
    }else if(L + N - 1 < 0){
        ans = ans - (L + N -1);
    }

    std::cout << ans;
}

Measured memory_bytes: 3656
#include <stdio.h>

int main(int ac, char **av) {
  char buf[256];
  unsigned long a, b, x, y, t, gcd;
  while(fgets(buf, 256, stdin) != NULL) {
    sscanf(buf, "%ld %ld", &a, &b);
    x = a;
    y = b;

    while(y) {
      t = y;
      y = x % y;
      x = t;
    }
    gcd = x;

    printf("%ld %ld\n", gcd, a*(b/gcd));
  }
  return 0;
}

Measured memory_bytes: 604
n=int(input())
s=str(input())
l=[]
cnt=0
ans=[]

for i in range(1,n):
    for j in range(i):
        if s[j] not in l:
            l.append(s[j])
    
    for j in range(i, len(s)):
        if s[j] in l:
            del l[l.index(s[j])]
            cnt+=1

    ans.append(cnt)
    
    l=[]
    cnt=0

print(max(ans))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  vector<string>p={"Sunny","Cloudy","Rainy"};
  bool ans=false;
  for(int i=0;i<2;i++){
	if(s==p[i]){
      cout<<p[i+1]<<endl;
      ans=true;
    }
  }
 if(ans==false) cout<<"Sunny"<<endl;
}

Measured memory_bytes: 256