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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

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;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;
    int cake_num[3];
    VVL cake(3);
    REP(i, 3) {
        cin >> cake_num[i];
        cake[i].resize(cake_num[i]);
    }
    cin >> k;
    REP(i, 3)REP(j, cake_num[i]) cin >> cake[i][j];

    VL cake_xy;
    REP(i, cake_num[0])REP(j, cake_num[1]) 
        cake_xy.push_back(cake[0][i] + cake[1][j]);
    sort(ALL(cake_xy), greater<ll>());
    VL cake_xyz;
    REP(i, min(k, (int)cake_xy.size()))REP(j, cake_num[2])
        cake_xyz.push_back(cake_xy[i] + cake[2][j]);
    sort(ALL(cake_xyz), greater<ll>());

    REP(i, k) cout << cake_xyz[i] << ln;
    return 0;
}


Measured memory_bytes: 43368
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cstdlib>
#include <cmath>
#include <string>
#include <ctime>
#include <cstring>
#include <queue>
#include <stack>
#define INT long long
#define oo 987654321
#define OO 9999999987654321ll
#define MOD 1000000007
using namespace std;

map<int, int> cnt;
INT ans = 1, n;
void f(INT x)
{
    for(int i=2; i<=x; i++)
    {
        while(x%i==0)
        {
            cnt[i]++;
            x=x/i;
        }
    }
}
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i = 2 ; i <= n ; i++ )
    {
        f(i);
    }
    for( auto p : cnt )
    {
        ans *= (p.second+1), ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {\
return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;
using ll = int64_t;

vector<int> A;
vector<int> B;

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

    A.resize(N);
    B.resize(N);

    REP(i, N)
    {
        cin >> A[i];
        B[i] = A[i] - i;
    }

    ALL(sort, B);

    ll sm = 0;

    int c = B[N / 2];

    REP(i, N)
    {
        sm += abs(B[i] - c);
    }

    cout << sm << endl;

    return 0;
}


Measured memory_bytes: 1792
{-# LANGUAGE BangPatterns #-}
import           Control.Monad
import           Control.Monad.State
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.List
import qualified Data.Vector.Unboxed         as VU
import qualified Data.Vector.Unboxed.Mutable as VUM

main :: IO ()
main = do
  [n,k] <- readLnAsListWith unconsInt
  hvec <- readLnAsUVecWith unconsInt n

  print $ VU.last $ solve1 n k hvec

  return ()


-- mutable vector を使うバージョン
solve1 :: Int -> Int -> VU.Vector Int -> VU.Vector Int
solve1 n k hvec = VU.create $ do
  dp <- VUM.replicate n 0
  forM_ [0..n-1] $ \i -> case i of
    0 -> VUM.write dp 0 0
    _ -> forM [(max (i-k) 0)..(i-1)] (\j -> liftM2 (+) (VUM.read dp j) (return . abs $ hvec VU.! i - hvec VU.! j)) >>=  VUM.write dp i . minimum
  return dp


-- https://atcoder.jp/contests/dp/submissions/5209611 を元に、微修正
solve2 :: Int -> Int -> VU.Vector Int -> VU.Vector Int
solve2 n k hvec = VU.constructN n $ \dp ->
  if VU.null dp
  then 0
  else let !i = VU.length dp
           !h_i = hvec VU.! i
       in VU.minimum $ VU.map (\(dp_j, h_j) -> dp_j + abs (h_i - h_j)) $ VU.drop (i-k) $ VU.zip dp hvec


unconsInt :: StateT BS.ByteString Maybe Int
unconsInt = StateT $ BS.readInt . BS.dropWhile isSpace

readLnAsListWith :: StateT BS.ByteString Maybe a -> IO [a]
readLnAsListWith !st = unfoldr (runStateT st) <$> BS.getLine

readLnAsUVecWith :: VU.Unbox a => StateT BS.ByteString Maybe a -> Int -> IO (VU.Vector a)
readLnAsUVecWith !st !n = VU.unfoldrN n (runStateT st) <$> BS.getLine

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


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

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; }
typedef long long ll;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(c>=a && c<=b) cout << "Yes";
    else if(c<=a && c>=b) cout << "Yes";
    else cout << "No";

}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        n: usize,
        a_vec: [usize; n],
    }

    let xor_all = (1..n).fold(a_vec[0], |acc, x| acc ^ a_vec[x]);

    for a in a_vec.into_iter() {
        println!("{}", xor_all ^ a)
    }
}


Measured memory_bytes: 6324
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
using namespace std;
#define INT_MAX 2147483647
#define INT_MIN (-2147483647 - 1)
#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e14
#define _INFLL (long long)-1e14
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

int main() {
	int n;
	cin >> n;
	vll a(n * 3);
	Loop(i, n * 3) cin >> a[i];
	sort(a.begin(), a.end());
	ll ans = 0;
	Loop(i, n) {
		ans += a[n + i * 2];
	}
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<vector>
using namespace std;
#define MST(vv,x) memset(vv,x,sizeof(vv))
#define ll long long
#define maxn 200010
vector<int>vec[maxn];
bool judge[maxn];
ll n;
ll s1[maxn];
int tempall;
int flag;
void dfs(int x,int all)
{
    if(flag)return;
    s1[all]=x;
    if(x==n)
    {
        tempall=all;
        flag=1;
        return;
    }
    for(int a=0; a<vec[x].size(); a++)
    {
        if(judge[vec[x][a]]&&flag==0)
        {
            judge[vec[x][a]]=false;
            dfs(vec[x][a],all+1);
            if(!flag)
            judge[vec[x][a]]=true;
        }
    }
    return ;
}
int ddfs(int x)
{
    int sum=0;
    for(int a=0;a<vec[x].size();a++)
    {
        if(judge[vec[x][a]])
        {
            sum++;
            judge[vec[x][a]]=false;
            sum+=ddfs(vec[x][a]);
        }
    }
    return sum;
}
int main()
{
    while(scanf("%lld",&n)!=EOF)
    {
        tempall=0;
        for(ll a=0;a<maxn;a++)
            vec[a].clear();
        for(ll a=1; a<n; a++)
        {
            ll x,y;
            cin>>x>>y;
            vec[x].push_back(y);
            vec[y].push_back(x);
        }
        MST(judge,true);
        flag=0;
        judge[1]=false;
        dfs(1,1);
        int sum=tempall/2;
        for(int a=1; a<=tempall/2; a++)
        {
            int tempnum=s1[a];
            for(int b=0; b<vec[tempnum].size(); b++)
            {
                if(tempall%2==0)
                if(vec[tempnum][b]==s1[tempall/2+1])
                    continue;
                if(judge[vec[tempnum][b]])
                {
                    judge[vec[tempnum][b]]=false;
                    sum++;
                    sum+=ddfs(vec[tempnum][b]);
                }
            }
        }
        if(tempall%2)
        {
            sum++;
            int tempnum=s1[tempall/2+1];
            for(int b=0; b<vec[tempnum].size(); b++)
            {
                if(vec[tempnum][b]==s1[tempall/2+2])
                    continue;
                if(judge[vec[tempnum][b]])
                {
                    judge[vec[tempnum][b]]=false;
                    sum++;
                    sum+=ddfs(vec[tempnum][b]);
                }
            }
        }

        if(sum>n-sum)cout<<"Fennec"<<endl;
        else cout<<"Snuke"<<endl;
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;
typedef vector<pp> vpp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()
#define pb push_back

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

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


template <typename T>
void printV(vector<T> A) {
  if (A.empty()) cerr << "EMTPY\n";
  else { 
    cerr << "[";
    for (int i = 0; i < A.size() -1 ; ++i) {
      cerr << A[i] << ", ";
    }
    if (A.size()) cerr << A.back() << "]\n";
  }
}


template <typename T>
void printVV(vector<vector<T>> A) {
  cerr << "[";
  for (auto v : A) {
    printV<T>(v);
  }
  cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

vector<int> cost;
vector<vector<int>> A;
vector<int> cur;
vll dp;

int n, m, x;

int main(int argc, char **argv) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> x;

  cost = vi(n);
  A = vvi(n, vi(m));
  dp = vll(1 << n, -1);
  cur = vi (m,0);


  for (int i = 0; i < n; ++i) {
    int c; cin >> c;
    cost[i] = c;
    for (int j = 0; j < m; ++j) {
      cin >> A[i][j];
    }
  }

  ll ret = 1 << 30;
  for (int bits = 0; bits < (1 << n); ++bits) {
    ll totalcost = 0;
    vector<int> d(m);
    for (int i = 0; i < n; ++i) {
      if (bits & (1 << i)) {
        for (int j = 0; j < m; ++j) d[j] += A[i][j];
        totalcost += cost[i];
      }
    }
    bool ok = true;
    for (int j = 0; j < m; ++j) {
      if (d[j] < x) {
        ok = false;
        break;
      }
    }
    if (ok) ret = min(ret, totalcost);
  }

  cout << (ret == (1 << 30) ? -1 : ret) << endl;


  return 0;
}



Measured memory_bytes: 3664
N = int(input())
H = list(map(int,input().split()))
ans = 0
i = 0
cnt = 0
for i in range(N-1):
    if H[i] >= H[i+1]:
       cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 0
ans = max(ans, cnt)
print(ans)

Measured memory_bytes: 14224
#include<bits/stdc++.h>
#define sz(a) int((a).size())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
#define ld(a) while(a--)
#define tci(v,i) for(auto i=v.begin();i!=v.end();i++)
#define tcf(v,i) for(auto i : v)
#define all(v) v.begin(),v.end()
#define rep(i,start,lim) for(long long (i)=(start);i<(lim);i++)
#define repd(i,start,lim) for(long long (i)=(start);i>=(lim);i--)
#define present(c,x) (find(all(c),x) != (c).end())
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define osit ostream_iterator
#define INF 		0x3f3f3f3f
#define LLINF       1000111000111000111LL
#define PI 			3.14159265358979323
#define endl '\n'
#ifdef WIN32
#define getchar_unlocked getchar
#endif
#define gc getchar
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define N 1000006
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long int ll;
typedef vector<long long int> vll;
typedef vector<vll> vvll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef tuple<int,int,int> iii;
typedef set<int> si;
typedef complex<double> pnt;
typedef vector<pnt> vpnt;
typedef priority_queue<ii,vii,greater<ii> > spq;
const ll MOD=1000000007LL;
template<typename T> T sqr(T x){return x*x;}
template<typename T> T gcd(T a,T b){if(a==0) return b; return gcd(b%a,a);}
template<typename T>void read(T &x) { register T c = gc(); x = 0; int t = 0; if (c == '-') t = 1, c = gc(); for (; (c < 48 || c>57); c = gc()); for (; c > 47 && c < 58; c = gc()) { x = (x << 1) + (x << 3) + c - 48; }if (t) x = -x; }
template<typename T> T pow(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y%2==1) ans=(ans*x)%m;y/=2;x=(x*x)%m;}return ans%m;} //using this instead of inbuilt pow due to precision issues in that
template<typename T> ll roundp(T x){ll ans=x;if(x-floor(x)<=0.001) ans=floor(x);else if(ceil(x)-x<=0.001) ans=ceil(x);return ans;}

int main(){
	ll n,m; cin>>n>>m;
	if(m<=2*n){
		cout<<m/2<<endl; return 0;
	}
	ll ans=n;
	m-=2*n;
	ans+=m/4;
	cout<<ans<<endl;
}


Measured memory_bytes: 256
N, M, L = [int(n) for n in input().split()]
A = []
for i in range(N):
  A.append([int(n) for n in input().split()])

B = []
for j in range(M):
  B.append([int(n) for n in input().split()])
BB = [list(b) for b in zip(*B)]

for i in range(N):
  x = []
  for j in range(L):
    x.append(sum([a*b for a,b in zip(A[i], BB[j])]))
  print(*x)



Measured memory_bytes: 6664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;

int main() {
    string S, T, Sa, S_, Smi;
    cin >> S >> T;
    int slen = S.length(), tlen = T.length();
    for(int i = 0; i < slen; ++i)
        Sa += S[i] == '?' ? 'a' : S[i];
    for(int i = 0; i <= slen - tlen; ++i) {
        S_ = Sa;
        bool confl = false;
        for(int j = 0; j < tlen; ++j) {
            if(S[i + j] != '?' && S[i + j] != T[j]) {
                confl = true;
                break;
            }
            S_[i + j] = T[j];
        }
        if(confl)
            continue;
        if(Smi.empty()) {
            Smi = S_;
            continue;
        }
        Smi = min(Smi, S_);
    }
    cout << (Smi.empty() ? "UNRESTORABLE" : Smi) << endl;
    return 0;
}


Measured memory_bytes: 256
# 1からスタートしてBFS、道しるべのない部屋に到達したら、親の番号を道しるべとして設定する

import sys
readline = sys.stdin.readline

N,M = map(int,readline().split())
G = [[] for i in range(N)]
for i in range(M):
  a,b = map(int,readline().split())
  G[a-1].append(b-1)
  G[b-1].append(a-1)

from collections import deque
q = deque([])
q.append([0,-1])
ans = [-1 for i in range(N)]
while q:
  v,parent = q.popleft()
  if ans[v] != -1:
    continue
  ans[v] = parent + 1
  for child in G[v]:
    if child == parent:
      continue
    q.append([child,v])

for i in range(1,len(ans)):
  if ans[i] == -1:
    print("No")
    exit(0)
print("Yes")
for i in range(1,len(ans)):
  print(ans[i])

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

#define ll long long
#define pb push_back
#define MOD 1000000007
#define MAX 200005

char str[100010];
char str1[10010],str2[10010];

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    int q,com,key;
    map<string,int>mp;
    string ss,s1,s2;

    scanf("%d",&q);

    while(q--)
    {
        scanf("%d",&com);
        if(com == 0)
        {
            scanf("%s %d",str,&key);
            ss = str;
            mp[ss] = key;
        }
        else if(com == 1)
        {
            scanf("%s",str);
            ss = str;
            int res = 0;
            if(mp.find(ss)!=mp.end())
                res = mp[ss];
            printf("%d\n",res);
        }
        else if(com == 2)
        {
            scanf("%s",str);
            ss = str;
            if(mp.find(ss)!=mp.end())
            {
                mp.erase(ss);
            }
        }
        else if(com == 3)
        {
            scanf("%s %s",str1,str2);
            s1 = str1;
            s2 = str2;
            vector<string>res;
            auto low = mp.lower_bound( s1 );
            auto upper = mp.upper_bound( s2 );

            if ( low != upper )
            {
                for ( auto it = low; it != upper; ++it )
                {
                    cout << it->first << ' ' << it->second << "\n";
                }
            }
        }
    }

    return 0;
}



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

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

  int minVal = 1000000000;
  int maxVal = 1;
  int d;
  for(int i = 0; i < n; i++){
    cin >> d;
    minVal = min(d, minVal);
    maxVal = max(d, maxVal);
  }
  cout << maxVal - minVal << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin>>n;
  vector<vector<ll>>a(n,vector<ll>(n));
  rep(i,n)rep(j,n)
  {
    cin>>a[i][j];
  }
  vector<ll>weight(1<<n,0);
  rep(i,1<<n)
  {
    vector<ll>mem;
    rep(j,n)
    {
      if(i&(1<<j))
      {
        mem.push_back(j);
      }
    }
    rep(j,mem.size())
    {
      repi(k,j+1,mem.size())
      {
        weight[i]+=a[mem[j]][mem[k]];
      }
    }
  }
  vector<ll>dp(1<<n,0);
  rep(i,1<<n)
  {
    vector<int>bit;
    rep(j,n)if(i&(1<<j))bit.push_back(1<<j);
    rep(j,1<<bit.size())
    {
      int cal=0;
      rep(k,bit.size())if(j&(1<<k))cal+=(bit[k]);
      chmax(dp[i],dp[i-cal]+weight[cal]);
    }
  }
  cout<<dp[(1<<n)-1]<<endl;


  return 0;

}


Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int w, h, x, y;
	cin >> w >> h >> x >> y;
	if((double)x == (double)w/2 && (double)y == (double)h/2){
		cout << fixed << setprecision(11) << (double)w*h/2;
		cout << " " << 1 << endl;
	}else{
		cout << fixed << setprecision(11) << (double)w*h/2;
		cout << " " << 0 << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;
ll const MOD=1000000007;

int N,M;
int a[200001];
int b[200001];
int cnt[200001];

int main(){
    cin>>N>>M;
    repn(i,M) cin>>a[i]>>b[i];

    repn(i,M){
        if(a[i]==1 || a[i]==N) cnt[b[i]]++;
        if(b[i]==1 || b[i]==N) cnt[a[i]]++;
    }

    string ans="IMPOSSIBLE";
    repn(i,N){
        if(cnt[i]==2){
            ans="POSSIBLE";
            break;
        }
    }

    cout<<ans<<endl;
}

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

int h, w;
int grid[92][92];
int dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };

int dfs(int x, int y, int r) {
	int res = r;
	for (int i = 0; i < 4; ++i) {
		int nx = x + dx[i];
		int ny = y + dy[i];
		if (grid[ny][nx]) {
			grid[ny][nx] = 0;
			res = std::max(res, dfs(nx, ny, r + 1));
			grid[ny][nx] = 1;
		}
	}
	return res;
}

int solve() {
	int ans = 0;
	for (int i = 1; i <= w; ++i) {
		for (int j = 1; j <= h; ++j) {
			if (grid[i][j]) {
				grid[i][j] = false;
				ans = std::max(ans, dfs(j, i, 1));
				grid[i][j] = true;
			}
		}
	}
	return ans;
}

int main() {
	while (1) {
		std::cin >> w >> h;
		if (w + h == 0)
			break;
		for (int i = 1; i <= h; ++i) {
			for (int j = 1; j <= w; ++j)
				std::cin >> grid[i][j];
		}
		std::cout << solve() << std::endl;
	}
	return 0;
}

Measured memory_bytes: 3048
#include<bits/stdc++.h>
using namespace std;
struct compare
{
    bool operator()(const int& first, const int& second)
    {
        return first>second;
    }
};
void solve()
{
    long long a, b;
    cin>>a>>b;
    int x= a*b;
    int y = a+b;
    int z= a-b;
    int mx = max(x,y);
    cout<<max(z,mx)<<endl;

}

int main()
{
    int t;
    t=1;
    while(t--)
    {
        solve();

    }
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <map>
#include <list>
#define MOD 1000000007
#define INF 1000000000
typedef long long ll;
using namespace std;
typedef pair<int,int> P;

int main(void){
    string s,t;
    cin>>s>>t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    //cout<<s<<endl<<t<<endl;
    if(s<t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
open System
open System.Collections.Generic

[<AutoOpen>]
module Cin =
    let read f = stdin.ReadLine() |> f
    let reada f = stdin.ReadLine().Split() |> Array.map f
    let readChars() = read string |> Seq.toArray
    let readInts() = readChars() |> Array.map (fun x -> Convert.ToInt32(x.ToString()))

[<AutoOpen>]
module Cout =
    let writer = new IO.StreamWriter(new IO.BufferedStream(Console.OpenStandardOutput()))
    let print (s: string) = writer.Write s
    let println (s: string) = writer.WriteLine s
    let inline puts (s: ^a) = string s |> println

let main() =
    let n = read int
    let ps = reada int
    let acc = Array.init (n + 1) (fun _ -> Int32.MaxValue)
    for i in 0 .. n - 1 do
        acc.[i + 1] <- min acc.[i] ps.[i]

    let mutable ans = 0
    for i in 0 .. n - 1 do
        let pi = ps.[i]
        let pj = acc.[i + 1]
        if pi <= pj then ans <- ans + 1

    ans |> puts
    ()

main()
writer.Close()


Measured memory_bytes: 36316
#include<bits/stdc++.h>
using namespace std;
char str[5];
int ans=0,now=0;
int main(){
	cin>>str+1;
	for(int i=1;i<=3;i++){
		if(str[i]=='R')now++;
		else now=0;
		ans=max(ans,now);
	}
	cout<<max(ans,now);
} 

Measured memory_bytes: 3628
/*       _________
        /|______/ \
        ||  _|_|\  |
        || |_|   | /
        ||    _ / |
        ||  _| \\  \    
        ||_|_|\ || |
        |/_|/ | /|_/
              /__/      Written by: Rishabh Roshan
*/
#include<bits/stdc++.h>
#include<time.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int            	long long
#define integer        	int32_t
#define mod         	1000000007
#define vint        	vector<int>
#define pint        	pair<int, int>
#define umint        	unordered_map<int, int>
#define mint        	map<integer, integer>
#define in(x)        	int x; cin>>x
#define setbits(x)    	__builtin_popcountll(x)
#define zerobits(x)    	__builtin_ctzll(x)
#define w(x)        	int x; cin>>x; while(x--)
#define sp(x, y)    	fixed<<setprecision(y)<<x
#define poll(x)        	x.front(); x.pop()
#define f(x)        	for(int i=0; i<x; i++)
#define fj(x)			for(int j=0; j<x; j++)
#define fn(n, x)		for(int i=n; i<x; i++)
#define endl         	'\n'
#define inf         	1e9 
#define order_set     	tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

// #include "functions.h"

void om_shree_ganeshaya_namah(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int32_t main() {

    om_shree_ganeshaya_namah();

    in(n);
    vint dp(1<<n), pre(1<<n);
    vector<vint> arr(n, vint(n));
    f(n) fj(n) cin>>arr[i][j];

    for(int i=0; i<(1<<n); i++){
    	int sum=0;
    	for(int j=0; j<n; j++){
    		if(i&(1<<j)){
    			for(int k=j+1; k<n; k++){
    				if(i&(1<<k))
    					sum+=arr[j][k];
    			}
    		}
    	}
    	pre[i] = sum;
    }

    for(int i=0; i<(1<<n); i++){
    	vint pos;	//position not selected yet...
    	fj(n)  if(!(i&(1<<j))) pos.push_back(j);

    	int size = pos.size();
    	for(int j=0; j<(1<<size); j++){
    		int mask=0;
    		for(int k=0; k<size; k++){
    			if(j&(1<<k))
    				mask|=(1<<pos[k]);
    		}
    		dp[mask|i] = max(dp[mask|i], pre[mask]+dp[i]);	
    	}
    }

    cout<<dp[(1<<n)-1];
}

Measured memory_bytes: 4264
#Beginner 047 B
W, H, N = map(int, input().split())

s = [input() for i in range(N)]
S = []
for i in range(N):
    S.append(list(map(int, s[i].split())))

lst = [[1 for i in range(W)] for j in range(H)]

for i in range(N):
    if S[i][2] == 1:
        for j in range(0,S[i][0]):
            for k in range(H):
                lst[k][j] = 0
    if S[i][2] == 2:
        for j in range(S[i][0],W):
            for k in range(H):
                lst[k][j] = 0
    if S[i][2] == 3:
        for j in range(0,S[i][1]):
            for k in range(W):
                lst[j][k] = 0
    if S[i][2] == 4:
        for j in range(S[i][1],H):
            for k in range(W):
                lst[j][k] = 0

print(sum(lst,[]).count(1))


Measured memory_bytes: 3520
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	x := r.nextStringArray().toInts()

	for i, v := range x {
		if v == 0 {
			fmt.Fprintln(stdout, i+1)
			break
		}
	}

}


Measured memory_bytes: 1752
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
	int a[200200];
	rep(i, N) cin >> a[i + 1];
	int M = 0;
	set<int> b;
	for(int i = N ; i >= 1; i--) {
		int l = 2 * i, cnt = 0;
		while(l <= N) {
			if(b.find(l) != b.end()) {
				cnt ++;
			}
			l += i;
		}
		cnt %= 2;
		if(cnt != a[i]) {
			b.insert(i);
			M ++;
		}
	}
	cout << M << endl;
	rep1(i, N) {
		if(b.find(i) != b.end()) {
			cout << i << " ";
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 7808
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
// const long long INF = 1LL<<60;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }
void sub(long long &a, long long b) { a -= b; if (a < 0) a += MOD; }
void mul(long long &a, long long b) { a *= b; a %= MOD; }
ll llmin(ll a, ll b) { if (a < b) return a; else return b; }
ll llmax(ll a, ll b) { if (a < b) return b; else return a; }
ll llabs(ll a) { if (a >= 0) return a; else return - a; }
ll llmodpow(ll a, ll n) {
   if (n == 0) return 1;
   ll tmp = llmodpow(a, n / 2);
   mul(tmp, tmp);
   if (n & 1) mul(tmp, a);
   return tmp;
}

ll dpe[52], dpo[52];

int main() {
   int N, P;
   cin >> N >> P;
   int A[N];
   for (int i = 0; i < N; i++) cin >> A[i];
   
   memset(dpe, 0, sizeof(dpe));
   memset(dpo, 0, sizeof(dpo));
   dpe[0] = 1;
   dpo[0] = 0;
   for (int i = 0; i < N; i++) {
      if (A[i] % 2 == 0) {
         dpe[i + 1] = 2 * dpe[i];
         dpo[i + 1] = 2 * dpo[i];
      } else {
         dpe[i + 1] = dpe[i] + dpo[i];
         dpo[i + 1] = dpo[i] + dpe[i];
      }
      // cout << i + 1 << " " << dpe[i + 1] << " " << dpo[i + 1] << endl;
   }
   if (P == 1) cout << dpo[N] << endl;
   else cout << dpe[N] << endl;
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define double long double
using namespace std;
typedef vector<double> vec;
typedef vector<vec> mat;
const double EPS=1E-6;

vec gauss_jordan(const mat& A,const vec& b){
  int n=A.size();
  mat B(n,vec(n+1));
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)B[i][j]=A[i][j];
  for(int i=0;i<n;i++)B[i][n]=b[i];
  for(int i=0;i<n;i++){
    int pivot=i;
    for(int j=i;j<n;j++)
      if(abs(B[j][i])>abs(B[pivot][i]))pivot=j;
    swap(B[i],B[pivot]);

    if(abs(B[i][i])<EPS)return vec();

    for(int j=i+1;j<=n;j++)B[i][j]/=B[i][i];
    for(int j=0;j<n;j++){
      if(i!=j)
	for(int k=i+1;k<=n;k++)B[j][k]-=B[j][i]*B[i][k];
    }
  }
  vec x(n);
  for(int i=0;i<n;i++)x[i]=B[i][n];
  return x;
}

int D;
vec calc(int d){
  vec res(D+1);
  for(int i=D,n=1;i>=0;i--,n*=d)res[i]=n;
  return res;
}

double calc(vector<double> A,int d){
  double res=0;
  for(int i=0,n=1;i<(int)A.size();i++,n*=d)res+=A[A.size()-1-i]*n;
  return res;
}


int main(){
  while(cin>>D,D){

    vec f(D+3);
    for(int i=0;i<=D+2;i++)cin>>f[i];
  
    mat A(D+3);
    vector<int> ord(D+3);
    for(int i=0;i<=D+2;i++)A[i] = calc(i),ord[i] = i;

    mat X;    
    vec Y;
    int idx=-1;
    for(int i=0;i<=D+2&&idx==-1;i++){
      for(int j=0;j<=D+2&&idx==-1;j++){
	if(i==j)continue;
	X.clear(),Y.clear();
	for(int k=0;k<=D+2;k++)
	  if(k!=i&&k!=j)X.push_back(A[k]),Y.push_back(f[k]);

	vec ans=gauss_jordan(X,Y);
	if(ans.size()==0)continue;
	int cnt=0;
	for(int k=0;k<=D+2;k++)if(abs(calc(ans,k)-f[k])>1e-5)idx = k,cnt++;
	if(cnt!=1)idx=-1;
      }
    }
    cout<<idx<<endl;
  }
  return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String t = sc.next();
		sc.close();
		char[]c1 = s.toCharArray();
		char[]c2 = t.toCharArray();
		Arrays.sort(c1);
		Arrays.sort(c2);
		StringBuilder sb = new StringBuilder(new String(c2));
		sb.reverse();
		String a = new String(c1);

		if(a.compareTo(sb.toString()) < 0) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21840
h,w=map(int,input().split())
lst=list(input() for i in range(h))
n_h=h
for i in range(len(lst)):
    if "#" not in lst[h-i-1]:
        n_h-=1
        lst.pop(h-i-1)
lst=list(map(list,lst))
for i in range(w):
    T=True
    for b in range(n_h):
        if lst[b][w-i-1]=="#":
            T=False
            break
    if T:
        for b in range(n_h):
            lst[b].pop(w-i-1)
for a in lst:
    print("".join(a))

Measured memory_bytes: 3188
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	x, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}

	scanner.Scan()
	y, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}

	fmt.Printf("%d\n", x*y)

}


Measured memory_bytes: 1776
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

int main() {
  int a, p;
  scan(a, p);
  int ans = (a * 3 + p) / 2;
  print(ans);

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int Y = sc.nextInt();
		String s = "No";
		for(int i=0; i<=X; i++) {
			int j = X-i;
			if(i*2 + j*4 == Y) {
				s = "Yes";
				break;
			}

		}
		sc.close();
		System.out.println(s);
	}

}

Measured memory_bytes: 35548
from itertools import product

H, W, N = 0, 0, 0
filled = {}

def boundary_check(pos):
    """
    (x, y) -> bool
    """
    return pos[0] < W - 2 and pos[1] < H - 2 and pos[0] >= 0 and pos[1] >= 0

def matrix_cell_in(a, b):
    """
    int -> int -> (int, int)

    塗りつぶされたセルの座標から、そのセルが含まれる 3 * 3 連続セルの集合を返す。
    3 * 3 連続セルは左上セルの座標で表現する。
    """
    matrixes = list(product(range(a-2,a+1),(range(b-2, b+1))))
    return list(filter(boundary_check ,matrixes))
    # return matrixes

def fill(pos, cell):
    """
    (int, int) -> unit

    3 * 3連続セルの座標を受け取って、その中の黒マスの数を増やす。まだ塗られていなかった場合は 1 にする。
    """
    if pos in filled:
        filled[pos] += 1
    else:
        filled[pos] = 1


H, W, N = map(int, input().split(" "))

for i in range(N):
    b, a = map(int, input().split(" "))
    a, b = a-1, b-1
    for cell in matrix_cell_in(a,b):
        fill(cell, (a,b))

results = [0 for _ in range(10)]
for v in filled.values():
    results[v] += 1

results[0] =  (H - 2) * (W - 2)  - sum(results)

for r in results:
    print(r)

Measured memory_bytes: 137952
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define pb push_back
#define fi first
#define se second
#define int long long
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 1e5+5, MOD = 998244353;
int t,n,m,k,x,y;
 
int h[LIM];
int dp[LIM];


int32_t main()
{
	IOS;
	cin>>n;
	forn(i,n) cin>>h[i+1];
	memset(dp,1e9 +5,sizeof(dp));
	dp[1]=0;
	for(int i=1;i<=n-1;i++){
		dp[i+1]=min({dp[i+1],dp[i]+abs(h[i]-h[i+1])});
		if(i+2<=n){
			dp[i+2]=min({dp[i+2],dp[i]+abs(h[i]-h[i+2])});
		}
	}
	cout<<dp[n]<<ln;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <map>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)

#define rep(i, a, b) for (ll i = a; i < (ll)b; ++i)
#define INF 10e12
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))

int main(void)
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    sort(all(a));
    map<ll, int> mp;
    rep(i, 0, n) mp[a[i]]++;
    int ans = 0;
    for (auto i : mp)
    {
        if (i.first > i.second)
            ans += i.second;
        else
            ans += min((ll)i.second, i.second - i.first);
    }
    cout << ans << endl;
}


Measured memory_bytes: 7040
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,0,n)cin>>v[i];
    Sort(v);
    
    rep(i,0,n){
        rep(j,i+1,n){
            if((v[j]-v[i])%(n-1)==0){
                cout<<v[i]<<" "<<v[j]<<endl;
                return 0;
            }
        }
    }
    
    return 0;
}



Measured memory_bytes: 3168
#include <stdio.h>

int main(void)
{
    int n, d;
    int i;

    while (1)
    {
        int sum = 0, min, max;
        scanf("%d", &n);
        if (n == 0)
            break;

        for (i = 0; i < n; i++)
        {
            scanf("%d", &d);
            if (i == 0)
            {
                max = d;
                min = d;
            }
            if (d > max)
                max = d;
            if (d < min)
                min = d;
            sum += d;
        }
        sum -= max + min;
        printf("%d\n", sum / (n - 2));
    }
    return 0;
}


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

int64_t mod = 1e9+7;

int64_t DP[5][5][2000000];

int64_t f(int rem, bool z, bool n) {
	if (rem == 0) {
		return z && n;
	}
	if (DP[z][n][rem] != -1) return DP[z][n][rem];
	if (z) {
		if (n) {
			return DP[z][n][rem] = ((f(rem-1, 1, 1)*10))%mod;
		}
		return DP[z][n][rem] = ((f(rem-1, z, n)*9)+(f(rem-1, 1, 1)))%mod;
	} else if (n) {
		return DP[z][n][rem] = ((f(rem-1, z, n)*9)+(f(rem-1, 1, 1)))%mod;
	} else {
		return DP[z][n][rem] = ((f(rem-1, z, n)*8)+(f(rem-1, 1, 0))+(f(rem-1, 0, 1)))%mod;
	}
}

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

	int N;
	cin >> N;

	memset(DP, -1, sizeof DP);

	cout << f(N,0,0) << endl;
}

Measured memory_bytes: 425400
#!/usr/bin/env python3
#ABC131 E

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()

if k > (n-1)*(n-2)//2:
    print(-1)
    quit()
print((n-1)*(n-2)//2 + (n-1) - k)
for i in range(n-1):
    print(1,i+2)

a,b = 2,3
for _ in range((n-1)*(n-2)//2 - k):
    print(a,b)
    b += 1
    if b > n:
        a += 1
        b = a+1


Measured memory_bytes: 42736
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1)*a%MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1)*a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b,a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size()>n) return kaijo_memo[n];
  if(kaijo_memo.size()==0) kaijo_memo.push_back(1);
  while(kaijo_memo.size()<=n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1]*kaijo_memo.size()%MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size()>n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size()==0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size()<=n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1]*mpow(gyaku_kaijo_memo.size(),MOD-2)%MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n==r) return 1;
  if(n<r ||r<0) return 0;
  ll ret = 1;
  ret *= kaijo(n); ret %= MOD;
  ret *= gyaku_kaijo(r); ret %= MOD;
  ret *= gyaku_kaijo(n-r); ret %= MOD;
  return ret;
}

signed main(){
	ll n; cin>>n;
	VI a(n+1); bool t[n+5]; memset(t,false,sizeof(t));
	int w=0, l=0, r=0;
	rep(i,n+1){
		cin>>a[i];
		if(t[a[i]]) w=a[i], r=i;
		else t[a[i]]=true;
	}
	rep(i,n){
		if(a[i]==w){
			l=i; break;
		}
	}
	for(ll k=1;k<=n+1;k++){
		ll x = (nCr(n+1,k)-nCr(n-r+l,k-1)+2*MOD)%MOD;
		cout<<x<<endl;
	}
	return 0;
}


Measured memory_bytes: 3444