akhauriyash/Code-Regression huggingface dataset:
char s[9];x,l,i;P(a){
	sprintf(s,"%d",a),l=strlen(s);
	for(x=0;x<l&s[x]==s[l-x-1];x++);
	return x==l;
}
main(n){for(scanf("%d",&n);;i++){
	if(P(n-i))printf("%d\n",n-i),exit(0);
	if(P(n+i))printf("%d\n",n+i),exit(0);
}}

Measured memory_bytes: 616
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
int main(){
  int A,B,C;
  str S1,S2,S3;
  str N;
  cin>>N;
  if(N.at(0)==N.at(2))cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
/*input
10 0
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=105;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
vector<pii> v;
int g[maxn][maxn];
int main()
{
	IOS;
	int n,k;
	cin>>n>>k;
	ll ans=0;
	for(int b=k+1;b<=n;b++){
		int rem=n%b;
		int tm=n/b;
		ans+=tm*(b-k);
		ans+=max(0,rem+1-k);
		//cout<<ans<<'\n';
	}
	if(k==0) ans-=n;
	cout<<ans<<'\n';
}



Measured memory_bytes: 256
#include<stdio.h>

#define MAX 2000000

int H,A[MAX+1];

void maxHeapify(int i){
  int l,r,largest,t;
  l = 2*i;
  r = 2*i+1;

  if(l<=H&&A[l] > A[i]) largest = l;
  else largest = i;
  if(r<=H&&A[r] > A[largest]) largest = r;

  if(largest!=i){
    t=A[i];
    A[i]=A[largest];
    A[largest] = t;
    maxHeapify(largest);
  }
}

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

  for(i = 1; i<=H;i++) scanf("%d",&A[i]);
      
  for(i = H/2; i>=1;i--) maxHeapify(i);

  for(i = 1; i<=H; i++){
    printf(" %d",A[i]);
  }
  printf("\n");
  return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

const int INF = 1000000007;
const ll INFLL = 1000000000000000007;

#define st first
#define nd second
#define pb push_back
#define _boost ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

// ***************************** CODE ***************************** //

const int SIZE = 2e5 + 7;
const int MAX = 1 << 18;

ll h[SIZE], a[SIZE], dp[SIZE];
ll tree[2*MAX];

void update(int p, ll v)
{
    p += MAX;
    tree[p] = max(tree[p], v);
    while(p >= 1)
    {
        p /= 2;
        tree[p] = max(tree[2*p], tree[2*p+1]);
    }
}

ll query(int a, int b)
{
    a += MAX; b += MAX;
    ll res = max(tree[a], tree[b]);
    while(a/2 != b/2)
    {
        if(a%2 == 0) res = max(res, tree[a+1]);
        if(b%2 == 1) res = max(res, tree[b-1]);
        a /= 2; b /= 2;
    }
    return res;
}

int main() {
    _boost;

    int n;  cin >> n;
    for(int i = 0; i < n; i++)
        cin >> h[i];
    for(int i = 0; i < n; i++)
        cin >> a[i];

    for(int i = 0; i < n; i++)
    {
        ll best = query(0, h[i]-1);
        dp[h[i]] = best + a[i];
        update(h[i], dp[h[i]]);
    }

    ll ans = 0;
    for(int i = 0; i <= n; i++)
        ans = max(ans, dp[i]);

    cout << ans;

    return 0;
}


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

const int M = 998244353;
void add(ll &x, ll y) { x = (x+y)%M; }

int main () {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  
  int n, s;
  cin >> n >> s;
  vector<ll> a(n);
  for (ll &x : a) cin >> x;
  vector<ll> q(s+1);
  ll ans = 0;
  rep(i, n) {
    add(q[0], 1);
    //-----
    for (int j = s; j >= 0; --j) if (j + a[i] <= s) add(q[j + a[i]], q[j]);
    //-----
    add(ans, q[s]);
  }
  cout << ans << endl;
}

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

int main(){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int diffx = tx - sx;
  int diffy = ty - sy;
  int i;
  for(i = 0; i < diffx; i++)
    cout << 'R';
  for(i = 0; i < diffy+1; i++)
    cout << 'U';
  for(i = 0; i < diffx+1; i++)
    cout << 'L';
  for(i = 0; i < diffy+1; i++)
    cout << 'D';
  cout << 'R';
  for(i = 0; i < diffy; i++)
    cout << 'U';
  for(i = 0; i < diffx+1; i++)
    cout << 'R';
  for(i = 0; i < diffy+1; i++)
    cout << 'D';
  for(i = 0; i < diffx+1; i++)
    cout << 'L';
  cout << 'U';
  
  return 0;
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

int n, mnr, mxl;

struct Node {
	int l, r;

	bool operator < (const Node &rhs) const {
		return l < rhs.l;
	}
} a[100005];

int mn[100005];

int main() {
	read(n);
	for (int i = 1; i <= n; ++i) {
		read(a[i].l), read(a[i].r);
		++a[i].r;
	}
	std::sort(a + 1, a + 1 + n);
	mn[n + 1] = 0x3f3f3f3f;
	for (int i = n; i; --i) {
		mn[i] = std::min(mn[i + 1], a[i].r);
	}
	int ans = 0;
	for (int i = 1; i < n; ++i) {
		ans = std::max(ans, std::max(mn[1] - a[i].l, 0) + std::max(mn[i + 1] - a[n].l, 0));
	}
	for (int i = 1; i <= n; ++i) {
		ans = std::max(ans, a[i].r - a[i].l + std::max(mn[1] - a[n].l, 0));
	}
	print(ans);
}


Measured memory_bytes: 6716
#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 X; cin >> X;
    vector <int> A(X);
    
    int i=2;
    int ans=1;
    int tmp;
    while(1){
        int k=1;
        while(1){
            if(pow(i,k)>X){
                tmp=pow(i,k-1);
                break;
            }
            else k++;
        }
        ans=max(tmp,ans);
        i++;
        if (pow(i,2)>X) break;
    }
    cout << ans;   
}

Measured memory_bytes: 512
#include <iostream>
#include <string>

char rotate(char c)
{
  return c == 'L' ? 'R' : 'L';
}

long solve(long n, long k, std::string& s)
{
  if (n == 1) return 0;
  if (n == 2) return 1;

  const char target = rotate(s[0]);
  std::string::size_type first = 0;
  std::string::size_type last = 0;
  for (int i = 0; i < k; ++i) {
    first = s.find(target, last);
    if (first == std::string::npos) break;
    last = s.find(rotate(target), first + 1);
    if (last == std::string::npos) last = s.size();
    s.replace(
        first,
        last - first,
        last - first,
        rotate(target));
  }

  long result = 0;
  if (s[0] == 'R' && s[1] == 'R') result += 1;
  if (s[n - 1] == 'L' && s[n - 2] == 'L') result += 1;
  for (int i = 1; i < n - 1; ++i) {
    if (s[i] == 'R' && s[i + 1] == 'R') {
      result += 1;
    } else if (s[i] == 'L' && s[i - 1] == 'L') {
      result += 1;
    }
  }
  return result;
}

int main()
{
  long n, k;
  std::string s;
  std::cin >> n >> k >> s;

  std::cout << solve(n, k, s) << std::endl;
}


Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main {
    public static void main(String[] args) throws java.lang.Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        br.readLine();

        double[] array = Arrays.stream(br.readLine().split(" ")).mapToDouble(Double::parseDouble).toArray();

        double gyakusum = Arrays.stream(array).map(i -> 1 / i).sum();

        System.out.println(1 / gyakusum);

    }
}

Measured memory_bytes: 27476
n,m=map(int,input().split())
dct={}
for i in range(n):
    k,v=map(int,input().split())
    if k not in dct.keys():
        dct[k]=v
    else:
        dct[k]+=v
sdct=sorted(dct.items())
yen=0
for k,v in sdct:
    if v<=m:
        m-=v
        yen+=k*v
    else:
        yen+=k*m
        break
print(yen)

Measured memory_bytes: 22992
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int main(){
    int N;
    cin >> N;
    int ans = 0;
    int cnt = 0;
    rep(i,N){
        int d,dd;
        cin >> d >> dd;
        if(d == dd) cnt++;
        else{
            cnt = 0;
        }
        if(cnt == 3) ans=1;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{

    fastio;
    ll a , b , res = 0 ; cin >> a >> b ;
    ll ma = max (a , b) , mi = min(a , b);
    vi vv ;
    if (ma % mi == 0) res = ma ;
    else {
        forr (2 , mi){
            if (ma % i == 0 && mi % i ==0)
            	vv . push_back (i) ;
        }
        res = (vv. empty () ? ma * mi : ma * (mi / vv .back())) ;
    }
    cout << res << endl ;
    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



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

int main(void){
 int a,b;
 cin>>a>>b;
 a=(a-1)%13;
 if(!a)a=13;
 b=(b-1)%13;
 if(!b)b=13;
  if(a>b)cout<<"Alice"<<endl;
   else if(a<b)cout<<"Bob"<<endl;
   else cout<<"Draw"<<endl;
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

const double eps = 1e-15;

bool IsEq(double d1, double d2)
{
    if (d1 - d2 > -eps && d1 - d2 < eps){
        return true;
    } else {
        return false;
    }
}

class Point2D {
public:
    double x, y;
    Point2D() : x(0), y(0) {}
    Point2D(double _x, double _y) : x(_x), y(_y) {}
    virtual ~Point2D() {}
};

istream& operator >> (istream& input, Point2D& P)
{
    input >> P.x >> P.y;
    return input;
}

class Segment {
public:
    Point2D P, Q;
    Segment() {}
    Segment(const Point2D& _P, const Point2D& _Q) : P(_P), Q(_Q) {}
};

istream& operator >> (istream& input, Segment& Seg)
{
    input >> Seg.P >> Seg.Q;
    return input;
}

class Vector2D : public Point2D {
public:
    Vector2D(const Point2D& P) : Point2D(P) {}
    Vector2D(const Segment Seg) : Point2D(Seg.Q.x - Seg.P.x, Seg.Q.y - Seg.P.y) {}
    Vector2D(const Point2D Start, Point2D End) : Point2D(End.x - Start.x, End.y - Start.y) {}
    double InnerProd(const Vector2D Vec) const
    {
        return x * Vec.x + y * Vec.y;
    }
    double OuterProd(const Vector2D Vec) const
    {
        return x * Vec.y - y * Vec.x;
    }
    double Length() const
    {
        return sqrt((*this).InnerProd(*this));
    }
};

double Dist(const Point2D P, const Segment Seg)
{
    Vector2D V1(Seg);
    Vector2D V2(Seg.P, P);
    return V1.InnerProd(V2) / V1.Length();
}

double Dist(const Point2D P, const Point2D Q)
{
    Vector2D V(P, Q);
    return V.Length();
}

bool IsPara(Segment Seg1, Segment Seg2)
{
    Vector2D V1(Seg1), V2(Seg2);
    return IsEq(V1.OuterProd(V2), 0.);
}

bool IsOnSeg(Point2D P, Segment Seg)
{
    Vector2D V(Seg);
    return IsEq(V.Length(), Dist(P, Seg.P) + Dist(P, Seg.Q));
}

bool IsIntersect(Segment Seg1, Segment Seg2) {
    Vector2D P1(Seg1.P), P2(Seg2.P);
    Vector2D V1(Seg1), V2(Seg2);
    if (!IsPara(Seg1, Seg2)) {
        double t = (P2.OuterProd(V2) - P1.OuterProd(V2)) / V1.OuterProd(V2);
        double s = (P2.OuterProd(V1) - P1.OuterProd(V1)) / V1.OuterProd(V2);
        return t > -eps && t < 1 + eps && s > -eps && s < 1 + eps;
    } else {
        if (IsOnSeg(Seg1.P, Seg2) || IsOnSeg(Seg1.Q, Seg2) || IsOnSeg(Seg2.P, Seg1) || IsOnSeg(Seg2.Q, Seg1)) return true;
        return false;
    }
}

int main(int argc, const char * argv[]) {
    int q;
    Segment Seg1, Seg2;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        cin >> Seg1 >> Seg2;
        if (IsIntersect(Seg1, Seg2)) {
            cout << 1 << endl;
        } else {
            cout << 0 << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
ll mod=1000000007;

int main() {
  int n; cin >> n;
  vector<int> a(n);
  for (int i=0;i<n;++i) cin >> a[i];
  int b_0=0;
  int coef = 1;
  for (int i=0;i<n;++i) {
    b_0 += coef * a[i];
    coef *=-1;
  }
  vector<int> b(n);
  b[0] = b_0;
  for (int i=1;i<n;++i){
  	b[i] = 2*(a[i-1]-b[i-1]/2);
  }
  for (int i=0;i<n;++i){
     cout << b[i] << " ";
  }
  return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/


int main()
{
	long long a, b;

	cin >> a >> b;

	if (a*b == 15) {
		cout << "*";
	}
	else if (a+b == 15) {
		cout << "+";
	}
	else {
		cout << "x";
	}

	char qq;
	cin >> qq;
	return 0;
}

Measured memory_bytes: 256
# 入力を受け取る
input_line = input()

# 入力データを分割する
input_list = input_line.split()
a = int(input_list[0])
b = int(input_list[1])

if a < b :
    print("a < b")
elif a > b:
    print("a > b")
else :
    print("a == b")


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int,int>;
using pll = pair<long long, long long>;
const long long INF = 1<<29;

const int MOD = 1000000007;
long long ruizyou(long long m,long long n){
  if(m == 0)return 0;
  if(m == 1)return 1;
  long long ans = 1;
  long long tmp = m;
  for(int i=0;i<=30;i++){
    if(n & (1<<i)){
      ans *= tmp;
      ans %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
  }
  return ans;
}
long long kaizyou(long long x){
  if(x == 0)return 1;
  return x * kaizyou(x-1) % MOD;
}
long long comb(long long x,long long y){
  long long bunsi = kaizyou(x);
  long long bunbo = kaizyou(x-y) * kaizyou(y) % MOD;
  return bunsi * ruizyou((int)bunbo,MOD-2) % MOD;
}
struct unionfind{
  vector<int> par;
  vector<int> hukasa;
  unionfind(int n){
    par = vector<int>(n);
    hukasa = vector<int>(n,0);
    for(int i=0;i<n;i++){
      par.at(i) = i;
    }
  }
  int root(int x){
    if(par.at(x) == x)return x;
    return root(par.at(x));
  }
  void unite(int x,int y){
    int rx = root(x);
    int ry = root(y);
    if(rx == ry)return;
    if(hukasa.at(rx) >= hukasa.at(ry)){
      par.at(ry) = rx;
      hukasa.at(rx) = max(hukasa.at(ry) + 1,hukasa.at(rx));
    }
    else{
      par.at(rx) = ry;
    }
  }
  bool same(int x,int y){
    return root(x) == root(y);
  }
};
int ctoi(char a){
  return a - '0';
}
long long gcd(long long a,long long b){
  long long c = max(a,b);
  long long d = min(a,b);
  if(d % c == 0)return c;
  return gcd(c,d%c);
}
long long lcm(long long a,long long b){
  return a * b / gcd(a,b);
}
int main(){
  int n;
  cin >> n;
  int i=1;
  while(1000*i < n){
    i++;
  }
  cout << 1000 * i - n << endl;
}

Measured memory_bytes: 3644
#include <stdio.h>
int main()
{
	int x, y, temp;
	while (1)
	{
		scanf("%d %d", &x, &y);
		if (x == 0 && y == 0)break;
		else if (x > y)
		{
			temp = x;
			x = y;
			y = temp;
		}
		printf("%d %d\n", x, y);
	}
	return 0;
}


Measured memory_bytes: 2692
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int n;
  cin >>n;
  long long int a[n],lmax[n+1],rmax[n+1];
  for(long long int i=0;i<n;i++)cin >>a[i];
  lmax[0]=0;
  rmax[0]=0;
  for(long long int i=0;i<n;i++){
    lmax[i+1]=max(lmax[i],a[i]);
    rmax[i+1]=max(rmax[i],a[n-i-1]);
  }
  for(long long int i=0;i<n;i++)cout << max(lmax[i],rmax[n-i-1]) <<endl;

}

Measured memory_bytes: 6272
// AOJ ALDS1_6_A Counting Sort
// 2018.4.27 bal4u

#include <stdio.h>

#if 1
#define gc() getchar_unlocked()
#define pc(c) putchar_unlocked(c)
#else
#define gc() getchar()
#define pc(c) putchar(c)
#endif
int in()
{
	int n = 0, c = gc();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = gc(); while (c >= '0');
	return n;
}

char buf[20]; int w;
void mypr(int n)
{
	int i;
	if (!n) { putchar('0'); return; }
	w = 0; while (n) buf[w++] = n%10 + '0', n/=10;
	i = w; while (i--) pc(buf[i]);
}

// 計数ソート（整数用）昇順
#define MAX_N 10002
int f[MAX_N];
void counting_sort(int n, int *a, int *b, int max)
{
	int i, x;
//	memset(f, 0, sizeof(f));
	for (i = 0; i < n; i++) f[a[i]]++;
	for (i = 1; i <= max; i++) f[i] += f[i-1];
	for (i = n-1; i >= 0; i--) {
		x = a[i], b[--f[x]] = x;
	}
}

int a[2000002], b[2000002];

int main()
{
	int N, i, j;

	N = in();
	for (i = 0; i < N; i++) a[i] = in();
	counting_sort(N, a, b, 10000);
	if (!b[0]) putchar('0'); else mypr(b[0]);
	for (i = 1; i < N; i++) {
		pc(' ');
		if (!b[i]) putchar('0');
		else if (b[i] == b[i-1]) {
			j = w; while (j--) pc(buf[j]);
		} else mypr(b[i]);
	}
	pc('\n');
	return 0;
}



Measured memory_bytes: 17212
#include<stdio.h>
#include<string.h>
#define swap(a,b)({a ^= b; b ^= a; a ^= b;})

int main(){
    int n, i, j, a[101], mini;
    char dec[40][2], c;
    int bubble[40], selection[40], bubleStable, selectionStable;
    scanf("%d", &n);
    i=0;
    while(i<n){
        c = getchar();
        if(isupper(c)){
            dec[i][0] = c;
        }else if(isdigit(c)){
            dec[i][1] = c;
            bubble[i] = i;
            selection[i] = i;
            i++;
        }
    }

    for(i = 0; i<n; i++){
        for(j = n-1; j>= i+1; j--){
            if(dec[bubble[j]][1] < dec[bubble[j-1]][1]){
                swap(bubble[j], bubble[j-1]);
            }
        }
    }
    bubleStable = 1;
    for(i = 0; i<n-1; i++){
        if(dec[bubble[i]][1] == dec[bubble[i+1]][1]){
            if(bubble[i] > bubble[i+1]){
                bubleStable = 0;
            }
        }
        printf("%c%c ", dec[bubble[i]][0], dec[bubble[i]][1]);
    }printf("%c%c\n", dec[bubble[i]][0], dec[bubble[i]][1]);
    printf("%s\n", bubleStable? "Stable": "Not stable");

    for(i = 0; i<n; i++){
        mini = i;
        for(j=i+1;j<n;j++){
            if(dec[selection[j]][1] < dec[selection[mini]][1]) mini = j;
        }
        if(i != mini){
            swap(selection[i], selection[mini]);
        }
    }
    selectionStable = 1;
    for(i = 0; i<n-1; i++){
        if(dec[selection[i]][1] == dec[selection[i+1]][1]){
            if(selection[i] > selection[i+1]){
                selectionStable = 0;
            }
        }
        printf("%c%c ", dec[selection[i]][0], dec[selection[i]][1]);
    }printf("%c%c\n", dec[selection[i]][0], dec[selection[i]][1]);
    printf("%s\n", selectionStable? "Stable": "Not stable");

return 0;
}



Measured memory_bytes: 2056
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    A = LI()
    cur_x = 0
    tot = 0
    for a in A:
        tot += abs(cur_x - a)
        cur_x = a
    tot += abs(cur_x - 0)
    A.append(0)
    cur_x = 0
    for i in range(N):
        print(tot - abs(cur_x - A[i]) - abs(A[i] - A[i+1]) + abs(cur_x - A[i+1]))
        cur_x = A[i]
main()



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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second

ll mod = 2019 , dp[3][2022] , rem[300005];

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

    string s;
    cin >> s;
    ll n = s.size();
    s = ' '+s;

    for(int i=0; i<30000; i++)
    {
        rem[i] = i%mod;
    }

    ll ans=0;
    dp[0][s[1]-'0'] = 1;
    for(int i=2; i<=n; i++)
    {
        dp[1][s[i]-'0'] = 1;
        for(int j=0; j<2019; j++)
        {
            int nxt = rem[j*10+s[i]-'0'];
            dp[1][nxt] += dp[0][j] ;
        }
        ans += dp[1][0];

        for(int j=0; j<2019; j++)
            dp[0][j] = dp[1][j] , dp[1][j]=0;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 4016
#include <stdio.h>

char s[5001], t[6];
int sl, tl;
int k, i, iM, j;
char c[6];
inline bool strin() {
  i = 0;
  iM = sl - tl;
  while (i <= iM) {
    for (j = 0; j < tl; ++j) {
      if (s[i + j] != t[j]) goto continue_while;
    }
    return true;
  continue_while:
    ++i;
  }
  return false;
}
void solve() {
  if (!strin()) return;
  if (k == 0) {
    printf("%s\n", t);
    k = -1;
    return;
  }
  --k;
  ++tl;
  for (c[tl] = 'a'; c[tl] <= 'z'; ++c[tl]) {
    t[tl - 1] = c[tl];
    solve();
    if (k < 0) return;
  }
  --tl;
  t[tl] = 0;
}
int main() {
  scanf("%s", s);
  sl = 5000;
  while (sl - i > 1) {
    j = (sl + i) >> 1;
    (s[j] ? i : sl) = j;
  }
  scanf("%d", &k);
  solve();
}


Measured memory_bytes: 1648
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long k = sc.nextLong();
		long d = sc.nextLong();
		long min1 = x % d;
		if(min1 < 0)
			min1 += d;
		long min2 = min1 - d;
		long ans = Long.MAX_VALUE / 2;
		long sa1 = Math.abs(x - min1) / d % 2;
		if(sa1 < 0)
			sa1 += 2;
		long sa2 = Math.abs(x - min2) / d % 2;
		if(sa2 < 0)
			sa2 += 2;
		if(Math.abs(x - min1) / d <= k && sa1 == k % 2) {
			ans = Math.abs(min1);
		}
		if(Math.abs(x - min2) / d <= k && sa2 == k % 2) {
			ans = Math.abs(min2);
		}
		long ans2 = 0;
		if(x >= 0) {
			ans2 = Math.abs(x - k * d);
		}
		else {
			ans2 = Math.abs(x + k * d);
		}

		ans = Math.min(ans, ans2);


		sc.close();
		System.out.println(ans);

	}
}



Measured memory_bytes: 35888
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;

int ct[200010];
vi ind[200010];
int upd[200010];
int32_t main(){
	ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vi a;
    memset(ct,0,sizeof(ct));
    memset(upd,0,sizeof(upd));
    a.PB(-1);
    REP(i,1,n+1){
        int A;
        cin>>A;
        if(A!=a[a.size()-1]){
            a.PB(A);
        }
    }
    int sz=a.size();
    vi dp;
    dp.clear();
    dp.resize(sz+1);
    dp[0]=1;
    int ans=1;
    for(int i=1;i<=sz;i++){
        dp[i]=dp[i-1];
        // if(ct[a[i]]){
        //     for(int j=0;j<ind[a[i]].size();j++){
        //         dp[i]=(dp[i]+(dp[ind[a[i]][j]-1]))%mod;
        //     }
        // }
        dp[i]=(dp[i]+upd[a[i]])%mod;
        upd[a[i]]=(upd[a[i]]+dp[i-1])%mod;
        ct[a[i]]++;
        ind[a[i]].PB(i);
    }
    cout<<dp[sz]<<"\n";


	return 0;
}

Measured memory_bytes: 17392
import sys
sys.setrecursionlimit(10 **5)

# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")

readline = sys.stdin.readline

# did it after reading editorial
# nice one
def proc():
    _ = int(readline().rstrip())
    a = list(map(int, readline().rstrip().split()))

    mx = max(a) +1
    cnt = [0] * mx
    for i in a:
        if cnt[i]!=0:
            if cnt[i] == 2:
                continue
        
        for j in range(i, mx, i):
            cnt[j]+=1
    
    return sum(cnt[i] for i in a if cnt[i]==1)

#for _ in range(int(readline().rstrip())):
print(proc())



Measured memory_bytes: 32076
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;

int main()
{
  int n, q;
  cin >> n;
  vector<int> A_list(n);
  for (int i = 0; i < n; ++i)
  {
    cin >> A_list.at(i);
  }
  cin >> q;
  vector<int> can_make(0);
  int cnt = 1;
  for (int i = 0; i < n; ++i)
  {
    cnt *= 2;
  }
  for (int i = 0; i < cnt; ++i)
  {
    int can = 0;
    bitset<20> bs_i(i);
    for (int j = 0; j < n; ++j)
    {
      if (bs_i[j] == 1)
      {
        can += A_list.at(j);
      }
    }
    can_make.push_back(can);
  }
  sort(can_make.begin(), can_make.end());
  int m;
  for (int i = 0; i < q; ++i)
  {
    cin >> m;
    if (*lower_bound(can_make.begin(), can_make.end(), m) == m)
    {
      cout << "yes" << endl;
    }
    else
    {
      cout << "no" << endl;
    }
  }
}



Measured memory_bytes: 6856
#include<bits/stdc++.h>
#define ll long long
const int maxn=1e6+6;
using namespace std;

int main()
{

    char a[20];
    scanf("%s",a);
    int l=strlen(a);
    if(l>=4&&a[0]=='Y'&&a[1]=='A'&&a[2]=='K'&&a[3]=='I')
        printf("Yes\n");
    else
        printf("No\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
 
int main() {
    long int N,S;
    cin >> N >> S;
  
    int cnt =0;
    long int value = 1;
    while(1){

        if(N >= value){
            cnt++;
            value = value * S;
        }else{
            break;
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
#define MOD 1000000007
int main(){
    ll n;
    cin >> n;
    string s;
    map<char,ll> alpha;
    ll i,j,k;
    for(i=0;i<26;i++){
        alpha[(char)('a'+i)]=100;
    }
    ll cnt;
    for(i=0;i<n;i++){
        cin >> s;
        for(j=0;j<26;j++){
            cnt=0;
            for(k=0;k<s.size();k++){
                if(s[k]==(char)('a'+j))cnt++;
            }
             alpha[(char)('a'+j)]=min(alpha[(char)('a'+j)],cnt);
        }
    }
    for(i=0;i<26;i++){
        for(j=0;j<alpha[(char)('a'+i)];j++){
            cout <<(char)('a'+i);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 
 using namespace std;
 
 bool is_prime(int x)
 {
   if(x==2) return true;
   else
   {
     for(int i=2;i<=sqrt(x);i++)
     {
        if(x%i==0) return false;        
     }    
     return true;
   }     
 }

 int main()
 {
   int n;
   int arr[10000+5];
   int count=1;
   int num=3;
   arr[0]=2;
   while(count<=10000)
   {
     if(is_prime(num)) 
     {
       arr[count++]=num;                  
     }                  
     num+=2;   
   }
   //for(int i=0;i<100;i++) cout<<arr[i]<<endl;
   while(cin>>n&&n)
   {
     int sum=0;
     for(int i=0;i<n;i++) sum+=arr[i];
     cout<<sum<<endl;                  
   }
   //while(1);
   return 0;
 }

 

Measured memory_bytes: 3116
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var d = cin.nextInt();

            var dd = new string[] { "Christmas Eve Eve Eve", "Christmas Eve Eve", "Christmas Eve", "Christmas" };
            
            Console.WriteLine(dd[d-22]);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11220
#include <iostream>

using namespace std;
typedef long long ll;

constexpr ll MOD = 998244353;

ll calc_pow(ll x, ll pow) {
    if (pow == 0) return 1;
    ll a = calc_pow(x, pow / 2);
    a = a * a % MOD;
    if (pow % 2 == 1) a *= x;
    return a % MOD;
}

ll calc_div(ll a, ll b) {
    return (a % MOD) * calc_pow(b, MOD - 2) % MOD;
}

int main() {
    int n;
    cin >> n;
    ll ret = calc_pow(3, n), comb = 1;
    for (int i = n; i > n / 2; i--) {
        if (i < n)comb = calc_div(comb * (i + 1), n - i);
        ll now = 2 * comb % MOD;
        now *= calc_pow(2, n - i), now %= MOD;
        ret += MOD - now, ret %= MOD;
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
    
n,x=MI()
a=LI()
a.sort()
y=x
ans,s=0,0
for i in range(n):
    s+=a[i]
    if s>x:
        break
    else:
        if i<n-1:
            ans+=1
        elif x-s==0:
            ans+=1
            
print(ans)

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

int main() {
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200){
        cout << s << endl;
    } else {
        cout << "red" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <complex>
using namespace std;

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

#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T> void preview(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}

const int INF = 100000000;
const double PI = acos(-1.0), EPS = 1e-10;

double distance(double xa, double ya, double xb, double yb) {
	return sqrt((xb - xa) * (xb - xa) + (yb - ya) * (yb - ya));
}

bool EQ(double x, double y) {
	return fabs(x - y) <= EPS;
}

int main() {
	int N; cin >> N;
	rep(n,N) {
		double xa, ya, ra, xb, yb, rb;
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		double dist = distance(xa, ya, xb, yb);
		if(dist + rb < ra) {
			cout << 2 << endl;
			continue;
		}
		if(dist + ra < rb) {
			cout << -2 << endl;
			continue;
		}
		if(dist > ra + rb) {
			cout << 0 << endl;
			continue;
		}
		// if(EQ(dist, ra + rb)) {
			cout << 1 << endl;
			continue;
		// } 

	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
int main(){
  int x,y,z,w;
  w=0;
  cin >> x >> y;
  for(int i=0;i<=x;i++){
    z=x-i;
    if(i*2+z*4==y){
      w=1;
    }
  }
  if(w==1){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

int main(){
    int m, maxi, mini;
    int p[10005];
    while(cin >> m >> mini >> maxi, m||mini||maxi){
        mini--; maxi--;
        rep(i,m) cin >> p[i];

        int n = 0, g = 0;
        for(int i = maxi; i >= mini; i--){
            if(p[i] - p[i + 1] > g){
                g = p[i] - p[i + 1];
                n = i + 1;
            }
        }
        cout << n << endl; 
    }
}

Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[][] num = new int[n + 1][n + 1];
			for (int i = 0; i < n + 1; i++) {
				for (int j = 0; j < n + 1; j++) {
					if (i != n && j != n) {
						int a = scanner.nextInt();
						num[i][j] = a;
						num[i][n] += a;
						num[n][j] += a;
					} else if (i == n && j != n) {
						num[n][n] += num[n][j];
					}
					System.out.print(String.format("%5d", num[i][j]));
				}
				System.out.println();
			}
		}

	}
}

Measured memory_bytes: 23672
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#define int long long
#define double long double
#define fre(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
using namespace std;

inline int read(){
	int sum=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){sum=sum*10+ch-'0';ch=getchar();}
	return f*sum;
}

const int N=100005;
struct node{int x,y;}a[N];
int H,W,n;
map < pair<int,int> ,int> mp;
int f[101];

inline int get(int x,int y){
	return mp.count(make_pair(x,y));
}

inline int getsum(int x,int y){
	int ret=0;
	if(x+2>H||y+2>W) return 0;
	for(int i=x;i<=x+2;i++)
		for(int j=y;j<=y+2;j++) ret+=get(i,j);
	return ret;
}

signed main(){
	H=read();W=read();n=read();
	for(int i=1;i<=n;i++) a[i].x=read(),a[i].y=read();
	for(int i=1;i<=n;i++) mp[make_pair(a[i].x,a[i].y)]=1;
	for(int i=1;i<=n;i++){
		int x=a[i].x,y=a[i].y;
		for(int i=max((int)1,x-2);i<=x;i++){
			for(int j=max((int)1,y-2);j<=y;j++){
				int ret=getsum(i,j);
				if(ret>0) f[ret]++;
			}
		}
	}
	for(int i=1;i<=9;i++) f[i]/=i;
	int ret=0;
	for(int i=1;i<=9;i++) ret+=f[i];
	f[0]=(H-2)*(W-2)-ret;
	for(int i=0;i<=9;i++) printf("%lld\n",f[i]);
	return 0;
}


Measured memory_bytes: 8064
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

ll ans[300005];

int main()
{ios_base::sync_with_stdio(false);
int n,a,b;
cin>>n>>a>>b;

if(a>n||b>n)
{
	ol("-1");
	return 0;
}

int l=(n+a-1)/a,r=n-a+1;

if(!(b>=l&&b<=r))
{
	ol("-1");
	return 0;
}
int id=0;
rep(i,0,a-1)
{
	ans[id++]=n-a+i;
}
int dec=1;

int ptr=n-a;

while(1)
{

	if(ptr<=0)break;
	int sz=min(ptr,a);
	int rem=(ptr-1)/a;
	int kk=min(sz,b-dec-rem);
	dec+=kk;
	if(kk==sz)
	{
		rep(i,0,sz-1)
		ans[id++]=ptr-1-i;
	}
	else if(kk==1)
	{
		rep(i,0,sz-1)
		ans[id++]=ptr-sz+i;
	}
	else
	{
		//o2("HI",kk);on;
		kk--;
		rep(i,0,kk-1)
		ans[id++]=ptr-1-i;
		rep(i,0,sz-1-kk)
		ans[id++]=ptr-sz+i;
	}
	ptr-=a;
}

rep(i,0,n-1)
{
	ol(ans[i]+1);os;
}
return 0;
}



Measured memory_bytes: 4608
import java.util.*;

class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int X = sc.nextInt();
    int Y = sc.nextInt();
    
    int[] ans = new int[N-1];
    int min = 10000;
    for(int i =1;i<N;i++){
      for (int j = i+1;j<N+1;j++){
        min = Math.min((Math.abs(j-i)),(Math.abs(X-i)+1+Math.abs(j-Y)));
       // min = Math.min(min,Math.abs(Y-i)+1+Math.abs(j-X));
        ans[min-1]++;
      }
    }
    for(int k:ans){
      System.out.println(k);
    }
    
    
  }    
}



Measured memory_bytes: 22740
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;

const ll MOD=1000000007;

ll gcd1(ll a,ll b){
  if(a==0 && b==0)return 0;
  ll n;
  while(a%b!=0){
    n=a%b;
    a=b;
    b=n;
  }
  return b;
}

ll solveLinear1(ll n,ll m,ll c){
  if(n==0 && m==0)return 0;
  ll a[100],b[100];
  a[0]=n;b[0]=m;
  int i=1;
  while(b[i-1]!=0){
    a[i]=b[i-1];
    b[i]=a[i-1]%b[i-1];
    i++;
  }
  n=i;
  if(c%a[n-1]!=0){
    return 0;
  }
  ll x=c/a[n-1],y=0;
  for(i=1;i<n;i++){
    ll cnt=x;
    x=y;
    y=cnt-(a[n-i-1]/b[n-i-1])*y;
  }
  return x;
}

ll modRev(ll a,ll p){
  ll n=solveLinear1(a,p,1);
  n=n%p;
  if(n<0)return n+p;
  return n;
}

int main(){
  int i,j,k,cnt=0;
  int h,w;
  cin>>h>>w;
  int c[10][10],a[h][w];
  for(i=0;i<10;i++)for(j=0;j<10;j++)cin>>c[i][j];
  for(i=0;i<h;i++)for(j=0;j<w;j++)cin>>a[i][j];
  int x[10],y[10];
  for(i=0;i<10;i++)x[i]=MOD;
  x[1]=0;
  for(k=0;k<20;k++){
    for(i=0;i<10;i++){
      for(j=0;j<10;j++){
        if(c[i][j]+x[j]<x[i])x[i]=c[i][j]+x[j];
      }
    }
  }
  int sum=0;
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      if(a[i][j]!=-1){
        sum+=x[a[i][j]];
      }
    }
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 384
N, T = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

dp = [[-1] * (T + 1) for i in range(N + 1)]
dp[0][0] = 0
X.sort()

for i in range(N):
    for j in range(T + 1):
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
    
        if dp[i][j] >= 0 and j < T:
            dp[i + 1][min(T, j + X[i][0])] = max(dp[i + 1][min(T, j + X[i][0])],
                                                 dp[i][j] + X[i][1])

print(max(dp[-1]))


Measured memory_bytes: 146040
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
int n,m;
char map[105][105];
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
void show()
{
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cout<<map[i][j];
		}
		cout<<endl;
	}
	cout<<endl<<endl;
}
void bfs(int x,int y,char now)
{
	queue<int>qx;
	queue<int>qy;
	qx.push(x);
	qy.push(y);

	int xx,yy;
	while(!qx.empty())
	{
		x=qx.front();
		y=qy.front();
		map[x][y]='.';
		qx.pop();
		qy.pop();
		for(int i=0;i<4;i++)
		{
			xx=x+dx[i];
			yy=y+dy[i];
			if(map[xx][yy]==now)
			{
				qx.push(xx);
				qy.push(yy);
				map[xx][yy]='.';
			}
		}
	//	show();
	}
}
int main()
{
	memset(map,'.',sizeof(map));
	while(cin>>n>>m)
	{
		if(n==0&&m==0)return 0;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
			{
				cin>>map[i][j];
			}
		}
		int cnt=0;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
			{
				if(map[i][j]!='.')
				{
					bfs(i,j,map[i][j]);
					cnt++;
				}
			}
		}
		cout<<cnt<<endl;
	}
}


Measured memory_bytes: 3088
class Combination():
    def __init__(self, n, mod):
        self.n = n
        self.mod = mod
        self.fact = self.make_fact(n)
        self.fact_inv = self.make_fact_inv(n)
    def make_fact(self, n):#0~nの階乗を求める
        res = [1]*(n+1)
        for i in range(1, n+1):
            res[i] = res[i-1]*i%self.mod
        return res
    def make_fact_inv(self, n):#0~nの階乗のmodに関する逆元を求める
        fact_inv = [1]*(n+1)
        fact_inv[n] = pow(self.fact[n], self.mod-2, self.mod)#フェルマーの小定理
        for i in range(n, 0, -1):
            fact_inv[i-1] = fact_inv[i]*i%self.mod
        return fact_inv
    def comb(self, m, k):
        return self.fact[m]*self.fact_inv[k]*self.fact_inv[m-k]%self.mod
mod = 998244353
n, m, k = map(int, input().split())
comb = Combination(n, mod)
ans = 0
for i in range(k+1):
    ans+=pow(m-1, n-1-i, mod)*comb.comb(n-1, i)
    ans%=mod
ans = ans*m%mod
print(ans)

Measured memory_bytes: 74456
#include <cstdio>
#include <cctype>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
    _typer init = 0;
    char ch = getchar(), k = 0;
    for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
    for ( ; isdigit(ch); ch = getchar())
        init = (init << 3) + (init << 1) + (ch ^ 48);
    return k ? -init : init;
}
const ll N = 100005, INF = 1e9;

int n, A[N];

int main() {
    n = read<int>();
    int lst = read<int>(), x, ans = 0, now = 0;
    rep (i, 2, n) {
        x = read<int>();
        if (x > lst) now = 0;
        else ans = max(ans, ++now);
        lst = x;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int x,a,b;
	cin >> x >> a >> b;

	x = 100*x + 10*a +b;
	if (x%4==0) {
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256