akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<algorithm>
using namespace std;
int p[21000];
int q[21000];
int r[21000];
int t[21000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){scanf("%d",t+i);t[i]--;}
	for(int i=0;i<a;i++)p[t[i]]=i;
	int now=1;
	for(int i=0;i<a;i++){
		q[i]=now;
		now+=a-p[i];
	}
	now=1000000000;
	for(int i=0;i<a;i++){
		r[i]=now;
		now-=a-p[i+1];
	}
	for(int i=0;i<a;i++){
		if(i)printf(" ");
		printf("%d",q[i]);
	}
	printf("\n");
	for(int i=0;i<a;i++){
		if(i)printf(" ");
		printf("%d",r[i]);
	}
	printf("\n");
	
}

Measured memory_bytes: 896
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

void update (i64 *bit, i32 x, i64 v) {
  i32 n = bit[0];
  for (i32 i = x; i <= n; i += i & -i) {
    if (bit[i] < v) {
      bit[i] = v;
    }
  }
}

i64 find (i64 *bit, i32 x) {
  i64 max = 0;
  for (i32 i = x; i > 0; i ^= i & -i) {
    if (max < bit[i]) {
      max = bit[i];
    }
  }
  return max;
}

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  i32 *h = (i32 *) calloc (n, sizeof (i32));
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi32, h + i);
  }
  i64 *bit = (i64 *) calloc (n + 1, sizeof (i64));
  bit[0] = n;
  for (i32 i = 0; i < n; ++i) {
    i32 a;
    scanf ("%" SCNi32, &a);
    i64 v = a + find (bit, h[i]);
    update (bit, h[i], v);
  }
  printf ("%" PRIi64 "\n", find (bit, n));
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>

using namespace std;

int main(){
	int k,s;
	cin >> k >> s;
	int eq=0,df=0,only=0;
	for(int x=0;x<=k;x++){
		for(int y=x;y<=k;y++){
			if(x+y>s)continue;
			for(int z=y;z<=k;z++){
				if(x+y+z==s){
					if(x==y&&y==z)eq++;
					else if(x!=y&&y!=z)df++;
					else only++;
				}
			}
		}
	}
	cout << eq+(df*6)+(only*3) << endl;		
	return 0;
}


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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 2e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e9 + 7;
const ll infll = 1e18 + 7;

int n, ans;
int a[N];
map <int, int> mpp;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    ForE(i, 1, n){
        cin >> a[i];
    }
    ForE(i, 1, n){
        ans += mpp[i - a[i]];
        mpp[i + a[i]]++;
    }
    cout << ans;
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 27924
s=input()

for bit in range(1 << 3):
    f=int(s[0])
    for i in range(0,3):
        if bit & (1 << i):
            f=f+int(s[i+1])
        else:
            f=f-int(s[i+1])
    if f==7:
        break

F=s[0]
for i in range(0,3):
    if bit & (1 << i):
        F=F+"+"+s[i+1]
    else:
        F=F+"-"+s[i+1]

print(F+"=7")

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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#include <set>
#define all(x) (x).begin(),(x).end()

const int MOD = 1e9 + 7;

void solve(){

}
int main(){
    int N;
    cin >> N;
    vector<int> A(N+2);
    int sum = 0;
    for (int i = 1; i <= N; ++i) {
        cin >> A[i];
    }

    for (int i = 0; i < N+2; ++i) {
        sum += abs(A[i+1] - A[i]);
    }

    for (int i = 1;  i <= N; ++i) {
        int ans = sum - (abs(A[i] - A[i-1]) + abs(A[i+1] - A[i]));
        ans += abs(A[i+1] - A[i-1]);
        cout << ans << endl;
    }


    return 0;
}


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

int main(void){
	int n, a, b, c, x;
	int arr[20000];
	cin >> n >> x;
	for( int i = 1 ; i <= n ; i++ ){
		cin >> arr[i];
	}
	int ans = 1;
	int d = 0;
	for( int i = 2 ; i <= n + 1 ; i++){
		c = d + arr[i-1];
		if( c <= x ) ans++;
		d = c;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 998244353
#define w(t) int t; cin>>t;while(t--)
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);



	//w(t) {
	int s , w;
	cin >> s >> w;
	if (w >= s) {
		cout << "unsafe" << "\n";
	}
	else {
		cout << "safe" << "\n";
	}





	//}





	return 0;

}





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


int main() {

  vector<int> a(5); for(int i=0;i<5;i++) cin >> a[i];
  vector<int> tmp(5,0);
  int max=0,sum=0;
  int cnt=0;
  for(int i=0;i<5;i++){
    tmp[i]=a[i]%10;
    if(max<10-tmp[i] && tmp[i]!=0){
      max=10-tmp[i];
    }
    if(tmp[i] == 0) ++cnt;
  }

  for(int i=0;i<5;i++){
    sum+=a[i];
    if(tmp[i]!=0) sum += 10-tmp[i];
  }
  
  cout << sum-max << endl;    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[10];
int main(){
	int i,j,k;
	for(i=1;i<=5;i++)cin>>a[i];
	for(i=1;i<=5;i++){
		if(a[i]==0){
			cout<<i;return 0;
		}
	}
} 

Measured memory_bytes: 3636
#![allow(unused_imports, non_snake_case)]
use proconio::{
    input, fastout,
    marker::{Chars, Bytes, Usize1}
};

#[fastout]
fn main() {
    input!{
        d: usize,
        t: usize,
        s: usize,
    }
    println!("{}", if d <= t * s {"Yes"} else {"No"});
}


Measured memory_bytes: 2196
#include <bits/stdc++.h>
#define pll pair<ll, ll>
using namespace std;
const int mod = 1e9 + 7;
typedef long long ll;

inline int fsp(int x, int k = mod - 2) {
    int res = 1;
    while (k) {
        if (k & 1)
            res = 1ll * res * x % mod;
        x = 1ll * x * x % mod, k >>= 1;
    }
    return res;
}

int n;
map<pll, int> num;
pll now[200200];

int main() {
#ifdef isLOCAL
    freopen(".in", "r", stdin);
    freopen(".out", "w", stdout);
#endif

    cin >> n;
    int aa = 0, bb = 0, cc = 0;
    for (int i = 1; i <= n; ++i) {
        long long x, y, g;
        scanf("%lld%lld", &x, &y);
        if (!x || !y) {
            if (!x && !y)
                ++cc;
            else if (!x)
                ++aa;
            else if (!y)
                ++bb;
            --i, --n;
            continue;
        }
        g = __gcd(abs(x), abs(y));
        if (x < 0)
            x = -x, y = -y;
        x /= g, y /= g;
        num[now[i] = make_pair(x, y)]++;
    }

    int ans = (fsp(2, aa) + fsp(2, bb) - 1) % mod;
    for (int i = 1; i <= n; ++i) {
        if (!num[now[i]])
            continue;
        pll tmp = make_pair(-now[i].second, now[i].first);
        if (tmp.first < 0)
            tmp.first *= -1, tmp.second *= -1;
        int x = num[now[i]], y = num[tmp];
        num[now[i]] = num[tmp] = 0;
        int t = (fsp(2, x) + fsp(2, y) - 1) % mod;
        ans = 1ll * ans * t % mod;
    }

    ans = (ans - 1 + cc) % mod;
    if (ans < 0)
        ans += mod;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 31784
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n,k;
    cin>>n>>k;
    vi a(n);
    FOR(i,0,n){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    LL sm=0;
    FOR(i,0,k){
        sm+=a[i];
    }
    cout<<sm;
}


Measured memory_bytes: 3624
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    /* 変数宣言 */
    final int N,M;
    AtCoder(FastScanner sc) {
        N = sc.nextInt();
        M = sc.nextInt();
    }

    void solve(PrintWriter out) {
        if (N==M) {
            out.println("Yes");
        } else {
            out.println("No");
        }
    }
}

// https://qiita.com/p_shiki37/items/a0f6aac33bf60f5f65e4
class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

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

int main() {
    int n;
    cin >> n;
    if(n == 25){printf("Christmas\n");}
    else if(n == 24){printf("Christmas Eve\n");}
    else if(n == 23){printf("Christmas Eve Eve\n");}
    else if(n == 22){printf("Christmas Eve Eve Eve\n");} 
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <iostream>
#include <climits>
#include <cfloat>


using namespace std;


int main()
{
	char pos = 'A';
	char a, b;
	while (scanf("%c,%c", &a, &b) != EOF)
	{
		if (pos == a)
			pos = b;
		else if (pos == b)
			pos = a;
	}
	printf("%c\n", pos);

	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int N = 100005;
int sz[N], root[N], ans[N], n, m, k, df[N];
vector<int> a[N];
int getroot(int u)
{
	if (u == root[u])
		return u;
	return root[u] = getroot(root[u]);
}
void mrg(int u, int v)
{
	int ru = getroot(u);
	int rv = getroot(v);
	if (ru == rv)
		return;
	if (sz[rv] > sz[ru])
		swap(rv, ru);
	root[rv] = root[ru];
	sz[ru] += sz[rv];
}
int main(int argc, char const *argv[])
{
	cin >> n >> m >> k;
	for (int i = 0; i < n; ++i)
	{
		root[i] = i;
		sz[i] = 1;
		ans[i] = 0;
	}
	for (int i = 0; i < m; ++i)
	{
		int u, v;
		cin >> u >> v;
		u --;
		v --;
		df[u] ++;
		df[v] ++;
		mrg(u, v);
	}
	for (int i = 0; i < k; ++i)
	{
		int u, v;
		cin >> u >> v;
		u --;
		v --;
		if (getroot(u) == getroot(v))
		{
			ans[u] ++;
			ans[v] ++;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		int r = getroot(i);
		int s = sz[r];
		cout << s - 1 - ans[i] - df[i] << ' ';
	}
	return 0;
}


Measured memory_bytes: 7504
#include <iostream>
using namespace std;
#include <vector>
#include <stdio.h>
int main(void){
    // Your code here!
    int N;
    cin >> N;
    vector<int> TAKO(N);
    for(int i = 0; i < N; i++){
        cin >> TAKO.at(i);
    }
    
    int ans = 0;
    
    for(int a = 0; a < N; a++){
        for(int b = 0; b < N; b++){
            if (a == b) continue;
            ans += TAKO.at(a) * TAKO.at(b);
        }
    }
    
    ans = ans / 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){

	long long int mod=1000000007;
	long long int dp[2001]={0};
	dp[0]=1;
	dp[1]=dp[2]=0;
	for(int i=3; i<2001; i++){
		for(int j=3; i-j>=0 && j<2001; j++){
			dp[i]=(dp[i]+dp[i-j]);
		}
		dp[i]%=mod;
	}

	long long int n;
	cin>>n;
	
	if(n<3)
		cout<<0;
	else
		cout<<dp[n];
}

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

typedef long long ll;
typedef long double ld;

const int MAXN = 100 * 1000 + 7;
vector<int> g[MAXN];
int p[MAXN];
int col[MAXN];
void dfs(int v, int pp) {
	p[v] = pp;
	for (int to : g[v]) {
		if (to != pp) {
			dfs(to, v);
		}
	}
}
void cdfs(int v) {
	for (int to : g[v]) {
		if (col[to] == 0) {
			col[to] = col[v];
			cdfs(to);
		}
	}
}
int main() {
#ifdef LOCAL
	freopen("input.txt", "r", stdin);
#endif
	int n;
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int u, v;
		scanf("%d %d", &u, &v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(1, -1);
	vector<int> path;
	int v = n;
	while (v != 1) {
		path.push_back(v);
		v = p[v];
	}
	path.push_back(1);
	reverse(path.begin(), path.end());
	for (int i = 0; i < (int)path.size(); i++) {
		if (i + 1 <= (int)path.size() - i) {
			col[path[i]] = 1;
		} else {
			col[path[i]] = 2;
		}
	}
	for (int i = 0; i < (int)path.size(); i++) {
		cdfs(path[i]);
	}
	int cb = 0, cw = 0;
	for (int i = 1; i <= n; i++) {
		if (col[i] == 1) {
			cb++;
		} else {
			cw++;
		}
	}
	if (cb > cw) {
		printf("Fennec\n");
	} else {
		printf("Snuke\n");
	}
}



Measured memory_bytes: 11640
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mem(a,x) memset(a,x,sizeof(a))
#define nl "\n"
#define fout(x) fixed<<setprecision(x)
#define one(x) __builtin_popcountll(x)
#define F first
#define S second
#define or_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// find_by_order(), order_of_key()

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << fout(10)<<x;}
void __print(double x) {cerr << fout(10)<<x;}
void __print(long double x) {cerr << fout(10)<<x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const int mod=1e9+7;
const double eps=1e-9;
const double PI=acos(-1.0);

ll qpow(ll n,ll k){ll ans=1;assert(k>=0);n%=mod;while(k>0){if(k&1)ans=(ans*n)%mod;n=(n*n)%mod;k>>=1;}return ans%mod;}


// ****************************************************



int main()
{
    int n, m;
    cin>>n>>m;
    ll tot=0;
    for(int i=0; i<m; i++){
        ll x;
        cin>>x;
        tot+=x;
    }
    tot=n-tot;
    if(tot<0) tot=-1;
    cout<<tot<<endl;
}


Measured memory_bytes: 3600
s=input()
def r(a):
    ll,l=[],1
    for i in range(len(a)-1):
        if a[i]==a[i+1]:
            l+=1
        else:
            ll.append(l)
            l=1
    ll.append(l)
    return ll
s=r(s)
for i in range(len(s)//2):
    for j in range(s[2*i]-1):
        print(0,end=' ')
    print((s[2*i]+1)//2+s[2*i+1]//2,end=' ')
    print((s[2*i+1]+1)//2+s[2*i]//2,end=' ')
    for j in range(s[2*i+1]-1):
        print(0,end=' ')

Measured memory_bytes: 4760
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ans;

		ArrayList<Integer> numArray = new ArrayList<>();

		for(int i = 0; i < N; i++){
		numArray.add(sc.nextInt());
		}
		Collections.sort(numArray);

		ans = numArray.get(N-1) - numArray.get(0);
		System.out.println(ans);

		sc.close();
	}

}


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

using namespace std;

#define PI (3.14159265358979323846)
#define MP make_pair
#define n1 first
#define n2 second
#define ALL(x) (x).begin(), (x).end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MS multiset
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define SZ(x) ((int)x.size())

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

const db eps = 0.00001;
const int INF = 1000000007;
const ll LINF = 1000000000000000555;
const int N = 750555;
const int M = 1125;

void solve() {
    int n;
    cin >> n;

    string s;
    cin >> s; // s = RRR...RRRWWW...WWW

    int ww = 0, rr = 0;
    for (int i = 0; i < n; i++){
        if (s[i] == 'W') ww++; else
            rr++;
    }

    if (ww == 0 || rr == 0){
        cout << 0;
        return;
    }

    int i = 0, j = n-1;

    int ans = 0;
    while (i < j){
        while (s[i] == 'R') i++;
        while (s[j] == 'W') j--;
        if (i >= j) continue;
        swap(s[i], s[j]);
        i++;
        j--;
        ans++;
    }

    cout << ans;

}

int main() {
    ios_base::sync_with_stdio(false);

#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 3772
n, a, b = map(int, input().split())

# nは高橋君の試行よりも絶対に小さいとする

# 青を置いて赤を置いて，という一連の動作がnの中に何個入っているか
c = int(n / (a+b))
count = c * a

#余りの部分
d = int(n % (a+b))
#dが青いボールよりも大きい場合
if d > a:
    count += a

#dが青いボールよりも小さい場合
if d <= a:
    count += d

print(count)



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

using namespace std;

int main() {
    int L, R;
    int ans;
    const int DIV = 2019;

    cin >> L >> R;

    int L_div = R / DIV;
    int R_div = L / DIV;

    if (L_div != R_div) {
	ans = 0;
    } else {
        ans = DIV;
        for (int i = L; i <= R; i++) {
            for (int j = i+1; j <= R; j++) {
                long long m = (long long)i*j;
                int rem = m % DIV;
                ans = min(ans, rem);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

ll max4(ll a,ll b,ll c,ll d){
    if (a>b) swap(a,b);
    if (b>c) swap(b,c);
    if (c>d) swap(c,d);
    return d;
}
int main()
{
    ios::sync_with_stdio(false);

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

    }else {
        cout << max4(a*c,a*d,b*c,b*d);
    }
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){
    int n,k;
    cin >> n >> k;
    int A[n + 5];
    REP(i,n){
        cin >> A[i];
    }

    int summ = 0;
    REP(i,n) summ += A[i];
    vector<int> all_hu;
    REP(i,n){
        if(A[i] < 0) all_hu.push_back(A[i]);
    }
    Sort(all_hu);
    int all_hu_size = all_hu.size();

    int res = 0;
    REP(i,k+1){
        // i 宝石を見る個数
        int huko = k - i;
        int tmp_sum = 0;
        if(i >= n){
            tmp_sum = summ;
            REP(j,min(huko,all_hu_size)){
                tmp_sum -= all_hu[j];
            }
            res = max(res,tmp_sum);
            continue;
        }
        REP(j,i+1){
            // jは左からとる個数
            vector<int> hu;
            tmp_sum = 0;
            REP(kk,j){
                tmp_sum += A[kk];
                if(A[kk] < 0) hu.push_back(A[kk]);
            }
            REP(kk,i - j){
                tmp_sum += A[n-1-kk];
                if(A[n-1-kk] < 0) hu.push_back(A[n-1-kk]);
            }
            Sort(hu);
            int hu_size = hu.size();
            REP(kk, min(huko,hu_size)){
                tmp_sum -= hu[kk];
            }
            res = max(res,tmp_sum);
            //if(tmp_sum == 98) cout << i << " " << j << endl;
        }
        
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int dp[20][20][2];
int x[20][20];
int H, W;
void A(int a, int b, int c, int d) {
	if (x[a][b] == 2) {
		if (d != 0) { return; }
		if (c == 1) { return; }
		if (c == 0) {
			if (x[a + 2][b] == 1) { return; }
			dp[a + 2][b][0] += dp[a][b][c];
			return;
		}
	}
	if (x[a + 1][b + d] == 1) { return; }
	if (x[a + 1][b + d] == 2 && d != 0) { return; }
	if (x[a][b] == 0) {
		if (d == 0) {
			dp[a + 1][b + d][0] += dp[a][b][c];
		}
		else {
			dp[a + 1][b + d][1] += dp[a][b][c];
		}
	}
}
int main() {
	while (true) {
		cin >> W >> H;
		if (H == 0 && W == 0) { break; }
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				cin >> x[i][j];
			}
		}
		for (int i = 0; i < 20; i++) {
			for (int j = 0; j < 20; j++) {
				dp[i][j][0] = 0;
				dp[i][j][1] = 0;
			}
		}
		for (int i = 1; i <= W; i++) {
			if (x[1][i] == 0) {
				dp[1][i][0] = 1;
			}
		}
		for (int i = 1; i <= H - 1; i++) {
			for (int j = 1; j <= W; j++) {
				A(i, j, 0, -1);
				A(i, j, 0, 0);
				A(i, j, 0, 1);
				A(i, j, 1, -1);
				A(i, j, 1, 0);
				A(i, j, 1, 1);
			}
		}
		int sum = 0;
		for (int j = H; j < 20; j++) {
			for (int i = 1; i <= W; i++) {
				sum += dp[j][i][0] + dp[j][i][1];
			}
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#define mod 1000000007

using namespace std;

int main()
{
    long long int n;
    
    cin >>n; 
    
    int f=1;
    
    while(n)
    {
        f=f*n%mod;
        n--;
    }
    cout << f;
    

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	
	int n;
	char str[105];
	scanf ("%d %s", &n,str);
	int check = 1;
	
	for (int i = 0; i < n/2; i++){
			if (str[i] != str[i + n/2]){
				check = 0;
				break;
			}
		}
	
	if (check == 0 || n % 2 != 0){
		printf ("No\n");
	}
	else{
		printf ("Yes\n");
	}
	
	return 0;
}

Measured memory_bytes: 1624
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    set<char> st;
    fore(i,'a','z'+1) st.insert(i);
    string s;
    cin >> s;
    int n = s.size();
    fore(i,0,n) st.erase(s[i]);
    if (st.size()) cout << *st.begin() << endl;
    else cout << "None\n";
}


Measured memory_bytes: 512
#
# File    : B.rb
# Author  : Kazune Takahashi
# Created : 2018-12-1 22:21:49
# Powered by Visual Studio Code
#

n = gets.chomp
x = n.to_i
sum = 0
n.chars{|c|
  sum += c.to_i
}
if x % sum == 0
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
#include <iostream>
#include <string> 
using namespace std;
int main(void){
    // Your code here!
    string S;
    string T;
    
    cin >> S >> T;
    T.pop_back();
    if(S == T){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int count = 0;
        for (int i = 0; i <= n - 3; i++) {
            String sub = s.substring(i, i+3);
            if (sub.equals("ABC")) count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 21972
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 2005
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define mp make_pair
#define ll long long
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll n, m, k, ans;
int f = 1;
string s;
deque<char> q;
int main() {
	io(); cin >> s;
	rep(i, 0, (s.length() - 1)) q.push_back(s[i]);
	cin >> k;
	rep(i, 1, k) {
		int op; cin >> op;
		if (op == 1) f ^= 1;
		else {
			int x; char ch;
			cin >> x >> ch;
			if (x == 1) {
				if (f) q.push_front(ch);
				else q.push_back(ch);
			}
			else {
				if (f) q.push_back(ch);
				else q.push_front(ch);
			}
		}
	}
	string ans;
	while (!q.empty()) {
		ans += q.front();
		q.pop_front();
	}
	if (!f) reverse(ans.begin(), ans.end());
	cout << ans;
}

Measured memory_bytes: 1368
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final int a = sc.nextInt();
			final int b = sc.nextInt();
			
			if(a + b == 15) {
				System.out.println("+");
			}else if(a * b == 15) {
				System.out.println("*");
			}else {
				System.out.println("x");
			}
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21204
#include<stdio.h>
int main()
{
int a[3],f=0,s=0,i,t;
for(i=0;i<3;i++)
{
scanf("%d ",&a[i]);
if(a[i]==5)
f++;
else if(a[i]==7)
s++;
}
t=f+s;
if(t==3&&f==2&&s==1)
printf("YES");
else
printf("NO");
}

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

const int MOD = (int)1e9+7;

int main(){
	string S;
	cin >> S;

	if(S.at(0)==S.at(1) && S.at(0)==S.at(2))	cout << "No" << endl;
	else if(S.at(0)==S.at(1) && S.at(2)==S.at(3))	cout << "Yes" << endl;
	else if(S.at(0)==S.at(2) && S.at(1)==S.at(3))	cout << "Yes" << endl;
	else if(S.at(0)==S.at(3) && S.at(1)==S.at(2))	cout << "Yes" << endl;
	else	cout << "No" << endl;

	return 0;
}


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

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr ll inf = 1ll<<62;
int main(){
    int n;
    cin>>n;
    vector<int> a(3),b(3);
    for(auto & t : a) cin>>t;
    for(auto & t : b) cin>>t;
    ll ret = n;
    for(int i=0;i<2;++i){
        vector<ll> dp(ret+1);
        iota(dp.begin(),dp.end(),0);
        for(int j=0;j<3;++j){
            for(int k=0;k+a[j] <=ret;++k){
                dp[k+a[j]] = max(dp[k+a[j]],dp[k] + b[j]);
            }
        }
        ret = dp[ret];
        swap(a,b);
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 195584
n = int(input())
list_A = list(map(int, input().split()))
list_S = list_A.copy()
list_S.sort()
left = list_S[n//2-1]
right = list_S[n//2]

for num in list_A:
    if num < right:
        print(right)
    if num > left:
        print(left)
    if num == right and num == left:
        print(num)

Measured memory_bytes: 25620
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long int ll;
using namespace std;
int main()
{
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2>>y2;
  int dx = x1- x2;
  int dy = y1- y2;
  int x3, y3, x4, y4;
  x3 = x2 + dy;
  y3 = y2 - dx;
  x4 = x3 + dx;
  y4 = y3 + dy;
  cout << x3 <<" " << y3 <<" " << x4 << " " <<y4 << endl;
}


Measured memory_bytes: 256
function main(lines) {
  const input = s();
  
  let ans = 'NO';
  switch (input) {
    case '7 5 5':
    case '5 7 5':
    case '5 5 7':
      ans = 'YES';
  }
  
  return ans;
}



const lines = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");

let lineCount = 0;
const s = () => lines[lineCount++];
const n = () => Number(s());
const b = () => BigInt(s());
const sa = () => s().split(' ');
const na = () => sa().map(Number);
const ba = () => sa().map(BigInt);

const ans = main(lines);
console.log( ans );

Measured memory_bytes: 29632
import java.util.*;

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();
        for(int i=0;i<s.length();i++){
            if(s.charAt(i)!=t.charAt(i)){
                System.out.println("No");
                return;
            }
        }
        
        System.out.println("Yes");
    }
}

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

int main(){

int a;
int b;

cin >> a >> b; 

if(a>b){
cout << "a" << " > " << "b" << endl;
}

if(a==b){
cout << "a" << " == " << "b" << endl;
}

if(a<b){
cout << "a" << " < " << "b" << endl;
}
}

Measured memory_bytes: 3080
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

const int MAXN = 123456;
const LL MOD = (LL)1e9 + 7;
int x[MAXN];
LL fac[MAXN], cfsum[MAXN];

LL mul(LL a, LL b) {
    return (a * b) % MOD;
}

LL qpow(LL n, LL p) {
    LL res = 1, base = n;
    while (p) {
        if (p % 2) res = mul(res, base);
        base = mul(base, base);
        p /= 2;
    }
    return res;
}

int main() {
    fac[0] = 1;
    for (int i = 1; i < MAXN; i++)
        fac[i] = mul(fac[i - 1], i);
    int N;
    scanf("%d", &N);
    for (int i = 0; i < N; i++)
        scanf("%d", &x[i]);
    for (int i = 0; i < N; i++) {
        LL cur = mul(fac[N - 1], qpow(i + 1, MOD - 2));
        cfsum[i] = cur;
        if (i) cfsum[i] = (cur + cfsum[i - 1]) % MOD;
    }
    LL ans = 0;
    for (int i = 0; i < N - 1; i++) {
        LL d = x[i + 1] - x[i];
        ans = (ans + mul(d, cfsum[i])) % MOD;
    }
    printf("%lld\n", ans);
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
by Benq;
*/


Measured memory_bytes: 5928
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);

int main() {
  double a, b, x;
  cin >> a >> b >> x;
  x /= a;
  double rad;
  if (a * b / 2 < x) {
    x = a * b - x;
    double h = x * 2 / a;
    rad = atan(h / a);
  } else {
    double w = x * 2 / b;
    rad = atan(b / w);
  }
  printf("%.6f\n", rad * 180 / PI);
  return 0;
}

Measured memory_bytes: 512
N,M = map(int,input().split())
G = [[] for _ in range(N)]
H = []
for i in range(M):
  a,b = map(int,input().split())
  a-=1;b-=1 #0index
  G[a].append([b,i]);G[b].append([a,i]) #iを辺のIDとして保存
  H.append([a,b])
ans = 0
 
def dfs(v,ID): #IDの辺を使えない
  visited.add(v)
  for u,idx in G[v]:
    if idx == ID or u in visited:
      continue
    dfs(u,ID)
 
for i in range(M):
  visited = set([])
  start = H[i][0]
  goal = H[i][1]
  dfs(start,i)
  if goal not in visited:
    ans +=1
print(ans)

Measured memory_bytes: 9212
from scipy.optimize import fmin
N = int(input())

INF = 10 ** 18
fixed_x, R, L = [], [], []
fixed_y, U, D = [], [], []

def update(fixed, li, x, y):
  li.append(x)
  fixed.append(y)
  
for _ in range(N):
  x,y,d = input().split()
  x,y = int(x), int(y)
  if d == 'L':
    update(fixed_y, L, x, y)
  elif d == 'R':
    update(fixed_y, R, x, y)
  elif d == 'U':
    update(fixed_x, U, y, x)
  else:
    update(fixed_x, D, y, x)

for li in ['fixed_x', 'L', 'R', 'fixed_y', 'D', 'U']:
  exec('{0} = [min({0} + [INF]), max({0} + [-INF])]'.format(li))

def calc_x(t, fixed, dec, inc):
  left = INF
  right = -INF
  for li, speed in [(fixed, 0), (dec, -1), (inc, 1)]:
    left = min(left, li[0] + speed * t)
    right = max(right, li[1] + speed * t)
  return right - left

def area(t):
  if t < 0:
    return INF
  return calc_x(t, fixed_x, L, R) * calc_x(t, fixed_y, D, U)

xopt = fmin(area, x0 = 10**8, ftol = 10**-9, disp = False)
answer = area(xopt[0])
print(answer)


Measured memory_bytes: 26232
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

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

int main() {
  int a, b;
  cin >> a >> b;
  int p = max(a * b, a - b);
  p = max(p, a + b);
  cout << p << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

set<pair<int, int> > totest, has;

int H, W;

bool valid(int h, int w) {
	return h > 0 && h <= H && w > 0 && w <= W;
}

int main() {
	cin >> H >> W;
	totest.clear();
	has.clear();
	int n, a, b;
	cin >> n;
	FOR (i, n) {
		cin >> a >> b;
		has.insert(make_pair(a, b));
		ffor (h, a - 2, a + 1)
			ffor (w, b - 2, b + 1)
				if (valid(h, w) && valid(h + 2, w + 2))
					totest.insert(make_pair(h, w));
	}
	vector<LL> ret;
	FOR (i, 10)
		ret.pb(0);
	LL sum = 0;
	for (set<pair<int, int> >::iterator it = totest.begin(); it != totest.end(); it++) {
		int cnt = 0;
		int a = (*it).first, b = (*it).second;
		FOR (h, 3)
			FOR (w, 3)
				cnt += has.count(make_pair(a + h, b + w)) != 0;
		ret[cnt]++;
		sum++;
	}
	ret[0] = 1LL * (H - 3 + 1) * (W - 3 + 1) - sum;
	FOR (i, 10)
		cout << ret[i] << endl;
	return 0;
}

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

using namespace std;

using ll = long long;

template<int MOD>
struct ModInt {
   using Mint = ModInt;
   int val;
   ModInt(ll __val = 0) { fix(__val % MOD + MOD); }
   Mint& fix(int __val) { val = __val; if (val >= MOD) val -= MOD; return *this; }
   explicit operator int() { return val; }
   Mint operator + (const Mint &mt) const { return Mint().fix(val + mt.val); }
   Mint operator - (const Mint &mt) const { return Mint().fix(val - mt.val + MOD); }
   Mint operator * (const Mint &mt) const { return Mint().fix(ll(val) * mt.val % MOD + MOD); }
   Mint& operator += (const Mint &mt) { return *this = *this + mt; }
   Mint& operator -= (const Mint &mt) { return *this = *this - mt; }
   Mint& operator *= (const Mint &mt) { return *this = *this * mt; }
   Mint pow(int y) const {
      Mint x = *this;
      Mint ans(1);
      for (; y > 0; y >>= 1, x *= x) {
         if (y & 1) ans *= x;
      }
      return ans;
   }
   Mint operator -() const { return Mint().fix(MOD - val); }
   Mint inv() const { return pow(MOD - 2); }
   Mint operator / (const Mint &mt) const { return *this * mt.inv(); }
   Mint& operator /= (const Mint &mt) const { return *this / mt; }
   friend ostream& operator<<(ostream& os, const Mint& mt) { return os << mt.val; }
};

using Mint = ModInt<1000000007>;


int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   int H; cin >> H;
   int L = 1 << (H - 1);
   vector<int> P(L);
   for (int i = 0; i < L; ++i) cin >> P[i], --P[i];
   vector<Mint> prod(L << 1);
   prod[1] = 1;
   for (int i = 2; i < (L << 1); ++i) {
      prod[i] = prod[i >> 1] * Mint(i);
   }
   vector<Mint> inv_prod(L << 1);
   for (int i = 1; i < (L << 1); ++i) inv_prod[i] = prod[i].inv();
   Mint ans = 0;
   for (int i = L - 1; i >= 1; --i) {
      vector<array<int, 2>> go;
      vector<Mint> sum;
      go.emplace_back();
      sum.emplace_back();
      int h = H - 1 - __lg(i);
      int low = i << h;
      int high = (i + 1) << h;
      int mid = (low + high) >> 1;
      for (int v = low - L; v < mid - L; ++v) {
         int cur = 0;
         for (int b = H - 2; b >= 0; --b) {
            int z = P[v] >> b & 1;
            if (!go[cur][z]) {
               go[cur][z] = sum.size();
               go.emplace_back();
               sum.emplace_back();
            }
            cur = go[cur][z];
            sum[cur] += prod[v + L] * prod[P[v] + L];
         }
      }
      for (int v = mid - L; v < high - L; ++v) {
         int cur = 0;
         int cur_val = 1;
         for (int b = H - 2; b >= 0; --b) {
            int z = P[v] >> b & 1;
            if (go[cur][z ^ 1]) {
               ans += prod[v + L] * prod[P[v] + L] * inv_prod[cur_val] * inv_prod[cur_val] * inv_prod[i] * inv_prod[i] * Mint(i) * Mint(cur_val) * sum[go[cur][z ^ 1]];
            }
            if (!go[cur][z]) break;
            cur_val = cur_val << 1 | z;
            cur = go[cur][z];
         }
      }
   }
   cout << ans << '\n';
   return 0;
}


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

constexpr int INF = (1 << 30);
constexpr int MAX = 10010;

void chmin (int &a, int b) {
	if (a > b) a = b;
}

int main() {
	int n, max_w;
	cin >> n >> max_w;
	vector<int> v(n), w(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i] >> w[i];
	}
	
	vector<int> dp(MAX, INF);
	dp[0] = 0;
	
	for (int i = 0; i < n; i++) {
		for (int sum_v = MAX; sum_v--> 0;) {
			chmin(dp[sum_v + v[i]], dp[sum_v] + w[i]);
		}
	}
	
	int max_v = 0;
	for (int sum_v = 0; sum_v < MAX; sum_v++) {
		if (dp[sum_v] <= max_w) max_v = sum_v;
	}
	
	cout << max_v << '\n';
	
	return 0;
}


Measured memory_bytes: 3156
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

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

	if (n * a <= b) {
		cout << n * a << endl;
	}
	else {
		cout << b << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 1;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/
int main()
{
	int		a,b,c,i,j,k,n,m,x,y,ans = 0;
	char	s[256];
	
	scanf("%d %d %d", &a, &b, &c);
	
	if (a+b+c >=22) printf("bust\n");
	else printf("win\n");
	



	return 0;
}


Measured memory_bytes: 128
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize,
    mut ab: [(usize, usize); n]
    }
    ab.sort_by(|x, y| x.1.partial_cmp(&y.1).unwrap());
    let mut t = 0;
    for i in 0..n {
        let (a, b) = ab[i];
        t += a;
        if t > b {
            println!("No");
            return
        }
    }
    println!("Yes");
}


Measured memory_bytes: 9112
a, b, c, d = map(int, input().split())

flg = False
while True:
  if c - b <= 0:
    flg = True
    break
  
  if a - d <= 0:
    flg = False
    break
  
  a -= d
  c -= b
  
print('Yes' if flg else 'No')

Measured memory_bytes: 9176
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const ll MOD = ll(1e9) + 7;
const ll INF = LLONG_MAX;
const ll MAX_N = 1 << 20;
const double EPS = 10e-8;
const double PI = 3.14159265359;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)

int n,w[300005]{},e[300005]{};
string s;

int main() {
    cin >> n >> s;
    REP(i,n){
        if(s[i]=='W')w[i+1]++;
        else e[i+1]++;
        w[i+1] += w[i];
        e[i+1] += e[i];
    }
    int ans = 99999999;
    REP(i,n){
        ans = min(ans,w[i]+e[n]-e[i+1]);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3076
import sys
s = list(input())
if s[0] != "A":
    print("WA")
    sys.exit()
c = 0
for i in range(2,len(s)-1):
    if s[i] == "C":
        c += 1
if c != 1:
    print("WA")
    sys.exit()
c = 0
for i in range(len(s)):
    if ord(s[i]) >= 65 and ord(s[i]) <= 90:
        c += 1
if c == 2:
    print("AC")
else:
    print("WA")

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

int main()
{
	int a, b;
	char op;

	while (1) {
		cin >> a >> op >> b;
		if (op == '+') {
			cout << a + b << "\n";
		}
		else if (op == '-') {
			cout << a - b << "\n";
		}
		else if (op == '*') {
			cout << a * b << "\n";
		}
		else if (op == '/') {
			cout << a / b << "\n";
		}
		else if (op == '?') {
			break;
		}
	}
    return 0;
}




Measured memory_bytes: 3080