akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>
using namespace std;
#define INF 1<<20

struct edge{
	int to;
	int cost;
	edge() {};
	edge(int a, int b) {
		to = a;
		cost = b;
	}
};

struct Node {
	int pos;
	int cost;
	Node() {};
	Node(int a, int b) {
		pos = a;
		cost = b;
	}
	bool operator <(const Node& rhs) const {
		return cost > rhs.cost;
	}
};

void dijkistra(int st, int TO,int V,vector<vector<edge> > graph) {
	priority_queue<Node> q;
	vector<int> d(V);
	for (int i = 0;i < V;i++) {
		d[i] = INF;
	}
	d[st] = 0;
	q.push(Node(st, 0));
	while (!q.empty()) {
		Node s = q.top(); q.pop();
		int pos = s.pos;
		for (int i = 0;i < graph[pos].size();i++) {
			int to = graph[pos][i].to;
			int cost = graph[pos][i].cost;
			if (d[pos] + cost < d[to]) {
				d[to] = d[pos] + cost;
				q.push(Node(to, d[to]));
			}

		}
	}
	cout << d[TO] << endl;
}
int partition(int A[],int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = p;j < r;j++) {
		if (x >= A[j]) {
			i = i + 1;
			swap(A[i], A[j]);
		}
	}
		swap(A[i + 1], A[r]);
		return i + 1;
}
void quicksort(int A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quicksort(A, p, q-1);
		quicksort(A, q + 1, r);
	}
}

int getNumberOfCoin(int C[],int n,int m) {
	int T[50000];
	for (int j = 0;j <= n;j++) {
		T[j] = INF;
	}
	T[0] = 0;
	for (int i = 0;i < m;i++) {
		for (int j = 0;j <= n;j++) {
			if (j - C[i] >=0  ) {
				T[j] = min(T[j], T[j - C[i]] + 1);
			}
		}
	}
	return T[n];
}
int knapsack(int w, int n,int* v,int* ww) {
	int W[101][10001];
		for (int j = 0;j <= w;j++) {
			W[0][j] = 0;
		}
	for (int i = 0;i < n;i++) {
		for (int k = 0;k < n;k++){
			for (int j = 0;j <= w;j++) {
				if (j - ww[k] < 0) {
					W[i + 1][j] = W[i][j];
				}
				if (j - ww[i] >= 0) {
					W[i + 1][j] = max(W[i][j], W[i][j - ww[k]] + v[k]);

				}
			}
		}
	}
	return W[n][w];
}
int fib(int n) {
	vector<int> v(n+1);
	v[0] = 1;
	v[1] = 1;
	for (int i = 2;i < n+1;i++) {
		v[i] = v[i - 2] + v[i - 1];
	}
	return v[n];
}
int isPrime(int x) {
	if (x <= 1) return false;
	if (x>2 && x % 2 == 0) return false;
	for (int i = 2;i <= sqrt(x);i++) {
		if (x%i == 0) {
			return false;
		}
	}
	if (x == 2) return true;
	return true;
}
int main() {
	int a[10];
	int n;
	cin >> n;
	for (int i = 0;i < n;i++) {
		bool flag = false;
		for (int j = 0;j < 10;j++) cin >> a[j];
		for (int j = 0;j < (1 << 10);j++) {
			int max1 = 0;
			int max2 = 0;
			for (int k = 0;k < 10;k++) {
				if (j >> k & 1) {
					if (a[k] > max1) max1 = a[k];
					else break;
				}
				else {
					if (a[k] > max2) max2 = a[k];
					else break;
				}
				if (k == 9) flag = true;
			}
			
		}
		if (flag) cout << "YES" << endl;
		else cout << "NO" << endl;
	}


	}

Measured memory_bytes: 1160
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	long long a[100002],i,j,n,k;
	while(scanf("%lld",&n)!=EOF)
	{
		for(i=0;i<n;i++)
		scanf("%lld",&a[i]);
		
		sort(a,a+n);
		k=0;
		for(i=0;i<n-1;i++)
		{
			if(i>0)
			a[i]+=a[i-1];
			
			if(2*a[i]<a[i+1])
			k=i+1;
		}
		printf("%lld\n",n-k);
	}
	return 0;
 } 

Measured memory_bytes: 896
use proconio::input;

fn main() {
    input! {
        n: u64,
        a: [u64; n],
    }

    let mut tall = 0;
    let mut sum = 0;

    for ai in a {
        if ai > tall {
            tall = ai;
        } else {
            sum += tall - ai;
        }
    }

    println!("{}", sum)
}


Measured memory_bytes: 5560
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 23333
int n,a[SZ]; vector<int> adj[SZ];
bool vv[SZ];
vector<int> mg(vector<int> a,vector<int> b)
{
	int ap=0,bp=0; vector<int> v;
	while(ap<a.size()&&bp<b.size())
	{
		if(a[ap]>b[bp]) v.pb(a[ap++]);
		else v.pb(b[bp++]);
	}
	while(ap<a.size()) v.pb(a[ap++]);
	while(bp<b.size()) v.pb(b[bp++]);
	return v;
}
vector<int> vs[SZ];
void dfs(int x)
{
	vv[x]=1; vector<int> w;
	for(auto b:adj[x]) if(!vv[b])
		dfs(b), w=mg(w,vs[b]);
	w.insert(w.begin(),a[x]);vs[x]=w;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",a+i);
	sort(a+1,a+1+n);
	for(int i=n;i>=1;--i)
		for(int j=1;j<i;++j)
			if(__gcd(a[i],a[j])>1)
				adj[i].pb(j),adj[j].pb(i);
	for(int i=1;i<=n;++i) adj[0].pb(i);
	for(int i=0;i<=n;++i)
		sort(adj[i].begin(),adj[i].end());
	dfs(0);
	for(int i=1;i<=n;++i)
		printf("%d ",vs[0][i]);
}


Measured memory_bytes: 25472
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    
    ll n,x,t,p=0;
    cin>>n>>x>>t;
    if(n%x!=0)
    {
        p=n/x+1;
    }
    else
        p=n/x;
    cout<<t*p<<endl;
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N = 200001;
pair <int, int> t[4 * N];
int a[N];
int n, k;
void build(int v, int vl, int vr) {
    if (vl == vr) {
        t[v] = {a[vl], a[vl]};
        return;
    }
    int vm = (vl + vr) / 2;
    build(2 * v + 1, vl, vm);
    build(2 * v + 2, vm + 1, vr);
    t[v].first = min(t[v * 2 + 1].first, t[2 * v + 2].first);
    t[v].second = max(t[2 * v + 1].second, t[2 * v + 2].second);
}
const int inf = 1e9 + 7;
pair <int, int> get(int v, int vl, int vr, int l, int r) {
    if (vl > r || vr < l) return {inf, -inf};
    if (vl >= l && vr <= r) return t[v];
    int vm = (vl + vr) / 2;
    auto p1 = get(2 * v + 1, vl, vm, l, r);
    auto p2 = get(2 * v + 2, vm + 1, vr, l, r);
    return {min(p1.first, p2.first), max(p1.second, p2.second)};
}
int dp[N];
signed main () {
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    build(0, 0, n - 1);
    int ans = n - k + 1, f = 0;
    for (int i = 0; i < n; i++) {
        if (!i) f = 1;
        else {
            if (a[i] > a[i - 1]) f++;
            else {
                ans -= max(0ll, f - k + 1);
                f = 1;
            }
        }
        dp[i] = f;
    }
    ans -= max(0ll, f - k + 1);
    for (int i = 0; i < n - k; i++) {
        pair <int, int> p = get(0, 0, n - 1, i, i + k);
        if (p.first == a[i] && p.second == a[i + k] && dp[i + k] - dp[i] != k) ans--;
    }
    for (int i = 0; i <= n - k; i++) {
        if (dp[i + k - 1] >= k) {
            ans++;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 12544
n,m = map(int, input().split())

list_k = [list(map(int, input().split())) for i in range(m)] 
list_p = list(map(int, input().split()))

nn = 1
for i in range(n):
    nn *= 2

x = 0
for i in range(nn): #各スイッチ全状態数でループ
    y = 1
    for im in range(m): #電球数
        rslt = 1 + list_p[im] #偶奇をずらす
        tmp = i
        for iii in range(n): #その状態に対して全スイッチを判定
            if (tmp&1 == 1): #そのスイッチがonなら
                for ik in range(1,list_k[im][0]+1): #リスト長さ
                    if ((list_k[im][ik]-1) == iii): #一致したらカウント
                        rslt += 1
            tmp >>= 1
        y *= (rslt%2) #全部つくときだけ
    x += y

print(x)



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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b;
	cin >> a >> b;
	int ans = max(a + b, max(a * b, a - b));
	cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#ifndef LOCAL
#define endl '\n'
#endif

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
*/

const int mod = 1e9 + 7;

int pwr(int a,int b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = (ans * 1LL * a) % mod;
		a = (a * 1LL * a) % mod;
		b >>= 1;
	}
	return ans;
}

int ncr(int n,int k) { // modulo 2
	if(n < k) return 0;
	for(int i = 0; i < 23; i++) {
		int b1 = ((n >> i) & 1);
		int b2 = ((k >> i) & 1);
		if(!b1 && b2) return 0;
	}
	return 1;
}

void solve() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 0; i < n; i++) {
		s[i]--;
		int r1 = i, r2 = n - 1 - r1;
		if(s[i] == '1')
			ans ^= ncr(r1 + r2, r1);
	}
	if(ans) {
		cout << 1;
		return;
	}
	for(int i = 0; i < n; i++) {
		if(s[i] == '1') {
			cout << 0;
			return;
		}
		if(s[i] == '2') s[i] = '1';
	}
	ans = 0;
	for(int i = 0; i < n; i++) {
		int r1 = i, r2 = n - 1 - r1;
		if(s[i] == '1')
			ans ^= ncr(r1 + r2, r1);
	}
	if(ans) {
		cout << 2;
	}
	else {
		cout << 0;
	}
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	// cin >> t;
	t = 1;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 1948
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[][] x = new int[n][];
        int[][] y = new int[n][];
        for (int i=0;i<n;i++){
            a[i]=sc.nextInt();
            x[i] = new int[a[i]];
            y[i] = new int[a[i]];
            for (int j=0;j<a[i];j++){
                x[i][j] = sc.nextInt();
                y[i][j] = sc.nextInt();
            }
        }
        int max = 0;
        for (int i=0;i<Math.pow(2,n);i++){
            String s = Integer.toBinaryString(i);
            while (s.length()<n){
                s = "0"+s;
            }
            int[] tf = new int[n];
            int count = 0;
            for (int j=0;j<n;j++){
                if (s.charAt(j)=='0')tf[j]=0;
                if (s.charAt(j)=='1'){
                    tf[j]=1;
                    count++;
                }
            }
            boolean b = true;
            for (int j=0;j<n&&b;j++){
                if (tf[j]==1){
                    for (int k=0;k<a[j]&&b;k++){
                        if (y[j][k]!=tf[x[j][k]-1])b=false;
                    }
                }
            }
            if (b){
                max = Math.max(max,count);
            }

        }
        System.out.println(max);
    }
}

Measured memory_bytes: 34008
import bisect
from sys import stdin

def get_result(data):
    N = data[0][0]
    A = sorted(data[1])
    B = sorted(data[2])
    C = sorted(data[3])
    ans = 0
    for mid_val in B:
      num_a = bisect.bisect_left(A, mid_val)
      num_c = N - bisect.bisect_right(C, mid_val)
      ans += num_a * num_c
    return ans


if __name__ == '__main__':
    raw_data = [val.rstrip() for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)


Measured memory_bytes: 25232
#include<stdio.h>

template <typename T>
T gcd(T a,T b) {
   if(b == 0) return a;
  return gcd(b,a%b); 
}
template <typename T>
T lcm(T a,T b) {
    return a/gcd(a,b)*b;
}


int main() {
    int a,b;
    while(scanf("%d %d",&a,&b)!=EOF) {
        printf("%d %d\n",gcd(a,b),lcm(a,b));
    }

    return 0;

}

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

using namespace std;
int main(){
  int N,M,x,a;
  vector<int> X;
  vector<int> A;

  cin >> N;
  for(int i=0;i<N;i++){
    cin >> x;
    X.push_back(x);
  }

  cin >> M;
  for(int i=0;i<M;i++){
    cin >> a;
    A.push_back(a);
  }


  for(int i=0;i<M;i++){
    bool bo=true;
    int sub=A[i]-1;

    for(int j=0;j<N;j++){
      if((X[sub]+1)==X[j]){
	bo=false;
      }
    }
    if((X[sub])==2019){
      bo=false;
    }

    else if(bo==true){
      X[sub]+=1;
    }

  }


  for(int i=0;i<N;i++){
    cout << X[i] << "\n";
  }
}


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

using namespace std;

const int MAXN = 2E5;
const int LOGN = 18;
int p[MAXN];
int minTable1[LOGN + 1][MAXN];
int minTable2[LOGN + 1][MAXN];
vector<pair<int, int>> ans;
int pos[MAXN + 1];
priority_queue<tuple<int, int, int, int>, vector<tuple<int, int, int, int>>, greater<tuple<int, int, int, int>>> pq;

pair<int, int> query(int l, int r)
{
    int len = r - l + 1;
    int k = 31 - __builtin_clz(len);
    int mid = l + (len - (1 << k));
    return make_pair(min(minTable1[k][l], minTable1[k][mid]), min(minTable2[k][l], minTable2[k][mid]));
}

pair<int, int> get(int l, int r)
{
    int small = -1;
    int nextSmall = -1;
    int pos1 = -1;
    if (l % 2 == 0)
    {
        small = query(l, r).first;
        pos1 = pos[small];
        nextSmall = query(pos1 + 1, r).second;
    }
    else
    {
        small = query(l, r).second;
        pos1 = pos[small];
        nextSmall = query(pos1 + 1, r).first;
    }
    return make_pair(small, nextSmall);
}

void push(int l, int r)
{
    if (l > r)
        return;
    pair<int, int> pr = get(l, r);
    pq.push(make_tuple(pr.first, pr.second, l, r));
}

int main()
{
    int n;
    cin >> n;
    ans.reserve(n / 2);
    fill(minTable1[0], minTable1[0] + n, n + 1);
    fill(minTable2[0], minTable2[0] + n, n + 1);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
        pos[p[i]] = i;
        if (i % 2 == 0)
            minTable1[0][i] = p[i];
        else
            minTable2[0][i] = p[i];
    }
    for (int i = 1; i <= LOGN; i++)
    {
        for (int j = 0; j < n; j++)
        {
            int inc = (1 << (i - 1));
            minTable1[i][j] = min(minTable1[i - 1][j], minTable1[i - 1][min(n - 1, j + inc)]);
            minTable2[i][j] = min(minTable2[i - 1][j], minTable2[i - 1][min(n - 1, j + inc)]);
        }
    }
    pair<int, int> first = get(0, n - 1);
    pq.push(make_tuple(first.first, first.second, 0, n - 1));
    while (!pq.empty())
    {
        tuple<int, int, int, int> t = pq.top();
        pq.pop();
        int s1 = get<0>(t);
        int s2 = get<1>(t);
        int l = get<2>(t);
        int r = get<3>(t);
        ans.push_back(make_pair(s1, s2));
        push(l, pos[s1] - 1);
        push(pos[s1] + 1, pos[s2] - 1);
        push(pos[s2] + 1, r);
    }
    for (pair<int, int> pr : ans)
    {
        cout << pr.first << " " << pr.second << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 34292
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    int x, n; cin >> x >> n;
    set<int> a;
    rep(i, n) {
        int x; cin >> x;
        a.insert(x);
    }
    rep(i, 1000) {
        rep(j, 2) {
            int num;
            if (j==0) num = x-i;
            else num = x+i;
            if (!a.count(num)) {
                cout << num << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3652
n, p = [int(i) for i in input().split()]
a = [[] for _ in range(p+1)]

for _ in range(n):
    l = [int(i) for i in input().split()]
    l.append(sum(l))
    [a[i].append(j) for i, j in enumerate(l)]
    print(*l)

for h,i in enumerate(a):
    if h == len(a) - 1:
        print(sum(i))
    else:
        print(sum(i),end=' ')

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

int main() {
  string s;
  cin >> s;
  int cnt=0;
  for(int i=0; i<s.length(); i++) {
    cnt+=s[i]-'0';
  }
  if(cnt<=1) {
    cout << 10 << endl;
  }
  else {
    cout << cnt << endl;
  }
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
int main() {
	int N, M;
	cin >> N >> M;
	if (N >= M) {
		cout << 0 << endl;
		return 0;
	}
	vector<int> X;
	for (int i = 0; i < M; i++) {
		int x;
		cin >> x;
		X.push_back(x);
	}
	sort(X.begin(), X.end());
	vector<int> L;
	ll sum = X[M - 1] - X[0];
	for (int i = 0; i + 1 < M; i++) {
		L.push_back(X[i + 1] - X[i]);
	}
	sort(L.begin(), L.end(), greater<int>());
	for (int i = 0; i < N - 1; i++) {
		sum -= L[i];
	}
	cout << sum << endl;

}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  while(true){
  int N;
  cin >> N;
  if(N == 0) break;
  int c = 1000 - N;
  int res = 0;
  if( c/500 >= 1) {
    res += c/500;
    c = c%500;
  }
  if( c/100 >= 1) {
    res += c/100;
    c = c%100;
  }
  if( c/50 >= 1) {
    res += c/50;
    c = c%50;
  }
  if( c/10 >= 1) {
    res += c/10;
    c = c%10;
  }
  if( c/5 >= 1) {
    res += c/5;
    c = c%5;
  }
  if( c >= 0) {
    res += c;
  }
  
  cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 2976
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

s = list(input())
print(s.count('+') - s.count('-'))


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

int main() {
    ll k;
    std::cin >> k;
    
    ll a = (k+49)/50;
    
    k -= 50*(a-1);
    k = 50-k;
    std::cout << 50 << std::endl;
    for (int i = 1; i <= 50; i++) {
        if(i<=k){
            std::cout << a+k-2<< " ";
        }else{
            std::cout << 50-1+a << " ";
        }
    }
    std::cout << std::endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.*;

class Main {
    public static void main(String[] args) {
        var scanner = new Scanner(System.in);
        var n = scanner.nextInt();

        var a = new int[n+1];

        var h = new HashMap<Integer,Integer>();
        for(int i = 1; i <= n; i++) {
            a[i] = scanner.nextInt();
            var value = h.get(i - a[i]);
            h.put(i - a[i], value == null ? 1 : value + 1);
        }
        long result = 0;
        for(int i = 1; i <= n; i++) {
            var value = h.get(i + a[i]);
            if(value != null) result += value;
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 69716
using Yorukatsu046.Questions;
using Yorukatsu046.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace Yorukatsu046.Questions
{
    /// <summary>
    /// ABC076 C
    /// </summary>
    public class QuestionD : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var s = inputStream.ReadLine().Replace('?', '.');
            var t = inputStream.ReadLine();

            for (int i = s.Length - t.Length; i >= 0; i--)
            {
                var substring = s.Substring(i, t.Length);
                if (Regex.Match(t, substring).Success)
                {
                    var answer = (s.Substring(0, i) + t + s.Substring(i + t.Length)).Replace('.', 'a');
                    yield return answer;
                    yield break;
                }
            }

            yield return "UNRESTORABLE";
        }
    }
}


namespace Yorukatsu046
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionD();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu046.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu046.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 16204
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,i,j,k,p=0,l,r,d;
    cin>>n;
    long long a[60001]={0};
    for(i=1;i<=100;i++){
        for(j=1;j<=100;j++){
            for(k=1;k<=100;k++){
                p=i*i+j*j+k*k+i*j+j*k+k*i;
                a[p]++;
            }
        }
    }for(i=1;i<=n;i++){
        cout<<a[i]<<endl;
    }
    return 0;
}


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

int main(){
  int N,T,min=1001;
  cin>>N>>T;
  
  int c[N+1],t[N+1];
  
  for(int i=1; i<N+1; i++) cin>>c[i]>>t[i];
  
  for(int i=1; i<N+1; i++){
    if(t[i]<=T&&c[i]<min) min=c[i];
    }
  if(min==1001) cout<<"TLE"<<endl;
  else cout<<min<<endl;
  
  return 0;
}
      
      
  

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#define MAXN 100010
using namespace std;
int n;
int A[MAXN];
bool state=0;
int gcd(int a,int b){return !b?a:gcd(b,a%b);}
bool Judge()
{
	int odd=0,even=0;
	bool res=0,one=0;
	for(int i=0;i<n;i++)
	{
		if(A[i]&1)odd++;
		else even++,res^=1;
		if(A[i]==1)one=1;
	}
	if(one)return res;
	if(!even)return 0;
	else if(even&1)return 1;
	else
	{
		if(odd==1)
		{
			int g=0;
			for(int i=0;i<n;i++)
			{
				if(A[i]&1)A[i]--;
				g=gcd(g,A[i]);
			}
			for(int i=0;i<n;i++)A[i]/=g;
			return !Judge();
		}
		else
		{
			return 0;
		}
	}
}
int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)scanf("%d",&A[i]);
	if(Judge())puts("First");
	else puts("Second");
 	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=1e9;

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

ll s;

int main() {
	cin>>s;
	int x3=inf,y1=(s-1)/inf+1;
	int x1=1,y3=1ll*x3*y1-s;
	cout<<x1<<' '<<y1<<' '<<0<<' '<<0<<' '<<x3<<' '<<y3<<endl;
	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

def calc_difference(N, ten_thousand_number, five_thousand_number, one_thousand_number):
    return N - (ten_thousand_number + five_thousand_number + one_thousand_number)

def print_answer(ten_thousand_number, five_thousand_number, one_thousand_number):
    print(str(ten_thousand_number) + ' ' + str(five_thousand_number) + ' ' + str(one_thousand_number))

[N, Y] = [int(i) for i in input().split()]

# まずは最小枚数での構成を考える
now_amount = Y
five_thousand_number = 0
one_thousand_number = 0

ten_thousand_number = now_amount // 10000
now_amount = now_amount % 10000
five_thousand_number = now_amount // 5000
now_amount = now_amount % 5000
one_thousand_number = now_amount // 1000
now_amount = now_amount % 1000

# この時点でお札の枚数(N)が最小構成の枚数より小さかったら実現不可能
difference = calc_difference(N, ten_thousand_number, five_thousand_number, one_thousand_number)
if difference < 0:
    print('-1 -1 -1')
    sys.exit()

if difference == 0:
    print_answer(ten_thousand_number, five_thousand_number, one_thousand_number)
    sys.exit()

# 10000円札を1000円札に切り崩す
ten_thousand_cut = difference // 9
actual_ten_thousand_cut = min(ten_thousand_cut, ten_thousand_number)
ten_thousand_number -= actual_ten_thousand_cut
one_thousand_number += actual_ten_thousand_cut * 10
difference = calc_difference(N, ten_thousand_number, five_thousand_number, one_thousand_number)

if difference == 0:
    print_answer(ten_thousand_number, five_thousand_number, one_thousand_number)
    sys.exit()

# 5000円札を1000円札に切り崩す
five_thousand_cut = difference // 4
actual_five_thousand_cut = min(five_thousand_cut, five_thousand_number)
five_thousand_number -= actual_five_thousand_cut
one_thousand_number += actual_five_thousand_cut * 5
difference = calc_difference(N, ten_thousand_number, five_thousand_number, one_thousand_number)

if difference == 0:
    print_answer(ten_thousand_number, five_thousand_number, one_thousand_number)
    sys.exit()

# 10000円札を5000円札に切り崩す
ten_thousand_cut = difference // 1
actual_ten_thousand_cut = min(ten_thousand_cut, ten_thousand_number)
ten_thousand_number -= actual_ten_thousand_cut
five_thousand_number += actual_ten_thousand_cut * 2
difference = calc_difference(N, ten_thousand_number, five_thousand_number, one_thousand_number)

if difference == 0:
    print_answer(ten_thousand_number, five_thousand_number, one_thousand_number)
    sys.exit()

print('-1 -1 -1')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define r_0 return 0;
#define ll long long
#define ld  long double
#define pb push_back
#define fr first
#define se second
#define in freopen("input.txt","r",stdin);
#define out freopen("output.txt","w", stdout);
#define TIME ios_base::sync_with_stdio(0);
#define tcn cin.tie(0);
#define tct cout.tie(0);
#define sz size()
using namespace std;

const long long N = 1e6 + 7;

ll l , r , x , y , n , cnt , m , a;
string s ,s1;
long long used[N];
map<ll , ll>mp;
int main()
{
    cin >> n;
    ll arr[n + 1];
    for( int i = 1;i <= n;i ++ ){
        cin >> a ;
        mp[a] ++;
    }
    for( int i = 1;i < N;i ++ ){
        for( int j = i;j < N;j += i )
            used[j] += mp[i];
    }
    for( int i = 0;i < N;i ++ )
        if( mp[i] and used[i] == 1 )
            cnt+=mp[i];
    cout << cnt;
}


Measured memory_bytes: 73996
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	vi x(3);
	REP(i, 3)x[i] = IN();
	sort(ALL(x));
	OUT(x[0] + x[1]);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Solution
{
    static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var a = vals[0];
        var b = vals[1];
        var c = vals[2];

        var t = Math.Min(c, a + b + 1);
        var n = t + b;

        Console.WriteLine(n);
    }
}

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

int main() {
  int n;  /* n*nのマス */
  int a;  /* 白に塗られたマス */
  
  // 
  // x = n^2 - a
  //
  
  cin >> n >> a;

  if (a > pow(n,2)) { 
    cout << "Error!" << endl;
  } else {
    cout << pow(n,2) - a << endl;
  }
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int n, m;
int d[3];
int x ,y, w, h, r;
int p = 1;
int main(){
    while(scanf("%d", &n), n){
        printf("Case %d: %d\n", p++, n);
    }
    return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define se second
#define fi first
#define pb push_back
const int N=1e5 + 5;
int par[N],v[N];
int mn[N],tak[N],cu[N];
vector<pair<int, int> > q;

int findp(int u){
	if(par[u] == u) return u;
	return par[u]=findp(par[u]);
}

int main(){

//	freopen("in.txt","r",stdin);

	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=0;i < n;i++){
		scanf("%d",&v[i]);
	}
	for(int i=0;i < n;i++)
		par[i]=i, mn[i]=2e9;
	int cmp=n,e;
	for(int i=0,a,b;i < m;i++){
		scanf("%d%d",&a,&b);
		int pa=findp(a),pb=findp(b);
		if(pa != pb) par[pa]= pb, cmp--;
	}
	if(cmp == 1) return puts("0"), 0;
	e=2 * (cmp - 1);
	for(int i=0;i < n;i++){
		mn[findp(i)]=min(mn[findp(i)],v[i]);
	}
	ll ans=0;
	for(int i=0;i < n;i++){
		if(!tak[findp(i)] && v[i] == mn[findp(i)]){
			tak[findp(i)]=1;
			ans+=v[i];
			cu[i]=1;
			e--;
		}
	}
	assert(e == cmp - 2);
	for(int i=0;i < n;i++){
		if(!cu[i]) q.pb({ v[i], findp(i) });
	}
	sort(q.begin(),q.end());
	reverse(q.begin(),q.end());
	while(q.size() && e){
		int am=q.back().fi;
		q.pop_back();
		ans+=am;
		e--;
	}
	if(!e) cout << ans << endl;
	else cout << "Impossible" << endl;

	return 0;

}


Measured memory_bytes: 3320
#include <iostream>
#include <string>
#include <vector>

class A {
private:
	
	int D, T, S;
	bool Flag = false;
	
	void Input() {
		std::cin >> D >> T >> S;
	}
	
	void Check() {
		if (D <= T * S) Flag = true;
	}
	
	void Output() {
		std::cout << (Flag ? "Yes" : "No") << std::endl;
	}
	
public:
	
	A() {
		Input();
		Check();
		Output();
	}
	
};

int main() {
	
	A();
	
	return 0;
}


Measured memory_bytes: 3504
#include <stdio.h>

int main(void)
{
	int a[4],b[4];
	int count,count_2,i,j;

	while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3]) != EOF)
	{
		scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]);
		count = 0;
		count_2 = 0;
		for(i=0;i<4;i++)
		{
			for(j=0;j<4;j++)
			{
				if(a[i] == b[j])
				{
					if(i == j)
					{
						count++;
					}
					else
					{
						count_2++;
					}
				}
			}
		}
		printf("%d %d\n",count,count_2);
	}

	return 0;
}

Measured memory_bytes: 596
import java.text.DecimalFormat;
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		DecimalFormat df = new DecimalFormat("####################.####################");

		double r = scan.nextDouble();

		System.out.println(df.format(r * r * Math.PI) + " " + df.format((r+r) * Math.PI));


		scan.close();

	}
}

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

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

	int N;
	cin >> N;
	vector<vector<long long> > a(100010, vector<long long>(3, 0));
	vector<vector<long long> > dp(100010, vector<long long>(3, 0));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 3; ++j) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < 3; ++j) {
			for (int k = 0; k < 3; ++k) {
				if (j == k) continue;
				dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i][k]);
			}
		}
	}
	long long ans = 0;
	for (int j = 0; j < 3; ++j) ans = max(ans, dp[N][j]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11264
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;
int main() {
	int a, b, x;
	cin >> a >> b >> x;
	if (a <= x && x < a + b)
		cout << "YES" << "\n";
	else
		cout << "NO" << "\n";
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x,i,ans=0,l,c=0;
	cin>>n>>x;
	if(ans<=x)
	{
		c++;
	}
	for(i=0;i<n;i++)
	{
	  cin>>l;
	  ans+=l;
	  if(ans<=x)
	  {
	  	c++;
	  }	
	}
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int i,j,n,k,v,va,A[101][101]={{0}};
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&k);
    for(j=0;j<k;j++){
      scanf("%d",&va);
      A[v][va]=1;
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j!=1)printf(" ");
      printf("%d",A[i][j]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2052
#include<bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(i,n) for(ll i=0;i<n;i++)
#define repp(i,a,b) for(ll i=a;i<=b;i++)
#define reff(i,a,b) for(ll i=a;i>=b;i--)
#define ll long long int
#define pll pair<ll,ll>
#define fill(a,x) memset(a,x,sizeof(a))
#define mb make_pair
#define pb push_back
#define F first
#define S second
#define M 1000000007
#define sc(x) scanf("%d",&x)
#define scc(x1,x2) scanf("%d%d",&x1,&x2)
#define sccc(x1,x2,x3) scanf("%d%d%d",&x1,&x2,&x3)
#define pr(x) printf("%lld ",x)
#define dbg(a)         std::cerr<<#a<<"="<<(a)<<"\n"
#define dbg1(a,b)       std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define dbg2(a,b,c)     std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define dbg3(a,b,c,d)   std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
#define co cout<<"fuck"<<endl;
#define all(v) v.begin(),v.end()
const int INF = 2034567891;
const ll INF64 = 4234567890123456789ll;
long long nc3(long long v){return (v * (v - 1ll) * (v - 2ll)) / 6ll;}
long long nc2(long long v){return (v * (v - 1ll)) / 2ll;}
ll gcd(ll a, ll b) { return (b == 0 ? a : gcd(b, a % b)); }
ll lcm(ll a, ll b) { return (a * (b / gcd(a, b))); }
const int N = 10+2e6;
bool isprime(ll n) {
    if (n < 2) return 0;
    if (n == 2) return 1;
    if (n % 2 == 0) return 0;
    for (ll i = 3; i*i <= n; i++) if (n%i == 0) return 0;
    return 1;
}
double dist(pll p1, pll p2)
 {
    return (p1. F - p2.F)*(p1.F - p2.F) +
          (p1.S - p2.S)*(p1.S - p2.S);
 }
int main()
{
   ll a,b,c,x;
   cin>>a>>b>>c>>x;
   ll ans=0;
   rep(i,a+1)
   {
     rep(j,b+1)
     {
       rep(k,c+1)
       {
          if(i*500+j*100+k*50==x)
          ans++;
	   }
	 }
   }
   cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <set>
#include <unordered_set>
#include <map>
#include <cmath>
#include <deque>
#include <queue>
#include <string>
#include <cstring>
#include <stack>


using namespace std;
typedef long long ll;

#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++)
#define V vector

int n, m, k;
long long MOD = 998244353;

V<long long> choose(200020);

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

void calc() {
    long long tmp = 1;
    choose[0] = tmp;
    REP(i, 1, n) {
        tmp = tmp * (n-i) % MOD * modinv(i, MOD) % MOD;
        choose[i] = tmp;
    }
    return ;
}

void solve() {
    calc();
    int res = 0;
    long long tmp = m;
    REP(i, 0, n-k-1) tmp = (tmp*(m-1)) % MOD;
    REP(i, 0, k+1) {
        res = (res + tmp * choose[k-i] % MOD) % MOD;
        tmp = (tmp * (m-1)) % MOD;
    }
    cout << res;
    return;
}

int main() {
    cin >> n >> m >> k;
    solve();
    return 0;
}



Measured memory_bytes: 4660
#include<bits/stdc++.h>
#define int long long

using namespace std;

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

    int n, a, b;
    vector<pair<int, int>> v;
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a >> b, v.push_back(make_pair(a, b));
    sort(v.begin(), v.end());

    if (n == 1)
        return cout << "1\n", 0;
    vector<pair<int, int>> pq;
    for (int i = 0; i < n; i++)
        for (int j = i + 1; j < n; j++)
            pq.push_back(make_pair(v[j].first - v[i].first, v[j].second - v[i].second));

    int ans = 2147483647, now;
    for (int i = 0; i < pq.size(); i++)
    {
        now = 0;
        int p = pq[i].first, q = pq[i].second;
        set<int> pi;
        for (int j = 0; j < n; j++)
            if (!pi.count(j))
            {
                now++;
                pi.insert(j);
                int x = v[j].first, y = v[j].second, k = j + 1;
                while (k < n)
                {
                    if (!pi.count(k) && v[k].first - x == p && v[k].second - y == q)
                        pi.insert(k), x = v[k].first, y = v[k].second;
                    k++;
                }
            }
        ans = min(ans, now);
    }
    cout << ans << '\n';

    return 0;
}


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

using namespace std;

const int N = 2000 + 7;
int n, k, mindel[N][N], dep[N][N];
vector<int> g[N];
bool vis[N];

void dfs(int a) {
  mindel[a][0] = 1;
  vector<int> kids;
  vis[a] = 1;
  for (auto &b : g[a]) {
    if (vis[b] == 0) {
      dfs(b);
      mindel[a][0] += mindel[b][0];
      kids.push_back(b);
    }
  }
  if (kids.empty()) {
    for (int i = 1; i <= k; i++) {
      mindel[a][i] = 0;
    }
    return;
  }
  for (int len = 1; len <= k; len++) {
    int other = k - len;
    other = min(other, len - 1);
    int sum = 0, mx = (int) 1e9;
    for (auto &b : kids) {
      sum += mindel[b][other];
      mx = min(mx, mindel[b][len - 1] - mindel[b][other]);
    }
    mindel[a][len] = min(mindel[a][len - 1], sum + mx);
  }
}

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

  cin >> n >> k;
  k++;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dfs(1);
  int ans = (int) 1e9;
  for (int i = 1; i <= n; i++) {
    ans = min(ans, mindel[i][k] + n - mindel[i][0]);
  }
  cout << ans << "\n";
}


Measured memory_bytes: 17664
import Data.List.Split
main=mapM_(print.solve).chunksOf 2.map(map read.words).lines=<<getContents 
solve::[[Int]]->Int
solve[[n],as]=f 0 where
  f k=if e==k then k else f e where
    e=sum$map(\a->(a+k-n)`div`(n+1)+1)as

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << (a) << endl
#define all(v) v.begin(), v.end()
#define rsort(v) sort(v.rbegin(), v.rend())


int main() {
  ll H, W; int N;
  cin >> H >> W >> N;
  int a, b;
  ll ans[10], sum = 0;
  fill(ans, ans+10, 0);
  map<pii, int> m;
  rep(i, N) {
    cin >> a >> b;
    a--; b--;
    reps(j,-1,2) {
      if (a+j<=0 || a+j>=H-1)
        continue;
      reps(k,-1,2) {
        if (b+k<=0 || b+k>=W-1)
          continue;
        m[make_pair(a+j, b+k)]++;
      }
    }
  }
  for (auto &e: m) {
    ans[e.second]++;
    sum++;
  }
  ans[0] = (H-2)*(W-2) - sum;
  rep(i,10) {
    print(ans[i]);
  }
  return 0;
}

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

int main(){

    // int X = 2;
    int X = 0;
    cin >> X;

    int sum = 0;
    for(int i = 1; i <= X; i++){
        sum += i;
        if(sum >= X){
            int dis = sum - X;
            if(dis < X){
                cout << i << endl;
                break;
            }
        }
    }
}


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

#define Rep(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) Rep(i, 0, n)

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

int main(){
	int sum = 0;
	rep(i,10) sum+=read<int>();
	cout << sum << endl;
}

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

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

	char& Q = S.back();
	if (Q == '2' || Q == '4' || Q == '5' || Q == '7' || Q == '9') {
		cout << "hon" << endl;
	}
	else if (Q == '0' || Q == '1' || Q == '6' || Q == '8') {
		cout << "pon" << endl;
	}
	else cout << "bon" << endl;
}

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

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;

    int count = 0;
    for (int i = 0; i < 3; ++i) {
        if (s[i] == t[i])
            ++count;
    }
    cout << count << '\n';
}


Measured memory_bytes: 256
n, r = open(0).read().split(maxsplit=1)
n = int(n)
*a, r = r.split(maxsplit=n)
a = list(map(int, a))
q, *bc = map(int, r.split())

d = {}
for x in a:
    if x in d:
        d[x] += 1
    else:
        d[x] = 1
ret = sum(a)
for i in range(0, min(q*2, len(bc)), 2):
    b = bc[i]
    c = bc[i+1]
    if b in d:
        v = d.pop(b)
        if c in d:
            d[c] += v
        else:
            d[c] = v
        ret += c * v - b * v
    #ret = sum([k * v for k, v in d.items()])
    print(ret)


Measured memory_bytes: 38536
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<climits>
#include<cstring>
#include<queue>
#include<complex>
using namespace std;

int suit2num(string S){
    if(S=="S") return 0;
    if(S=="H") return 1;
    if(S=="C") return 2;
    if(S=="D") return 3;
}

int main(){
    int cards[4][13];
    for (int i=0;i<4;i++){
        for (int j=0;j<13;j++){
            cards[i][j] = 0;
        }
    }

    int n,r, suit;
    string S;
    cin >> n;
    for (int i=0;i<n;i++){
        cin >> S >> r;
        cards[suit2num(S)][r-1] = 1;
    }

    for (int i=0;i<4;i++){
        for (int j=0;j<13;j++){
            if(cards[i][j] == 0){
                if(i == 0){
                    cout << "S" << " "<< j+1 << endl;
                }
                if(i == 1){
                    cout << "H" << " "<< j+1 << endl;
                }
                if(i == 2){
                    cout << "C" << " "<< j+1 << endl;
                }
                if(i == 3){
                    cout << "D" << " "<< j+1 << endl;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3112
a1, b1 = (int(i) for i in input().split())
a2, b2 = (int(i) for i in input().split())
a3, b3 = (int(i) for i in input().split())
list = [a1, b1, a2, b2, a3, b3]
count_list = [list.count(i) for i in range(1,5)]
if 3 in count_list:
    print("NO")
else:
    print("YES")


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

int main(void){
  int A, B,C;
//  char s;
  //string str;
//  if(A==B)
  cin >> A >> B >> C;
  if(A==B)
  cout << C;
  else if(B==C)
  cout<<A;
  else
  cout<<B;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

char s[1000];
char answer[100000010];

int main(void)
{
	int n, m;
	int x, y;
	char c, c2;
	
	while (1) {
		scanf("%d", &n);
		for (x = 0; x < 1000; x++) {
			s[x] = 0;
		}
		for (x = 0; x < n; x++) {
			scanf(" %c %c", &c, &c2);
			s[c] = c2;
		}
		if (n == 0) {
			break;
		}
		scanf("%d", &m);
		for (x = 0; x < m; x++) {
			scanf(" %c", &c);
			if (s[c] != 0) {
				answer[x] = s[c];
			}
			else {
				answer[x] = c;
			}
		}
		answer[x] = '\0';
		printf("%s\n", answer);
		answer[0] = '\0';
	}
	
	return (0);
}

Measured memory_bytes: 692
#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;
     
    void debug_out() { cerr << endl; }
    template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
    template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
    template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
    template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
    template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
    template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
     
    #define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
    #define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
    #define dbg_ok cerr<<"OK!\n"
    #define  st first
    #define  nd second
    #define int long long  
     
    template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
    typedef cc_hash_table<int, int, hash<int > > ht;
     
    const int  M    = 998244353;
    const int  MAXN = 10005 ;
    const int   INF  = 0x3F3F3F3F  ; // long long inf
    const long double eps = 1.084202e-19;


    int32_t main(){
         ios_base::sync_with_stdio(false);
         cin.tie(NULL);
        int x , y ; 
        cin >> x >> y ; 
        if(y>=x){
            cout<<"unsafe";
        }
        else{
            cout<<"safe";
        }
        
       
    }

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <ctime>
using namespace std;

int M;
int a[7];
int s, g;
int N[301];

bool isChecked[301];
vector<int> milestone[301];  //そのマスで出せばゴールにたどり着ける目を格納する

int iabs(int x){ return x >= 0 ? x : -x; }

bool search(int now){
	if (isChecked[now]) return false;
	else if (now == g)  return true;

	isChecked[now] = true;
	/*for (int dice = 1; dice <= 6; dice++){
		if (now + a[dice] == g){
			milestone[now].push_back(a[dice]);
		}
		else if (now - a[dice] == g){
			milestone[now].push_back(-a[dice]);
		}
	}*/
	for (int dice = 1; dice <= 6; dice++){
		if (now + a[dice] <= M && search(now + a[dice] + N[now + a[dice]])){
			milestone[now].push_back(a[dice]);
		}
		if (now - a[dice] >= 1 && search(now - a[dice] + N[now - a[dice]])){
			milestone[now].push_back(-a[dice]);
		}
	}

	return milestone[now].size() > 0 ? true : false;
}

int main(){
	srand((unsigned int)time(NULL));
	cin >> M;
	for (int i = 1; i <= 6; i++){
		cin >> a[i];
	}
	cin >> s >> g;
	for (int i = 1; i <= M; i++){
		cin >> N[i];
	}
	bool canGoal = search(s);

	int now = s; //自分が今いるマスの番号
	for (;;){
		int dice;
		cin >> dice;

		bool found = false;
		for (vector<int>::iterator it = milestone[now].begin(); it != milestone[now].end(); it++){
			if (iabs(*it) == a[dice]){
				if (*it > 0){
					now = now + a[dice] + N[now + a[dice]];
					cout << 1 << endl;
				}
				else{
					now = now - a[dice] + N[now - a[dice]];
					cout << -1 << endl;
				}
				found = true;
				break;
			}
		}
		if(!found) cout << 0 << endl;
		cout.flush();

		if (now == g) return 0;
	}
	
	return 0;
}

Measured memory_bytes: 1304
#include<stdio.h>

static const int N = 100;

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

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

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

      trace(A, n);

      key = A[j];
      //A[j]をソート済みの列A[1..j-1]に代入する
    
      i = j-1;
      
      
      while(i>0 && A[i]>key){
	
	A[i+1] = A[i];
	i = i - 1;
	A[i+1] = key;
      }
    }  
    return 0;
}

Measured memory_bytes: 604