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

const int INF = 1e9;
const int N = 1e3 + 5;

int h, w, stx, sty, enx, eny;
char grid[N][N];
int d[N][N];
std::priority_queue<std::tuple<int, int, int>> q;

bool inside(int x, int y) {
    return 1 <= x && x <= y;
}

void Dijkstra() {
    std::fill(*d, *d + N * N, INF);
    d[stx][sty] = 0;
    q.emplace(0, stx, sty);

    while (!q.empty()) { 
        auto [dxy, x, y] = q.top();
        q.pop();
        if (dxy > d[x][y]) continue;

        for (int dx = -2; dx <= 2; dx++) {
            int nx = x + dx;
            if (!inside(nx, h)) continue;

            for (int dy = -2; dy <= 2; dy++) {
                int ny = y + dy;

                if (!inside(ny, w)) continue;
                if (grid[nx][ny] == '#') continue;

                int dt = d[x][y] + (abs(dx) + abs(dy) > 1);
                if (d[nx][ny] > dt) {
                    d[nx][ny] = dt;
                    q.emplace(-dt, nx, ny);
                }
            }
        }
    }
}

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

    std::cin >> h >> w >> stx >> sty >> enx >> eny;

    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            std::cin >> grid[i][j];
        }
    }

    Dijkstra();

    if (d[enx][eny] == INF) std::cout << -1;
    else std::cout << d[enx][eny];

    return 0;
}

Measured memory_bytes: 8616
io = STDIN
N=io.gets.to_i
A=io.gets.split.map(&:to_i)
uniq=A.uniq
hash=Hash.new{|h,k|h[k]=0}
if uniq.size==1 && uniq[0]==0
  puts 'Yes'
else
  A.each {|a|hash[a]+=1}
  k=hash.keys.sort
  v=hash.values.sort
  if (hash.size==3 &&
      N % 3 == 0 &&
      k[0]^k[2] ==k[1] &&
      hash.values.uniq.size==1)  # 1,2,3
      puts 'Yes'
  elsif (hash.size==2 &&
         N % 3 == 0 &&
         v[0]*2 == v[1])      # 0 1 1
    puts 'Yes'
  else
    puts 'No'
  end
end


Measured memory_bytes: 15532
//verma_ankit484

#include<bits/stdc++.h>

typedef long long ll;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const ll mod = (ll) 1e9+7;

using namespace std;

int main() {
  IOS
  #ifdef AV
  freopen("int.txt", "r", stdin);
  #endif
  ll n;
  cin >> n;
  ll ans = n/2;
  if (n%2 == 0) {
    cout << ans-1 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define db long double
#define pii pair<int,ll>
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define vi vector<int>
#define lb lower_bound
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,b,a) for(int i=(b);i>=(a);--i)
#define rep0(i,a,b) for(int i=(a);i<(b);++i)
#define fore(i,a) for(int i=0;i<a.size();++i)
#define ls x<<1,l,m
#define rs x<<1|1,m+1,r
#define gc() getchar()
inline int rd()
{
	int x=0,w=1;char c=gc();while(!isdigit(c)&&c!='-')c=gc();
	if(c=='-')w=-1,c=gc();while(isdigit(c))x=x*10+c-48,c=gc();return x*w;
}
const int N=100005,M=1<<19,P=998244353,iv2=(P+1)/2;
int n,s[N],sg[N],a[M],b[M],c[M],d[M];vi g[N];
inline int pw(int a,int b){int r=1;for(;b;b>>=1,a=1ll*a*a%P)if(b&1)r=1ll*r*a%P;return r;}
inline void fwt(int n,int*a,int o)
{
	for(int i=2;i<=n;i<<=1)for(int j=0;j<n;j+=i)rep0(k,0,(i>>1))
	{
		int x=a[j+k],y=a[j+k+(i>>1)];
		a[j+k]=(x+y)%P;a[j+k+(i>>1)]=(x+P-y)%P;
		if(o==-1)
		{
			a[j+k]=1ll*a[j+k]*iv2%P;
			a[j+k+(i>>1)]=1ll*a[j+k+(i>>1)]*iv2%P;
		}
	}
}
void calc(int n,int*a)
{
	int m=rd();rep(i,1,n)g[i].clear();
	rep(i,1,m){int u=rd(),v=rd();if(u>v)swap(u,v);g[u].pb(v);}
	per(i,n,1)
	{
		for(int x:g[i])s[sg[x]]++;
		sg[i]=0;while(s[sg[i]])sg[i]++;
		for(int x:g[i])s[sg[x]]--;
		a[sg[i]]=(a[sg[i]]+pw(10,18*i))%P;
	}
}
int main()
{
	n=rd();calc(n,a);calc(n,b);calc(n,c);
	fwt(M,a,1);fwt(M,b,1);fwt(M,c,1);
	rep0(i,0,M)d[i]=1ll*a[i]*b[i]%P*c[i]%P;
	fwt(M,d,-1);printf("%d\n",d[0]);return 0;
}

Measured memory_bytes: 13824
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define FOR(i, a, b) for (int i=(a); i<(b); ++i)
#define ROF(i, b, a) for (int i=(b); i>(a); --i)
#define CASET int _T; cin >> _T; FOR(caset, 0, _T)
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vvi vector<vi>
#define vvb vector<vb>
#define pii pair<int,int>
#define t3i tuple<int,int,int>
#define mii map<int,int>
#define vpii vector<pii>
#define vt3i vector<t3i>
#define sq(x) (x)*(x)
#define inv(x) powa(x, MOD-2)
 
long long INF = 1LL<<60;
long long MOD = 1e9+7;

template <typename A, typename B> istream &operator>>(istream &is, pair<A, B> &pr) {is >> pr.first >> pr.second; return is;}
template <typename A> istream &operator>>(istream &is, vector<A> &v) {for (auto &x : v) is >> x; return is;}
ostream &operator<<(ostream &os, char &c) {os << (char)c; return os;}
ostream &operator<<(ostream &os, const char s[]) {os << (string)s; return os;}
ostream &operator<<(ostream &os, string &s) {for (char &c : s) os << (char)c; return os;}
template <typename A, typename B> ostream &operator<<(ostream &os, pair<A, B> &pr) {os << '(' << pr.first << ", " << pr.second << ')'; return os;}
ostream &operator<<(ostream &os, vb &v) {
    bool first = true;
    os << '[';
    for (const bool &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
template <class C> ostream &operator<<(ostream &os, C &v) {
    bool first = true;
    os << '[';
    for (auto &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}
bool mini(int &a, int b) { return b < a ? a = b, 1 : 0; }
bool maxi(int &a, int b) { return b > a ? a = b, 1 : 0; }

main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    int R, C;
    cin >> R >> C;

    vs grid(R, string(C, ' '));
    cin >> grid;

    vi dr = {0, 0, 1, -1};
    vi dc = {1, -1, 0, 0};
    
    int res = 0;
    FOR(sr, 0, R) FOR(sc, 0, C) if (grid[sr][sc] != '#') {
        deque<pii> q = {{sr, sc}};
        vvi dist(R, vi(C, -1));
        dist[sr][sc] = 0;
        while (q.size()) {
            int r, c;
            tie(r, c) = q.front();
            q.pop_front();

            FOR(d, 0, 4) {
                int rr = r + dr[d];
                int cc = c + dc[d];
                if (rr < 0 || rr >= R || cc < 0 || cc >= C || grid[rr][cc] == '#' || dist[rr][cc] != -1) continue;
                dist[rr][cc] = dist[r][c] + 1;
                maxi(res, dist[rr][cc]);
                q.push_back({rr, cc});
            }
        }
    }
    cout << res;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define PRINT(a)   cout << (a) << endl
#define RALL(v) rbegin(v), rend(v)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

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

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 int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main(){
  int N;
  cin >> N;
  vector<ll> a(N);
  REP(i,N)cin >> a[i];
  sort(ALL(a));
  reverse(ALL(a));
  ll ans=a[0];
  REP(i,N-2){
    ans+=a[i/2+1];
  }
  PRINT(ans);
}



Measured memory_bytes: 4772
n=int(input())
s=input()
ss=s[::-1]
ans=0
front_bucket=[0 for i in range(26)]
back_bucket=[0 for i in range(26)]

for i in range(n):
  front_bucket[ord(s[i])-97]+=1
for i in range(n):
  back_bucket[ord(ss[i])-97]+=1
  front_bucket[ord(ss[i])-97]-=1
  a=0
  for j in range(26):
    if front_bucket[j]*back_bucket[j]>0:
      a+=1
  ans=max(ans,a)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>

#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define VS vector<string>
#define VL vector<long long>
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVL vector<vector<ll>>
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort((x).rbegin(),(x).rend())
#define PAIR pair<ll,ll>
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using  ll = long long;
constexpr ll MOD = 1000000007;
using std::cout;
using std::endl;
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::multiset;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, ll b) {
	ll ans = 1;
	while (b > 0) {
		if (b % 2 == 1) {
			ans *= a;
			ans %= MOD;
		}
		b /= 2;
		a *= a;
		a %= MOD;
	}
	return ans;
}
ll comb(ll a, ll b) {
	if (a - b < b) { return comb(a, a - b); }
	ll c = 1;
	FOR(i, a - b + 1, a + 1) {
		c *= i;
		c %= MOD;
	}
	ll k = 1;
	FOR(i, 2, b + 1) {
		k *= i;
		k %= MOD;
	}
	c *= pow(k, MOD - 2);
	return c % MOD;
}
multiset<ll> prime_decomposition(ll n) {
	ll i = 2;
	multiset<ll> table{};
	while (i * i <= n) {
		while (n % i == 0) {
			n /= i;
			table.emplace(i);
		}
		++i;
	}
	if (n > 1) {
		table.emplace(n);
		return table;
	}
	return table;
}

int main() {
	ll n;
	cin >> n;

	ll t = (-1.0 + sqrt(1.0 + 8.0*(double)n)) / 2.0;
	ll c = ((t + 1) * (t + 2))/2;
	RFOR(i, 1, t + 2) {
		if (c - n >= i) {
			//cout << ":" << i << ": ";
			c -= i;
		} else {
			cout << i << " ";
		}
	}
	cout << endl;
}

Measured memory_bytes: 256
from collections import deque

n=int(input())

que=deque()

for i in range(n):
    m=input()
    if m=="deleteFirst":
        que.popleft()
    elif m=="deleteLast":
        que.pop()
    else :
        m,n=m.split()
        if m=="insert":
            que.appendleft(n)
        elif n in que:
            que.remove(n)
        else:
            pass

l=' '.join(que)

print(l)




Measured memory_bytes: 69736
#include<iostream>
#include<map>
#include<set>
#include<algorithm>
#include<string>
using namespace std;
map<char,int> m1;
map<char,int> m2;
multiset<int> s1;
multiset<int> s2;
string a,b;
int main()
{
    ios::sync_with_stdio(false);
    while(cin>>a>>b)
    {
        m1.clear();m2.clear();
        s1.clear();s2.clear();
        int lena=a.length();
        int lenb=b.length();
        for(int i=0;i<lena;i++) m1[a[i]]++;
        for(int i=0;i<lenb;i++) m2[b[i]]++;
        map<char,int>::iterator it;
        for(it=m1.begin();it!=m1.end();it++) s1.insert(it->second);
        for(it=m2.begin();it!=m2.end();it++) s2.insert(it->second);
        multiset<int>::iterator it1,it2;
        bool flag=1;
        for(it1=s1.begin(),it2=s2.begin();it1!=s1.end(),it2!=s2.end();it1++,it2++)
        {
            if(*it1!=*it2)
            {
                flag=0;break;
            }
        }
        if(flag) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }
}

Measured memory_bytes: 916
#include<bits/stdc++.h>
using namespace std;
int main(){
	
	int a, b;
	cin >> a >> b;
	if(a>b)
		for(int i=1; i<=a; i++) cout << b;
	else 
		for(int i=1; i<=b; i++) cout << a;
	return 0;	
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll extgcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;y=0;
        return a;
    }
    ll d=extgcd(b,a%b,y,x);
    y-=a/b*x;
    return d;
}
int main(){
 ll a,b;
 cin>>a>>b;
 ll x=0,y=0;
 extgcd(a,b,x,y);
 cout<<x<<" "<<y<<"\n";
}


Measured memory_bytes: 3228
def get(A, ar, ac):
    if ar > 2 or ar < 0 or ac > 2 or ac < 0:
        return 0
    if A[ar][ac] == 0:
        return 1
    return 0

def check(A, ar, ac):
    # print( get(A, ar-1, ac-1) + get(A, ar-2, ac-2) + get(A, ar+1, ac+1) + get(A, ar+2, ac+2))
    if 2 == get(A, ar-1, ac-1) + get(A, ar-2, ac-2) + get(A, ar+1, ac+1) + get(A, ar+2, ac+2):
        return True
    if 2 == get(A, ar+1, ac-1) + get(A, ar+2, ac-2) + get(A, ar-1, ac+1) + get(A, ar-2, ac+2):
        return True
    if 2 == get(A, ar+1, ac) + get(A, ar+2, ac) + get(A, ar-1, ac) + get(A, ar-2, ac):
        return True
    if 2 == get(A, ar, ac+1) + get(A, ar, ac+2) + get(A, ar, ac-1) + get(A, ar, ac-2):
        return True
    return False

A = [[0 for i in range(3)] for i in range(3)]
for i in range(3):
    A[i] = list(map(int, input().split()))
N = int(input())
for n in range(N):
    b = int(input())
    for ar in range(3):
        for ac in range(3):
            if A[ar][ac] == b:
                A[ar][ac] = 0
                if check(A, ar, ac):
                    print("Yes")
                    # print(A)
                    import sys
                    sys.exit(0)
                continue
print("No")
# print(A)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define sf scanf
#define pf printf
#define pi acos(-1.0)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define pb push_back
#define pop pop_back
#define fi first
#define se second
#define in insert
#define mp make_pair
#define GCD(a,b) __gcd(a,b);
#define endl "\n"
#define FRU freopen("out.txt","w",stdout)
#define FRO freopen("in.txt","r",stdin)
#define INFLL 9223372036854775807
#define debug 0
#define MAXN   100001
int main()
{
    boost;
    int x,b,t;
    cin>>x>>b>>t;
    if(b>t)
     cout<<0<<endl;
     else
     {
         cout<<b*(t/x)<<endl;
     }
     return 0;
}

Measured memory_bytes: 3656
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();

		int[] ab = new int[2*M];
		int[] cities = new int[N];
		for(int i=0; i<2*M; i++) {
			ab[i] = sc.nextInt();

			for(int j=0; j<N; j++) {
				if(ab[i]-1 == j ) {
					cities[j] += 1;
				}
			}
		}

		for(int k=0; k<N; k++) {
			System.out.println(cities[k]);
		}




	}

}


Measured memory_bytes: 21716
#include <stdio.h>
#include <string.h>

int main(){
  char s[201];
  char p[101];
  char temp[101];

  scanf("%s %s", s, p);
  strcpy(temp, s);
  strcat(s,temp);
  if(strstr(s, p)){
	printf("Yes\n");
  }else{
	printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 2056
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define  all(v)            v.begin(), v.end()
#define  sz(x)             (int)x.size()
#define  debug(x)          cout << '>' << #x << ':' << x << endl;
#define  rep(i,n)          for(int i = 0; i <  n ; i++)
#define  reps(i,n)         for(int i = 1; i <= n ; i++)
#define  make_unique(v)    sort(all(v));v.erase(unique(all(v)), v.end());
#define  rot(v)            rotate(v.begin(), v.begin() + k, v.end());
#define  rmv(v,a)          v.erase(remove(v.begin(),v.end(), a), v.end());
#define  pb                push_back
#define  eb                emplace_back
#define  mp                make_pair
#define  endl              '\n'
#define  fi                first
#define  se                second
#define  ajs(a)            (a<0)?(-1*a):a


using namespace std;
typedef long long          ll;
typedef vector<long long>  vll;

const ll MOD = 1e9+7;
const double PI  = acos(-1.0);
const double EPS = (1e-10);
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = { -1, 0, 1, 0};
const int dx8[8] = { -1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = { -1, 0, 1, 1, 1, 0, -1, -1};
bool cmp(int X, int Y) {return X > Y;}
int dcp(double A, double B){return fabs(A-B)<=EPS ? 0 : A<B ? -1:1;}


ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll lcm(ll a, ll b) {return (a / gcd(a, b)) * b;}
ll modpow(ll a, ll b, ll m=MOD){a %= m; ll res = 1; while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}





int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
string s,t;cin>>s>>t;
ll n = s.length();
ll m = t.length();

ll dp[n+1][m+1];

for(ll i = 0; i<=n ; i++){
    dp[i][0] = 0;
}

for(ll i = 0; i<=m ; i++){
    dp[0][i] = 0;
}

for(ll i = 1 ; i<= n ; i++){
    for(ll j = 1 ; j<=m ; j++){
        if(s[i-1] == t[j-1]){
            dp[i][j] = dp[i-1][j-1] + 1;
        }else{
            dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);
        }
    }
}
//cout<<dp[n][m];
ll len = dp[n][m];

string ans = "";


ll l = n-1;
ll r = m-1;

while(l>=0 && r>=0){
    if(s[l] == t[r]){
        ans+=s[l];
        l--;
        r--;

    }else if(dp[l][r+1] > dp[l+1][r]){
        l--;
    }else{
        r--;
    }
}
reverse(all(ans));
cout<<ans;





}


Measured memory_bytes: 73936
S = input()

divide = True
while len(S) > 0:
    if S[-5:] in ["dream", "erase"]:
        S = S[:-5]
    elif S[-6:] == "eraser":
        S = S[:-6]
    elif S[-7:] == "dreamer":
        S = S[:-7]
    else:
        divide = False
        break
        
if divide:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3188
// inputに入力データ全体が入る
function Main(input) {
	var input = input.split("\n");
	var answer;

	input = input.map((x) => parseInt(x, 10));

	answer =
		(input[0] + input[1]) * input[2] / 2;


	// 出力
	console.log(answer);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

typedef vector<vvd> vvvd;
template<typename T> void chmin(T& a,const T& b){a=min(a,b);}
template<typename T> void chmax(T& a,const T& b){a=max(a,b);}

double solve(const vvd& p,int mask,int cur,vvd& memo)
{
	if(memo[mask][cur]!=-1) return memo[mask][cur];
	int m=p.size(),n=p[0].size();
	double res=0;
	rep(i,m) if(mask>>i&1){
		double cp=1;
		double sum=0;
		repi(j,cur,n){
			sum+=cp*(1-p[i][j])*(solve(p,mask^1<<i,j,memo));
			cp*=p[i][j];
		}
		chmax(res,sum+cp);
	}
	return memo[mask][cur]=res;
}

int main()
{
	for(int m,n;cin>>m>>n && m|n;){
		vvd p(m,vd(n));
		rep(i,m) rep(j,n) cin>>p[i][j];
		vvd memo(1<<m,vd(n,-1));
		printf("%.12f\n",solve(p,(1<<m)-1,0,memo));
	}
}

Measured memory_bytes: 11820
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <utility>
#include <map>
int needleX[4] = { -1,0,1,0 };
int needleY[4] = { 0,1,0,-1 };

#define const INF=1<<21;
int main(){
	int N,M;
    std::string s;
	std::cin >> s;
    if(s.size()==2){
        std::cout << s << std::endl;
    }else{
        std::reverse(s.begin(),s.end());
        std::cout << s<<std::endl;
    }
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FOR1(i, n) for(int (i)=1; (i)<=(n); (i)++)
#define FORI(i, n) for(int (i)=n-1; (i)>=0; (i)--)
template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}
template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}
template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, x); }
template<class T, class U> void init(vector<T> &v, U x, size_t n, size_t m...) { v=vector<T>(n); for(auto& a : v) init(a, x, m);}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int n;
    cin >> n;
    vector<int> a(n);
    FOR(i, n) cin >> a[i];
    sort(a.begin(), a.end());

    ll sol = 0;
    int t = 0;
    int pos = n-1;
    FORI(i, n-1){
        sol += a[pos];
        t ^= 1;
        if (t)
            pos--;
    }
    cout << sol << endl;

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}



Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
inline long long read(){
	register long long x=0;
	register bool f=0;
	register char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-') f=1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<3)+(x<<1)+c-48;
		c=getchar();
	}
	return f?-x:x;
}
char cr[200];int tt;
inline void print(register long long x,register char k='\n') {
    if(!x) putchar('0');
    if(x < 0) putchar('-'),x=-x;
    while(x) cr[++tt]=x%10+'0',x/=10;
    while(tt) putchar(cr[tt--]);
    putchar(k);
}
long long n,m,cnt,sum;
int main(){
	n=read();m=read();
	n=n%m;
	print(min(n,m-n));
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

long long mod = 1000000007;
long long con = 10000000000000;

int A, B, Q;
long long S[1<<20];
long long T[1<<20];
long long x;

long long find_answer() {
  long long ls, lt, rs, rt;
  ls = lt = rs = rt = -1;

  int z = lower_bound(S, S + A, x) - S;
  if(z == A) {
    ls = S[z-1];
    rs = con;
  } else if(z == 0) {
    rs = S[z];
    ls = -con;
  } else {
    rs = S[z];
    ls = S[z-1];
  }

  z = lower_bound(T, T + B, x) - T;
  if(z == B) {
    lt = T[z-1];
    rt = con;
  } else if(z == 0) {
    rt = T[z];
    lt = -con;
  } else {
    rt = T[z];
    lt = T[z-1];
  }

  long long ans = min(x-min(ls, lt), max(rs, rt) - x);

  ans = min(ans, min(rs-lt+x-lt, rs-lt+rs-x));
  ans = min(ans, min(rt-ls+x-ls, rt-ls+rt-x));

  //cout << ls << " " << lt << " " << rs << " " << rt << endl;
  return ans;
}

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

  cin >> A >> B >> Q;
  for (size_t i = 0; i < A; i++) {
    cin >> S[i];
  }
  for (size_t i = 0; i < B; i++) {
    cin >> T[i];
  }
  for (size_t i = 0; i < Q; i++) {
    cin >> x;
    cout << find_answer() << endl;
  }


  return 0;
}


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int a,b;
    cin >> a >> b;
    int x;
    if(b<10)x = a*10+b;
    else if(b==100)x = a*1000+b;
    else x = a*100+b;
    rep(i,1000){
    if(x == i*i){
        cout << "Yes" << endl;
        return 0;
    }
    }
    cout << "No" << endl;
    return 0;
}

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

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int L=a+b;
  int R=c+d;
  if(L>R){
    cout<<"Left"<<endl;
  }else if(L<R){
    cout<<"Right"<<endl;
  }else{
    cout<<"Balanced"<<endl;   
  }
  return 0;
}

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

namespace ABC087A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x, a, b, c;
            x = int.Parse(Console.ReadLine());
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());
            c = (x - a) % b;
            Console.WriteLine(c);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
from math import factorial
N, M = map(int, input().split())
mod = 10 ** 9 + 7

if abs(N - M) >= 2:
  print(0)
  exit()

if N == M:
  print(factorial(N) * factorial(M) * 2 % mod)
else:
  print(factorial(N) * factorial(M) % mod)

Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+7;
int ans[N];
int visited[N];
int n, m;
vector<int> graph[N];
int main(){
    ios::sync_with_stdio(false);
    cin.tie();
    cin>>n>>m;
    for(int i = 0; i < m; i++){
        int a, b;
        cin>>a>>b;
        a--; b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    queue<int> q;
    memset(visited, 0, sizeof(visited));
    q.push(0);
    ans[0] = 0;
    visited[0] = 1;
    int count = 0;
    while(!q.empty()){
        count++;
        int p = q.front();
        q.pop();
        for(int i = 0; i < graph[p].size(); i++){
            if(visited[graph[p][i]] == 0){
                q.push(graph[p][i]);
                ans[graph[p][i]] = p;
                visited[graph[p][i]] = 1;
            }
        }
    }
 //   cout<<count<<endl;
    if(count < n) cout<<"No";
    else
    {
        cout<<"Yes"<<endl;
        for(int i = 1; i < n; i++){
            cout<<ans[i]+1<<endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 10816
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define FASTIO

#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/
const ll MOD = 1e9 + 7;

int go(int k) {
	if (k == 3)
		return 1;
	return k;
}

void add(ll &a, ll b) {
	a += b;
	if (a >= MOD)
		a -= MOD;
}

string s;
ll dp[3][3], dp2[3][3];

int main() {
#ifdef FASTIO
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
	cin >> s;
	dp[0][0] = 1;
	ll wn = 0;
	for (int i = 0; i < s.size(); ++i) {
		for (int j = 0; j < 3; ++j)
			for (int k = 0; k < 3; ++k)
				dp2[j][k] = 0;
		if (s[i] == '?')
			wn = (wn * 2) % MOD;
		for (int j = 0; j < 3; ++j)
			for (int k = 0; k < 3; ++k) {
				if (s[i] == '1' || s[i] == '?') {
					if (k) {
						add(dp2[j][k - 1], dp[j][k]);
					}
					else {
						if (j + 1 == 3) {
							add(wn, dp[j][k]);
						}
						else {
							add(dp2[j + 1][k], dp[j][k]);
						}
					}
				}
				if (s[i] == '0' || s[i] == '?') {
					add(dp2[j][go(k + 1)], dp[j][k]);
				}
			}
		for (int j = 0; j < 3; ++j)
			for (int k = 0; k < 3; ++k)
				dp[j][k] = dp2[j][k];
	}
	add(wn, dp[1][0]);
	add(wn, dp[2][1]);
	cout << wn << "\n";
	return 0;
}




Measured memory_bytes: 720
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int p[100010];

int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    rep(i,n)p[a[i]]++;
    int cnt = 0;
    rep(i,100010){
        cnt += max(0,p[i]-1);
    }
    if(cnt%2==0){
        cout << n-cnt << endl;
    }else{
        cout << n-cnt-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
 
int main (){
  long long a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<max(max(a*c,a*d),max(b*c,b*d));
}

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

def check(t, a):
    T, A = map(int, input().split())
    if T >= t and A >= a:
        t = T
        a = A
        return t, a
    if T >= t and A < a:
        t = T * ((a + (A-1))//A)
        a = A * ((a + (A-1))//A)
        return t, a
    if T < t and A >= a:
        t = T * ((t + (T-1))//T)
        a = A * ((t + (T-1))//T)
        return t, a
    if T < t and A < a:
        t = T * max((t + (T-1))//T, (a + (A-1))//A)
        a = A * max((t + (T-1))//T, (a + (A-1))//A)
        return t, a
t = 0
a = 0
for _ in range(N):
    t, a = check(t, a)

print (t + a)

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int n;
  int p[1005][1005];
  int tf=0;
  int tt=0;
  int ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      cin>>p[i][j];
    }
    sort(p[i],p[i]+3);
    
    for(int k=0;k<i;k++){
      for(int j=0;j<3;j++){
      if(p[i][j]==p[k][j]){
	tt++;
      }
      }
      if(tt==3){
	tf++;
      }
      tt=0;
     }
    if(tf>0){
      ans++;
    }
    tf=0;
  }
  cout<<ans<<"\n";
  
  return 0;
}





Measured memory_bytes: 7080
#include<iostream>

using namespace std;
int main()
{
    int n;
    cin>>n;long long sum=0;
    for(int i=1;i<=n;i+=1){
        if(i%3!=0 && i%5!=0){
           ///cout<<i<<endl;
           sum = sum+i;
        }
    }
    cout<<sum<<endl;


    return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using graph = vector<vector<int>>;
using wgraph = vector<vector<pair<int, lint>>>;
const lint INF = 1001001001001001LL;
const lint MOD = 1000000007LL;
int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

void yes(){ cout << "yes" << endl; }
void Yes(){ cout << "Yes" << endl; }
void YES(){ cout << "YES" << endl; }
void no(){ cout << "no" << endl; }
void No(){ cout << "No" << endl; }
void NO(){ cout << "NO" << endl; }
void possible(){ cout << "possible" << endl; }
void Possible(){ cout << "Possible" << endl; }
void POSSIBLE(){ cout << "POSSIBLE" << endl; }
void impossible(){ cout << "impossible" << endl; }
void Impossible(){ cout << "Impossible" << endl; }
void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for(int i = s; i < t; i++)
#define all(a) a.begin(),a.end()

void dfs(graph &g, lint cur, vector<lint> &score, lint s, vector<bool> &used){
  score[cur] += s;
  s = score[cur];
  for(auto nxt : g[cur]){
    if(used[nxt] == false){
      used[nxt] = true;
      dfs(g, nxt, score, s, used);
    }
  }
}

int main(){
  
  lint n, q; cin >> n >> q;
  graph g(n);
  rep(i, n - 1){
    lint a, b; cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a); 
  }
  vector<lint> score(n, 0);
  rep(i, q){
    lint p, x; cin >> p >> x;
    p--;
    score[p] += x;
  }

  vector<bool> used(n, false);
  used[0] = true;
  dfs(g, 0, score, 0, used);
  rep(i, n){
    if(i == n - 1) cout << score[i] << endl;
    else cout << score[i] << " ";
  }
  return 0;
}


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

#define INF INT_MAX

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

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

	double W,H,x,y;
	cin >> W >> H >> x >> y;
	
	double sum = W*H/2.0;

	int c = (W/2 == x && H/2 == y)? 1 : 0;

	printf("%.9f %d\n",sum,c);

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

int main(){
	int n;
	std::vector<int> x;
	std::cin>>n;
	for(int i=1;i<=n;i++){
		int in;
		std::cin>>in;
		x.push_back(in);
	}
	for(int i=0;i<n;i++){
		std::vector<int> s;
		for(int j=1;j<=10000000;j=j*10)s.push_back(x[i]/j%10);
		std::sort(s.begin(),s.end());
		std::cout<<(s[7]-s[0])*10000000+(s[6]-s[1])*1000000+(s[5]-s[2])*100000+(s[4]-s[3])*10000+(s[3]-s[4])*1000+(s[2]-s[5])*100+(s[1]-s[6])*10+(s[0]-s[7])<<std::endl;
		s.clear();
	}
}

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

int main() {
  int n;
  cin >> n;
  int ans = n;
  vector<long>data(n);
  for(int i = 0;i < n;i++) cin >> data[i];
  sort(data.begin(),data.end());
  for(int i = 0;i < n-1;i++){
    if(data[i] == data[i+1]){
      ans -= 2;
      i++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;

int main(){

    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    vector<vector<int>> road(n);
    vector<bool> isGood(n, true);
    for (int i = 0; i < n; ++i)
    {
        cin >> h[i];
    }

    int a, b;
    for (int i = 0; i < m; ++i)
    {
        cin >> a >> b;
        road[a-1].push_back(b-1);
        road[b-1].push_back(a-1);
    }


        int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        bool judge = true;
        if (isGood[i])
        {
            for (const auto &A : road[i])
            {
                if(h[i] <= h[A]){
                    judge = false;
                }
                else{
                    isGood[A] = false;
                }
            }
        }
        else{
            judge = false;
        }

        if(judge){
            ++ans;
        }

    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8804
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int main(){
  int n;
  cin>>n;
  int p[n];
  rep(i,n) cin>>p[i];
  int max=10;
  rep(i,n){
  if(max<p[i])max=p[i];
  }
  int sum=0;
  rep(i,n)sum+=p[i];
  
  cout << sum-(max/2) <<endl;
}

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

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

//a???i?????????????????????b???j???????????????????????????????????±?????¨???????????????
int dp[4000][4000];

int main()
{
    string a,b;
    while(cin >>a >>b)
    {
        //initialize
        memset(dp,0,sizeof(dp));

        int A=a.size(), B=b.size();

        rep(i,A) if(a[i]==b[0]) dp[i][0]=1;
        rep(i,B) if(a[0]==b[i]) dp[0][i]=1;

        for(int i=1; i<A; ++i)for(int j=1; j<B; ++j)
        {
            if(a[i]==b[j]) dp[i][j]=dp[i-1][j-1]+1;
        }

        int ans=0;
        rep(i,A)rep(j,B) ans=max(ans,dp[i][j]);

        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 65716
#include <stdio.h>

int main(void) {
	int x,k,i;
	scanf("%d%d",&k,&x);
	x=x-k+1;
	for(i=0;i<2*k-1;i++){
		printf("%d ",x);
		x++;
	}
	

	
	// your code goes here
	return 0;
}

Measured memory_bytes: 128
A, B, C, D = [i for i in list(input())]

for bit in range(8):
    f = [A, '', B, '', C, '', D]
    for i, j in enumerate([1, 3, 5]):
        if bit & (2**i): f[j] = '+'
        else: f[j] = '-'
    f = ''.join(f)
    if eval(f)==7:
        print('%s=7' % f)
        quit()


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


int main() {
  ll a,b,c,d;cin>>a>>b>>c>>d;
  
  if(a>0 && c>0) cout << b*d << endl;
  else if(b>0 && d>0 && a*c<=0) cout << b*d << endl;
  else if(b<0 && d<0) cout << a*c << endl;
  else if(a<0 && c<0 && b*d<=0) cout << a*c << endl;
  else if(a==0 || b==0 || c==0 || d==0) cout << 0 << endl;
  else if(b<0 && c>0) cout << b*c << endl;
  else if(d<0 && a>0) cout << d*a << endl;
  else cout << max(a*c,b*d) << endl;
  
  
}
 

Measured memory_bytes: 3620
#include<stdio.h>
int main()
{
  long a,b,n,p=0;
  scanf("%ld %ld", &a, &b);
  n=a;
  while(b>=n){ 
   n*=2;
   p++;
  }
  
  printf("%ld\n", p);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include<deque>
#include<stdlib.h>
#include <algorithm>
#include<set>
#include<map>
#include <limits>
#include<iomanip>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_2 100000
#define d9_7 1000000007
int main(void){
  ll h,w,n;
  cin >> h>>w>>n;
  vector<ll> a(n);
  vector<ll> b(n);
  rep(i,n){
    cin>>a[i]>>b[i];
    a[i]--;b[i]--;
    a[i]--;b[i]--;
  }
  map<pair<ll,ll>,int> mat;
  ll cnt=0;
  rep(i,n){
    for(ll k1=-1;k1<=1;k1++){
      for(ll k2=-1;k2<=1;k2++){
        if(mat.find({k1+a[i],k2+b[i]})==mat.end()){
          mat.insert({{k1+a[i],k2+b[i]},1});
        }else{
          mat[{k1+a[i],k2+b[i]}]++;
        }
      }
    }
  }
  vector<ll> result(10,0);
  for(auto i = mat.begin(); i != mat.end() ; ++i){
    if(i->first.first<=h-3 && i->first.first>=0 &&i->first.second<=w-3&&i->first.second>=0){
          cnt++;
      result[i->second]++;
    }
  }
  result[0]=(h-2)*(w-2)-cnt;
  rep(i,10){
    cout<<result[i]<<endl;
  }
  return 0;
}

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


int main(){ 
int n,k;
  cin>>n>>k;
  
  vector<int>cnt(n);
  for(int x=0;x<k;++x){int d;
  cin>>d;
      vector<int>rem(d);
      for(int i=0;i<d;++i)
      cin>>rem[i];
   for(int i=0;i<d;++i)
   cnt[rem[i]-1]+=1;
  }
  int count=0;
  for(int i=0;i<n;++i)
  if(cnt[i]==0)
  ++count;
  cout<<count;
    return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int c=0,cw,f=0;
	cin>>s;
	for(int i=0;i<s.size();i++)
    {
    	if(s[i]=='C')c=1,cw=i;
	}
	for(int i=cw;i<s.size();i++)
    {
    	if(s[i]=='F')f=1;
	}
	if(c==1 && f==1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

// template <typename T>
// struct edge {
//     int to;
//     T cost;
//     edge(){}
//     edge(int _to, T _cost) : to(_to), cost(_cost) {}
//     bool operator< (const edge& e) const {
//         return cost == e.cost ? to < e.to : cost < e.cost;
//     }
// };

template <typename T>
struct edge {
    int from, to;
    T cost;
    edge(){}
    edge(int _from, int _to, T _cost) : from(_from), to(_to), cost(_cost) {}
    bool operator< (const edge& e) const {
        return cost == e.cost ? (from == e.from ? to < e.to : from < e.from) : cost < e.cost;
    }
    bool operator> (const edge& e) const {
        return cost == e.cost ? (from == e.from ? to > e.to : from > e.from) : cost > e.cost;
    }
};

template <typename T>
class Prim {
private:
    int n;
    vector<vector<edge<T>>> G;
public:
    Prim(int _n) : n(_n) {
        G.resize(n);
    }
    // undirected
    void addEdge(int u, int v, T c) {
        G[u].emplace_back(u, v, c);
        G[v].emplace_back(v, u, c);
    }
    T calc(int s = 0) {
        T total_weight = 0;
        vector<bool> visited(n);
        priority_queue<edge<T>, vector<edge<T>>, greater<edge<T>>> pq;
        pq.push(edge<T>(-1, s, 0));
        while (!pq.empty()) {
            auto e = pq.top(); pq.pop();
            if (visited[e.to]) continue;
            total_weight += e.cost;
            visited[e.to] = true;
            for (const auto& ne: G[e.to]) {
                if (!visited[ne.to]) pq.push(ne);
            }
        }
        return total_weight;
    }
};
/* !!!!! T: ?????????????????????(int, double) !!!!! */

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

    int n, m;
    cin >> n >> m;
    Prim<int> prim(n);
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        prim.addEdge(a, b, c);
    }

    cout << prim.calc() << endl;
}

Measured memory_bytes: 13852
H,W = map(int,input().split())

squares=[]

for i in range(H):
    squares.append(list(input()))

# rows
    
for i in range(H-1,-1,-1):
    if '#' not in squares[i]:
        del squares[i]
        
# columns
check_col =[]  
    
for j in range(W):
    flag=True
    for i in range(len(squares)):
        if squares[i][j] == '#':
            flag = False
    if flag:
        check_col.append(j)

check_col.sort(reverse=True)

for j in check_col:
    for i in range(len(squares)):
        del squares[i][j]
        
# print

for i in range(len(squares)):
    print(''.join(squares[i]))
        




Measured memory_bytes: 3188
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j;
  int A[N+1];
  int key;
  scanf("%d", &n);

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

  for(j=2; j<=n; j++){
    key = A[j];
    i = j-1;

    while(i>0 && A[i]>key){
      A[i+1] = A[i];
      i = i-1;
      A[i+1] = key;
    }
    
    trace(A,n);

  }
  
  return 0;
}

Measured memory_bytes: 608
while true do
    h, w = gets.split(" ").map(&:to_i)
    if h && w == 0
        break
    end
    a = h - 2
    b = w - 2

    puts "#" * w
    i = 0
    while i < a do
        puts ("#" + "." * b + "#")
        i = i + 1
    end
    puts "#" * w

    puts
end

Measured memory_bytes: 8808
#include<bits/stdc++.h>
using namespace std;
//BEGIN CUT HERE

template<typename T> 
struct BIT{
  vector<T> bit;
  int n;
  //1-indexed
  BIT(){init(-1,(T)0);}
  BIT(int n_,T d){init(n_,d);}
  void init(int n_,T d){
    n=n_;
    bit.clear();
    bit.resize(n+1,d);
  }
  T sum(int i){
    T s=0;
    for(int x=i;x>0;x-=(x&-x))
      s+=bit[x];
    return s;
  }
  void add(int i,T a){
    if(i==0) return;
    for(int x=i;x<=n;x+=(x&-x))
      bit[x]+=a;
  }
  T sum0(int i){
    return sum(i+1);
  }
  void add0(int i,T a){
    add(i+1,a);
  }
};
template <typename T,typename E,typename R>
struct SegmentTree2D{
  typedef function<T(void)> C;
  typedef function<R(R,R)> F;
  typedef function<void(T&,int,E)> G;
  typedef function<R(T&,int,int)> V;
  int n;
  F f;
  G g;
  V v;
  R d1;
  vector<T> dat;
  SegmentTree2D(int n_,C c,F f,G g,V v,R d1){
    this->f=f;
    this->g=g;
    this->v=v;
    this->d1=d1;
    init(n_,c);
  }
  void init(int n_,C c){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1);
    for(int i=0;i<2*n-1;i++) dat[i]=c();
  }
  void update(int x,int y,E e){
    x+=n-1;
    g(dat[x],y,e);
    while(x>0){
      x=(x-1)/2;
      g(dat[x],y,e);
    }
  }
  R query(int a,int b,int c,int d,int k,int l,int r){
    if(r<=a||b<=l) return d1;
    if(a<=l&&r<=b) return v(dat[k],c,d);
    R vl=query(a,b,c,d,k*2+1,l,(l+r)/2);
    R vr=query(a,b,c,d,k*2+2,(l+r)/2,r);
    return f(vl,vr);
  }
  // [a,b) * [c,d)
  R query(int a,int b,int c,int d){
    return query(a,b,c,d,0,0,n);
  }
};

//END CUT HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int h,w,t,q;
  cin>>h>>w>>t>>q;
  typedef BIT<int> T;
  SegmentTree2D<T,int,int> beet(2048,
				[&](){return T(2048,0);},
				[](int a,int b){return a+b;},
				[](T& t,int k,int e){t.add(k,e);},
				[](T& t,int c,int d){
				  return t.sum(d-1)-t.sum(c-1);
				},
				0);
  SegmentTree2D<T,int,int> ushi(2048,
				[&](){return T(2048,0);},
				[](int a,int b){return a+b;},
				[](T& t,int k,int e){t.add(k,e);},
				[](T& t,int c,int d){
				  return t.sum(d-1)-t.sum(c-1);
				},
				0);
  
  typedef pair<int,int> P;
  typedef pair<int,P> PP;
  queue<PP> qq; 
  for(int i=0;i<q;i++){
    int a,c,x1,y1;
    cin>>a>>c>>x1>>y1;
    while(!qq.empty()&&qq.front().first<=a){
      P p=qq.front().second;qq.pop();
      int x=p.first,y=p.second;
      assert(beet.query(x,x+1,y,y+1)==1);
      beet.update(x,y,-1);
      assert(ushi.query(x,x+1,y,y+1)==0);
      ushi.update(x,y,1);
    }
    if(c==0){
      assert(beet.query(x1,x1+1,y1,y1+1)==0);
      beet.update(x1,y1,1);
      qq.push(PP(a+t,P(x1,y1)));
    }
    if(c==1){
      if(ushi.query(x1,x1+1,y1,y1+1)==0) continue;
      ushi.update(x1,y1,-1);
    }
    if(c==2){
      int x2,y2;
      cin>>x2>>y2;
      x2++;y2++;
      cout<<ushi.query(x1,x2,y1,y2)<<" "<<beet.query(x1,x2,y1,y2)<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 69848
n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]
cnt = 0
flag = False
for i in range(n):
  if d[i][0]==d[i][1]:
    cnt+=1
  else:
    cnt = 0
  if cnt == 3:
    flag = True
if flag:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 9116
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(x) x.begin(),x.end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

ll a,b,c,k;
ll solve(){
   ll ans=0;
   if(k<=a)ans=k;
   else if(k<=a+b)ans=a;
   else {
       ans=a-(k-a-b);
   }

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

    cin>>a>>b>>c>>k;
    cout<<solve()<<endl;
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
inline long long mod(long long n,long long m){return(n%m+m)%m;}
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main(){
    int a,b,t; cin>>a>>b>>t;
    cout<<t/a*b<<endl;
    return 0;
}


Measured memory_bytes: 256