akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define ld long double
#define PB push_back
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define pii pair <int , int>
#define pll pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0);
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const ll maxn = 3e5 + 20 , N = 1e6 + 20 , mod = 998244353 , INF = 1e9 + 10 , lg = 32;

ll fc[N] , rfc[N];

ll pw(ll a, ll b) {
   ll res = 1;
   while (b) {
       if (b & 1) {
           res = (res * a) % mod;
       }
       a = (a * a) % mod;
       b /= 2;
   }
   return res;
}

ll chs(ll a, ll b) {
   return (((fc[b] * rfc[a]) % mod) * rfc[b - a]) % mod;
}

int main() {
    FAST
   fc[0] = rfc[0] = 1;
   for (int i = 1; i < N; ++i) {
       fc[i] = (i * fc[i - 1]) % mod;
       rfc[i] = pw(fc[i] , mod - 2);
   }
   int res , n , m;
   cin >> n >> m;
   res = max(n , m);
   for (int i = 2; i <= min(n + 1, m + 1); i++) {
       ll way = (chs(i - 1, 2 * (i - 1)) * chs(m + 1 - i , n + m + 2 - 2 * i)) % mod;
       ll p = ((way * pw(chs(n , n + m) , mod - 2)) % mod);
       p = (p * pw(2 , mod - 2)) % mod;
       res = (res + p) % mod;
   }
   cout << res << '\n';
}


Measured memory_bytes: 19280
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

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

    vector<int> v(n), c(n);

    ll ans = 0;

    for (int i = 0; i < n; i++)
    {
        cin >> v[i];
    }

    for (int i = 0; i < n; i++)
    {
        cin >> c[i];

        ans += max(0, v[i] - c[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int N; cin >> N;
	vector<int>W(N);
	for (int i = 0;i < N;i++) {
		cin >> W[i];
	}

	int ans = 6000;
	int sum_1 = 0, sum_2 = 0;
	for (int i = 0;i < N;i++) {
		int data = 0, sum_2 = 0;
		sum_1 += W[i];
		for (int j = 1+i;j < N;j++) {
			sum_2 += W[j];
		}
		data = sum_2 - sum_1;
		if (data < 0)data *= -1;
		if (ans > data)ans = data;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <limits>
#include <iterator>
#include <cmath>
#include <numeric>
#include <stack>
#include <queue>
#include <cassert>
#include <forward_list>
#include <chrono>
#include <deque>
#include <list>
#include <random>
#include <cstdio>
#include <sstream>

using namespace std;

int main()
{
	vector<int> a(3);
	for (int i = 0; i < 3; i++)
	{
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	cout << a[0] * 10 + a[1] + a[2] << endl;

	return 0;
}

Measured memory_bytes: 384
a=int(input())
dp=[float('inf') for i in range(100000+10)]
dp[0]=0
for i in range(1,100000+1):
    dp[i]=dp[i-1]+1
    for k in [6,9]:
        for j in range(1,7):
            if k**j <=i :
                dp[i]=min(dp[i],dp[i-k**j]+1)
print(dp[a])

Measured memory_bytes: 6296
// Problem_C.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//
#include <iostream>
using namespace std;

int N, M;
int V[4] = { -1, -1, -1, -1 };

bool input_check(void) {
	cin >> N >> M;
	bool ret = true;
	for (int i = 0; i < M; ++i) {
		int s, c;
		cin >> s >> c;
		if (V[s] == -1)
			V[s] = c;
		else {
			if (V[s] != c)
				ret = false;
		}
	}
	return ret;
}

int solve(void) {
	if (V[1] == 0) {
		if (N == 1)
			return 0;
		else
			return -1;
	}
	if (V[1] == -1) {
		if (N == 1)
			V[1] = 0;
		else
			V[1] = 1;
	}
	if (N >= 2 && V[2] == -1)
		V[2] = 0;
	if (N == 3 && V[3] == -1)
		V[3] = 0;
	int val = 0;
	for (int i = 1; i <= N; ++i) {
		val *= 10;
		val += V[i];
	}
	return val;
}

int main(void) {
	int ans = -1;
	bool flag = input_check();
	if (flag)
		ans = solve();
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
use std::cmp::{max, min};
use std::io::stdin;
use std::str::FromStr;

const A_AS_INT: usize = 'a' as usize;

fn main() {
    let n: usize = input().unwrap();
    next(n, "a".to_string());
}

fn next(n: usize, before: String) {
    if before.len() == n {
        println!("{}", before);
    } else {
        let kind = {
            let mut tmp = before.chars().collect::<Vec<_>>();
            tmp.sort();
            tmp.dedup();
            tmp.len()
        };

        for c in A_AS_INT..kind+A_AS_INT+1 {
            let mut nex = before.clone();
            nex.push(c as u8 as char);
            next(n, nex);
        }
    }
}

fn input<T: FromStr>() -> Result<T, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    Ok(buf.trim().parse().ok().unwrap())
}

fn input_vec<T: FromStr>() -> Result<Vec<T>, T::Err> {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    Ok(buf
        .trim()
        .split_whitespace()
        .map(|x| x.parse().ok().unwrap())
        .collect::<Vec<_>>())
}

fn input_two<T: FromStr>() -> Result<(T, T), T::Err> {
    let tmp = input_vec::<String>().unwrap();
    Ok((tmp[0].parse()?, tmp[1].parse()?))
}

fn input_three<T: FromStr + Clone>() -> Result<(T, T, T), T::Err> {
    let tmp = input_vec::<T>().ok().unwrap();
    // println!("{:?}", tmp);
    Ok((tmp[0].clone(), tmp[1].clone(), tmp[2].clone()))
}


Measured memory_bytes: 5500
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
typedef long long ll;
using namespace std;

bool comp(const int& a, const int& b) {
	return a > b;
}

int main()
{
	int N,A=0,B=0;
	vector<int> vec;
	cin >> N;
	fore(i,0,N) {
		int t;
		cin >> t;
		vec.push_back(t);
	}
	sort(vec.begin(),vec.end(), comp);
	fore(i, 0, N) {
		if (i % 2 == 0) {
			A = A + vec[i];
		}
		else {
			B = B + vec[i];
		}
	}
	cout << abs(A - B) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v1 = vector<T>;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max() - (int)1e8;
const ll INFLL = numeric_limits<ll>::max() - (ll)1e17;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G(N);
    for (int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        A--, B--;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    queue<pair<int, int>> explore;
    explore.emplace(-1, 0);
    vector<bool> check(N, false);
    check[0] = true;
    vector<int> ans(N, -1);
    while (!explore.empty()) {
        auto now = explore.front();
        explore.pop();
        ans[now.second] = now.first;
        for (int next : G[now.second]) {
            if (check[next]) continue;
            explore.emplace(now.second, next);
            check[next] = true;
        }
    }
    cout << "Yes" << endl;
    for (int i = 1; i < N; i++) {
        cout << ans[i] + 1 << endl;
    }
}

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

using namespace std;

int main() {
	long long a, b, k; cin >> a >> b >> k;
	long long t = min(a, k);
	a -= t;
	k -= t;
	b -= min(b, k);
	cout << a << " " << b << endl;

	return 0;
}

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

int main()
{
    long int n, k;
    cin >> n >> k;

    n = n % k;
    long int prevN = n;
    while(true)
    {
        prevN = n;
        n = abs(n - k);

        if(n >= prevN)
        {
            cout << prevN;
            break;
        }
    }

    return 0;
}


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

class Point{
public:
  int n[8],g;
  bool operator < (const Point &p) const{ return g > p.g;}
};

int main(){
  int i,j,n,m,b[8],ans;
  Point p[100];
  string str;
  while(1){
    cin >> n >> m;
    if(n == 0 && !m) break;

    for(i=0;i<n;i++){
      cin >> str;
      for(j=0;j<str.size();j++){
	if(str[j] == '*') p[i].n[j] = -1;
	else p[i].n[j] = str[j] - '0';
      }
      cin >> p[i].g;
    }

    sort(p,p+n);
    ans = 0;

    for(i=0;i<m;i++){
      cin >> str;
      for(j=0;j<8;j++) b[j] = str[j] - '0';

      for(int k=0;k<n;k++){
	for(j=0;j<8;j++){
	  if(p[k].n[j] != -1 && p[k].n[j] != b[j]) break;
	}
	if(j == 8){
	  ans += p[k].g;
	  break;
	}
      }
    }

    cout << ans << endl;

  }
  return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#define ll long long
#define MAXN 105
using namespace std;
typedef pair<int,int> pii;
template <typename t>
inline void read(t& a)
{
    t ret(0),f(1);char ch(getchar());
    while(ch < '0' || ch > '9'){if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){ret = ret * 10 + (ch ^ 48);ch = getchar();}
    a = ret * f;
}
inline int Max(int x,int y){return x > y ? x : y;}
inline int Min(int x,int y){return x < y ? x : y;}
int a[MAXN];
int main()
{
	int n,x,ans(0);
	read(n),read(x);
	for(int i(1);i <= n;i++)
		read(a[i]);
	sort(a + 1,a + n + 1);
	for(int i(1);i <= n;i++)
	{
		if(x >= a[i]) x -= a[i],++ans;
		else {x = 0;break;}
	}
	printf("%d",Max(0,ans - (x != 0)));
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node
{
    int key;
    Node *next, *prev;
};

Node *nil;

Node* listSearsh(int key)
{
    Node *cur = nil->next;
    while(cur != nil && cur->key != key)
    {
        cur = cur->next;
    }
    return cur;
}
void init()
{
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}
void printList()
{
    Node *cur = nil->next;
    int isf = 0;
    while(1)
    {
        if(cur == nil)    break;
        if(isf++ > 0)     printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}
void deleteNode(Node *t)
{
    if(t==nil)     return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
}
void deleteFirst()
{
    deleteNode(nil->next);
}
void deleteLast()
{
    deleteNode(nil->prev);
}
void deleteKey(int key)
{
    deleteNode(listSearsh(key));
}
void insert(int key)
{
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main()
{
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for(int i=0; i<n; i++)
    {
        scanf("%s%d", com, &key);
        if(com[0]=='i')
        {
            insert(key);
            np++,size++;
        }
        else if(com[0] == 'd')
        {
            if(strlen(com)>6)
            {
                if(com[6]=='F')
                    deleteFirst();
                else if(com[6]=='L')
                    deleteLast();
            }
            else
            {
                deleteKey(key);
                nd++;
            }
            size--;
        }
    }
    printList();
    return 0;
}

Measured memory_bytes: 36940
import java.io.*;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);
		while(true) {
			int n = sc.nextInt();
			if (n == 0) break;
			int[][] map = new int[n][n];
			int x = n/2;
			int y = n/2+1;
			map[y][x] = 1;
			for(int i = 2; i <= n*n; i++) {
				x++;
				y++;
				
				IN:do {
					
					if(x >= n) {
						x = 0;
						continue IN;
					}
					if(x < 0) {
						x = n-1;
						continue IN;
					}
					if(y >= n) {
						y = 0;
						continue IN ;
					}
					if(map[y][x] != 0) {
						y++;
						x--;
						continue IN;
					}
					break;
				}while(true);
				map[y][x] = i;
				
				
			}
			for(int i = 0; i < n; i++) {
				for(int j = 0; j < n; j++) {
					System.out.printf("%4d",map[i][j]);
				}
				System.out.println();
			}
		}
		out.flush();

	}
}
//------------------------------//
//-----------//
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    
    public int nextInt() {
    	return (int)nextLong();
    }
    

}

Measured memory_bytes: 19888
// https://atcoder.jp/contests/abc074/tasks/arc083_a

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int B_MAX = 30;
const int D_MAX = 30;
const int E_MAX = 100;
const int F_MAX = 3'000;

int A, B, C, D, E, F;

void solve() {
  double vx = -1;
  int abcdx = 0;
  int cdx = 0;
  for (int a = 0; a * 100 <= F; a += A) {
    for (int ab = a; ab * 100 <= F; ab += B) {
      for (int c = 0; c <= ab * E && ab * 100 + c <= F; c += C) {
        int d = min(F - (ab * 100 + c), ab * E - c) / D * D;
        int cd = c + d;
        int abcd = ab * 100 + cd;
        if (abcd == 0) continue;
        double v = (double)cd / abcd;
        if (v > vx) {
          vx = v;
          abcdx = abcd;
          cdx = cd;
        }
      }
    }
  }
  printf("%d %d\n", abcdx, cdx);
}

void input() {
  scanf("%d%d%d%d%d%d", &A, &B, &C, &D, &E, &F);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a) for (ll i = 0; i < (a); ++i)
#define pb push_back
#define all(v) v.begin(),v.end()
#define sort_1(v) sort(v.begin(),v.end())
#define sort_2(v) sort(v.begin(),v.end(),greater<ll>())
#define reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef long double la;
using namespace std;
 
int main(){
  ll x;
  cin >> x;
  for(int i=-200;i<=200;i++){
    for(int j=-200;j<=200;j++){
      if (pow(i,5) - pow(j,5) == x){
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 4020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define rep3(i, s, n) for (int i = s; i > (int)(n); i--)
#define all(obj) obj.begin(), obj.end()
#define db(x) cerr << #x << ":" << x << " "
#define dbl(x) cerr << #x << ":" << x << "\n"
#define dbv(vec) cerr << #vec << ":"; for (auto e : vec) cerr << e << " "; cout << "\n"
#define dbvv(vv) cerr << #vv << ":\n"; for (auto vec : vv) { for (auto e : vec) cerr << e << " "; cerr << endl; }
#define YN(f) cout << (f ? "YES" : "NO") << endl
#define Yn(f) cout << (f ? "Yes" : "No") << endl
#define yn(f) cout << (f ? "yes" : "no") << endl
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;

int main() {
	string s; cin >> s;
	bool f = s != "AAA" && s != "BBB";
	Yn(f);
}

Measured memory_bytes: 256
from collections import deque

def bfs(s):
    status[s] = VISITING
    signs[s] = 0
    Q.append(s)
    while len(Q) > 0:
        u = Q.popleft()
        for v in rooms[u]:
            if status[v] == NOT_VISITED:
                status[v] = VISITING
                signs[v] = u
                Q.append(v)
        status[u] = VISITED


def bfs_opt(s):
    signs[s] = 0
    Q.append(s)
    while len(Q) > 0:
        u = Q.popleft()
        for v in rooms[u]:
            if signs[v] == INFTY:
                signs[v] = u
                Q.append(v)


n, m = map(int, input().split())
rooms = [[] for i in range(n)]

# adjacent list
for i in range(m):
    a, b = map(int, input().split())
    rooms[a-1].append(b-1)
    rooms[b-1].append(a-1)

INFTY = float('inf')
signs = [INFTY] * n

# status を保持しなくても、signs == INFTY (== 未訪問) で訪問済みかどうかの判定は可能
# for bfs()
# NOT_VISITED = 0
# VISITING = 1
# VISITED = 2
# status = [NOT_VISITED] * n

Q = deque()

bfs_opt(0)

# ok = True
# for sign in signs:
#     if sign == INFTY:
#         ok = False

# ok にならない (No になる) ケースは存在しない
print('Yes')
signs = signs[1:]
for sign in signs:
    print(sign + 1)

Measured memory_bytes: 34460
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var n=(sc.I%1000);
		Console.WriteLine("{0}",(1000-n)%1000);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),int.Parse);}
	public int[] Ia3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),long.Parse);}
	public long[] La3(int a){return Array.ConvertAll((Console.ReadLine()+" "+a.ToString()).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(string a,string b){return Array.ConvertAll((a+Console.ReadLine()+b).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 27548
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
 
int main(){
     
    int x[1000],y[100];
    int n,i,max=0;
    double D[5],sum1=0,sum2=0;
 
    for(i=0;i<5;i++){
      D[i]=0;
    }
     
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    for(i=0;i<n;i++){
        scanf("%d",&y[i]);
    }
     
    for(i=0;i<n;i++){
        D[0]+=abs(x[i]-y[i]);
    }
     
    for(i=0;i<n;i++){
        sum1+=(x[i]-y[i])*(x[i]-y[i]);
    }
    D[1]=sqrt(sum1);
     
    for(i=0;i<n;i++){
        sum2+=pow(abs(x[i]-y[i]),3);
    }
    D[2]=pow(sum2,0.33333333333);
     
    for(i=0;i<n;i++){
        if(max<=abs(x[i]-y[i])){
        max=abs(x[i]-y[i]);
        }
    }   
    D[3]=max;
        for(i=0;i<4;i++){
          printf("%.8f\n",D[i]);
    }
    return 0;
}

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

#define faster      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi          acos(-1.0)
#define nl          '\n'

///Library
#define mem(a,b)    memset(a,b,sizeof(a))
#define all(a)      a.begin(),a.end()
#define Sort(x)     sort(x.begin(),x.end())
#define Reverse(x)  reverse(x.begin(),x.end())
#define SortA(ar,s) sort(ar,ar+s)
#define SortD(ar,s) sort(ar,ar+s,greater<int>())
#define gcd(a,b)    __gcd(a,b)
#define lcm(a,b)    (a*(b/gcd(a,b)))
#define sq(x)       (x)*(x)

#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min(b,min(c,d)))
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max(b,max(c,d)))
#define ABS(x)             ((x)<0?-(x):(x))
#define pb                 push_back
#define mod                1000000007
#define end                printf("\n")
#define yes                printf("YES\n")
#define no                 printf("NO\n")

///data type
typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
	faster
	int a,b,c,ans;
	cin>>a>>b>>c;
	if(a%b==0)ans=a/b;
	else ans=a/b+1;
	cout<<ans*c<<nl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  int com = 0;
  
  for(int i = 1; i <= 9; i++){
    for(int j = 1; j <= 9; j++){
      if(i * j == N){
        cout << "Yes" << endl;
        com = 1;
        break;
      }
      else if(i * j == 81){
        cout << "No" << endl;
      }
    }
    if(com == 1){
      break;
    }
  }
}


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

using namespace std;
 
#define PB	push_back
#define ALL(x)	(x).begin(), (x).end()
#define ALLR(x)	(x).rbegin(), (x).rend()
#define MP	make_pair
 
#define debug(_x)		cerr << #_x << '=' << (_x) << endl;
#define debug2(_x, _y)	cerr << #_x << '=' << (_x) << ' ' << #_y << '=' << (_y) << endl;
#define debugn(_a)		cerr << #_a << ": "; for (const auto _x: _a) cerr << (_x) << ' '; cerr << endl;

#define HERE debug(__LINE__);

#define FAST_IO ios::sync_with_stdio(false); cin.tie(0)

#define int long long int

typedef pair<int, int> ii;
typedef pair<pair<int, int>, int> iii;
typedef vector<int> vi;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef unsigned long long ull;

const int INF = LONG_LONG_MAX>>1;
const int NINF = LONG_LONG_MIN/2;

//MODULAR ARITHMATIC
const int mmod = 1000000007 ;

//ADD
int add(int a, int b, int m=mmod) {
	a += b;
	a %= m;
	return a;
}

//SUB
int sub(int a, int b, int m=mmod) {
    return (a%m - b%m + m)%m;
}

//MUL
int mul(int a, int b, int m=mmod) {
	return ((a%m) * (b%m) % m);
}

//POW
int pow(int a, int b, int m=mmod) {
    a %= m;
    int r = 1;
    while (b) {
		if (b&1) r = r*a%m;
		b >>= 1;
		a = a*a%m;
    }
    return r;
}

int32_t main() {
	FAST_IO;
	
	int h, w;
	cin >> h >> w;
	
	string s[h];
	for (int i = 0; i < h; i++) cin >> s[i];
	
	vvi dp(h, vi(w));
	
	dp[0][0] = 1;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] != '#') {
				if (i+1 != h)	
					dp[i+1][j] = add(dp[i+1][j], dp[i][j]);
				if (j+1 != w)
					dp[i][j+1] = add(dp[i][j+1], dp[i][j]);
			}
		}
	}
	
	cout << dp[h-1][w-1] << endl;
}

// g++ -Wall -Wextra -Wshadow -fsanitize=undefined


Measured memory_bytes: 9216
#include<cstdio> 
#include<cstring>
#include<iostream> 
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(abs(a-b)%2==1)
	cout<<"IMPOSSIBLE";
	else cout<<abs(max(a,b)-abs(a-b)/2);
	return 0;
} 

Measured memory_bytes: 256
// #include <cmath>
// #include <vector>
// #include <iostream>

// using namespace std;

// int main()
// {
//     vector<int> v;
//     int N,x,sum=0;
//     int ans=0;
//     cin>>N;
//     for(int i=0;i<N; i++)
//     {
//         cin>>x;
//         v.push_back(x);
//         sum+=x;
//     }
//     if(sum==0)
//     {
//         cout<<0;
//     }
//     else{
//     float sum1 =ceil((float)sum/(float)N);
//     for(int i:v)
//     {
//         ans+=pow((i-sum1),2);
//     }
//     cout<<ans;
//     }


//     return 0;
// }
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    vector<int> v;
    int N,x,sum=0;
    int ans=0;
    int ans1=0;
    cin>>N;
    for(int i=0;i<N; i++)
    {
        cin>>x;
        v.push_back(x);
        sum+=x;
    }
    sum/=N;
    for(int i:v)
    {
        ans+=pow((i-sum),2);
        ans1+=pow((i-sum-1),2);
    }
    cout<<min(ans,ans1);


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define ll long long
bool IsPrime(ll int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (ll int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main(void){
    ll int X;
    cin >> X;
    X--;
    bool ans = false;
    while(ans == false){
        ans = IsPrime(++X);
    }
    cout << X << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <functional>
#include <cstring>
#include <cstdio>
using namespace std;
const int maxn = 1e5+10;

struct edge{
	int to,dis,cost;
	edge(){}
	edge(int to,int dis,int cost) : to(to),dis(dis),cost(cost){}
	bool operator>(const edge& rhs) const{
		return dis != rhs.dis ? dis>rhs.dis : cost>rhs.cost;
	}
};

int V,M;
bool vis[maxn];

vector<edge> G[maxn];

int dijkstra(int s){
	int res = 0;
	priority_queue<edge,vector<edge>,greater<edge> > Q;

	Q.push(edge(0,0,0));

	while(!Q.empty()){
		edge p = Q.top(); Q.pop();
		int v = p.to;
		if(vis[v]) continue;
		vis[v] = true;
		res += p.cost;
		for(int i=0; i<G[v].size(); i++){
			Q.push(edge(G[v][i].to,p.dis+G[v][i].dis,G[v][i].cost));
		}
	}

	return res;
}


int main(){
	while(scanf("%d%d",&V,&M) && V){
		memset(vis,0,sizeof(vis));
		for(int i=0; i<=V; i++) G[i].clear();

		for(int i=0; i<M; i++){
			int u,v,d,c;
			scanf("%d%d%d%d",&u,&v,&d,&c);
			--u,--v;
			G[u].push_back(edge(v,d,c));
			G[v].push_back(edge(u,d,c));
		}

		printf("%d\n",dijkstra(0));

	}
}

Measured memory_bytes: 7736
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


def init(bit, values):
    for i,v in enumerate(values):
        update(bit,i,v)

#A1 ~ Aiまでの和 O(logN)
def query(bit,i):
    res_sum = 0
    while i > 0:
        res_sum += bit[i]
        i -= i&(-i)
    return res_sum

#Ai += x O(logN)
def update(bit,i,x):
    while i <= len(bit)-1:
        bit[i] += x
        i += i&(-i)
    return


n = int(input())
a = list(map(int, input().split()))
from collections import Counter
def sub(x):
    cumsum = [None] * n
    cumsum[0] = 1 if a[0]>=x else -1
    for i in range(1,n):
        cumsum[i] = cumsum[i-1] + (1 if a[i]>=x else -1)

    ### BIT 
    #A1 ... AnのBIT(1-indexed)
    bit = [0]*(2*n+2)
    update(bit, n+1, 1)
    ans = 0
    for v in cumsum:
        ans += query(bit, v+n+1)
        update(bit, n+v+1, 1)
    return ans

l = 0
r = 10**9+1
tmp = (n+1)*n//2
thre = tmp//2 + tmp%2
while l<r-1:
    m = (l+r)//2
    if sub(m)>=thre:
        l = m
    else:
        r = m
print(l)

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

using namespace std;

typedef long long ll;

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

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

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

int main() {
   int H, W;
   cin >> H >> W;
   string S;
   for (int i = 0; i <= W + 1; i++) cout << "#";
   cout << endl;
   for (int i = 0; i < H; i++) {
      cin >> S;
      cout << "#";
      cout << S;
      cout << "#";
      cout << endl;
   }
   for (int i = 0; i <= W + 1; i++) cout << "#";
   cout << endl;
   return 0;
}


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

int main() {
  int N;
  cin >> N;
  string s;
  bool exits_Y = false;

  //N回目まで繰り返す
  for(int i = 0; i < N ; ++i){
      //ひなあられを受け取る
      cin >> s;
      if(s == "Y"){
          exits_Y = true;
          break;
      }
  }

  //フラグがたったか判断する
  if(exits_Y)cout << "Four" << endl;
  else cout << "Three" << endl;
}


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

using namespace std;

const int mod=1e9+7,maxn=1e5+10;
int n,k;
ll cnt=1;
char vis[maxn];
vector<int> v[maxn];

void dfs(int x,int fa,int p)
{
    int i,j,num=1;
    //cout<<cnt<<' '<<x<<' '<<k-p-1<<endl;
    cnt=(cnt*(k-p-1))%mod;
    for(i=0;i<(int)v[x].size();i++)
        if(vis[v[x][i]]==0 && v[x][i]!=fa)
        {
            vis[v[x][i]]=1;
            dfs(v[x][i],x,num++);
        }
}
/*void dfs(int x,int fa,int p)
{
    int i,j,num=0;
    cnt=(cnt*(k-p))%mod;
    for(i=0;i<(int)v[x].size();i++)
    {
        if(!vis[v[x][i]])
        {
            vis[v[x][i]]=1;
            dfs(v[x][i],x,num++);
        }
    }
}*/

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

    int i,j,a,b;
    cin>>n>>k;
    for(i=1;i<n;i++)
    {
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    /*for(i=1;i<=n;i++)
    {
        cout<<v[i].size()<<' ';
        for(j=0;j<(int)v[i].size();j++)
            cout<<v[i][j]<<' ';
        cout<<endl;
    }
    cout<<endl;*/
    cnt=k;
    for(i=1;i<=n;i++)
        if(v[i].size()==1)
        {
            vis[i]=1;
            dfs(v[i][0],i,0);
            break;
        }
    cout<<cnt<<endl;
    return 0;
}

/*

4 3
1 2
2 3
3 4


*/


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

int main(void) {
  int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
  int w = tx - sx, h = ty - sy;
  REP(i,h) cout << 'U';
  REP(i,w) cout << 'R';
  REP(i,h) cout << 'D';
  REP(i,w) cout << 'L';
  cout << 'L';
  REP(i,h+1) cout << 'U';
  REP(i,w+1) cout << 'R';
  cout << 'D' << 'R';
  REP(i,h+1) cout << 'D';
  REP(i,w+1) cout << 'L';
  cout << 'U' << '\n';
}


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

namespace AtCoder.ABC172
{
    public class Problem2
    {
        public static void Main(string[] args)
        {
            var S = Console.ReadLine().ToCharArray();

            var T = Console.ReadLine().ToCharArray();

            var cnt = (long)0;

            for (var i = 0; i < S.Count(); i++)
            {
                if (S[i] != T[i])
                {
                    cnt++;
                }
            }

            Console.WriteLine(cnt.ToString());
        }
    }
}


Measured memory_bytes: 28576
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

const uint64_t mod = 1'000'000'007;

int main() {
  uint32_t N = 0, K = 0;
  std::cin >> N >> K;
  std::vector<uint64_t> plus, minus;
  for (size_t i = 0; i < N; i++)
  {
    int64_t a = 0;
    std::cin >> a;
    if(a >= 0) plus.push_back(a);
    else minus.push_back(-a);
  }

  if(N == K){
    uint64_t result = 1;
    for (size_t i = 0; i < plus.size(); i++) result = (result * plus[i]) % mod;
    for (size_t i = 0; i < minus.size(); i++) result = (result * minus[i]) % mod;

    std::cout << ((result && minus.size()%2) ? mod - result : result) << std::endl;
    return 0;
  }

  if(plus.empty() && K%2){
    std::sort(minus.begin(), minus.end());

    uint64_t result = 1;
    for (size_t i = 0; i < K; i++) result = (result * minus[i]) % mod;
    std::cout << mod - result << std::endl;
    return 0;
  }

  std::sort(plus.rbegin(), plus.rend());
  std::sort(minus.rbegin(), minus.rend());

  uint32_t p = 0, m = 0;
  for (size_t i = 0; i < K; i++)
  {
    if(plus.empty() || p == plus.size()) m++;
    else if(minus.empty() || m == minus.size()) p++;
    else if(plus[p] >= minus[m]) p++;
    else m++;
  }
  if(m % 2){
    if(p == plus.size()) p--, m++;
    else if(m == minus.size() || p == 0) p++, m--;
    else if(plus[p]*plus[p-1] >= minus[m]*minus[m-1]) p++, m--;
    else p--, m++;
  }

  uint64_t result = 1;
  for (size_t i = 0; i < p; i++) result = (result * plus[i]) % mod;
  for (size_t i = 0; i < m; i++) result = (result * minus[i]) % mod;

  std::cout << result << std::endl;

  return 0;
}

Measured memory_bytes: 5560
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin>>s;
  int len=s.size();
  int bit[len]={0};
  int A=0,Z=0;
  for(int i=0;i<len;i++){
    if(s[i]=='A'){
      A=i;
      break;
    }
  }
  for(int i=len-1;i>=0;i--){
    if(s[i]=='Z'){
      Z=i;
      break;
    }
  }
  cout<<Z-A+1<<endl;
  return 0;
}


Measured memory_bytes: 1412
#include <stdio.h>

int main(void){

	int b;
	int i, j;
	int k = 0;
	while (1){
		scanf("%d", &b);
		if (!b) break;
		int a[10][10] = {};
		int sum[10][10] = {};
		for (i = 0; i < b; i++)
			for (j = 0; j < b; j++)
				scanf("%d", &a[i][j]);

		for (i = 0; i < b; i++) {
			for (j = 0; j < b; j++) {
				printf("%5d", a[i][j]);
				sum[0][i] += a[i][j];
			}
			printf("%5d\n", sum[k][i]);
		}

		for (j = 0; j < b; j++) {
			for (i = 0; i < b; i++) {
				sum[1][j] += a[i][j];
				sum[2][0] += a[j][i];
			}
			printf("%5d", sum[1][j]);
		}

		printf("%5d\n", sum[2][0]);
	}

	return 0;
}

Measured memory_bytes: 608
local ior = io.read
local n = ior("*n")
local a = {}
for i = 1, n do a[i] = io.read("*n") end

local function getgcd(x, y)
  while(0 < x and 0 < y) do
    if(x < y) then y = y % x else x = x % y end
  end
  return math.max(x, y)
end

local mac = math.ceil
local mam = math.max

local mesh = 500

local groups = mac(n / mesh)
local groupgcd = {}
local group_inv_gcd = {}
for i = 1, groups do
  groupgcd[i] = 0
  group_inv_gcd[i] = 0
end

for i = 1, n do
  local g = mac(i / mesh)
  groupgcd[g] = getgcd(groupgcd[g], a[i])
end

for i = 1, groups do
  for j = 1, groups do
    if(i ~= j) then
      group_inv_gcd[i] = getgcd(group_inv_gcd[i], groupgcd[j])
    end
  end
end

local ret = 0

for i = 1, n do
  local g = mac(i / mesh)
  local stt = 1 + (g - 1) * mesh
  local last = (g == groups and n or g * mesh)
  local cand = group_inv_gcd[g]
  for j = stt, last do
    if(j ~= i) then
      cand = getgcd(cand, a[j])
    end
  end
  ret = mam(ret, cand)
end
print(ret)


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

string x;
int i, s, t, tot;

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

	cin >> x;
	tot=x.length();
	for (i=0; i<int(x.length()); i++) {
		if (x[i]=='S') {
			s++;
		}
		if (x[i]=='T') {
			t++;
			if (s>0) {
				s--;
				t--;
				tot-=2;
			}
		}
	}
	cout << tot;

}

Measured memory_bytes: 720
#include<cstdio>
#include<algorithm>

using namespace std;

int N;
int l[15];
int b,c;
//int res[1000000000000];


void solve(int k){
  for(int i=0;i<10;i++){
    if(b<l[i] && c<l[i]){
      if(l[i]-b < l[i]-c) b=l[i];
      else c=l[i];
    }
    else if(b<l[i] && c>l[i]) b=l[i];
    else if(b>l[i] && c<l[i]) c=l[i];
    else{
  //    res[k]=0;
      printf("NO\n");
      return;
    }
  }
  printf("YES\n");
  return;
}


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

  for(int i=0;i<N;i++){
    b=0;
    c=0;
    scanf("%d%d%d%d%d%d%d%d%d%d",&l[0],&l[1],&l[2],&l[3],&l[4],&l[5],&l[6],&l[7],&l[8],&l[9]);
    solve(i);
  }

  /*for(int i=0;i<N;i++){
    if(res[i]==0) printf("NO\n");
    else printf("YES\n");
  }
*/

  return 0;
}

Measured memory_bytes: 1008
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;

int n;
pii arr[200200];
int dp[200200];
stack<pii> s;

int32_t main(){
	cin >> n;
	for(int i=0; i<n; ++i) cin >> arr[i].first >> arr[i].second;
	dp[n]=1ll;
	s.push({4294967296ll, n});
	sort(arr, arr+n);
	for(int i=n-1; i>=0; --i){
		while(s.top().first < (arr[i].first + arr[i].second)) s.pop();
		dp[i] = (dp[i+1] + dp[s.top().second]) % 998244353;
		s.push({arr[i].first, i});
	}
	cout << dp[0] << endl;
}


Measured memory_bytes: 6528
mod=10**9+7
k=int(input())
s=input()
n=len(s)
c=1
t=1
ans=0
for i in range(k+1):
  ans+=c*t
  ans%=mod
  c*=(n+k-i)*pow(i+1,mod-2,mod)
  c%=mod
  t*=25
  t%=mod
print(ans)


Measured memory_bytes: 75632
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<queue>
#define N (998244353)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> Q;

ll h,w,n;
bool check(int i,int j){
    return (i>=0)&&(i<h-2)&&(j>=0)&&(j<w-2);
}

ll ans[20];

int main(void){
    cin>>h>>w>>n;
    vector<int>a(n),b(n);
    set<P>black,cand;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
        black.insert(P(a[i],b[i]));
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                int x = a[i]-j;
                int y = b[i]-k;
                if(check(x,y))
                    cand.insert(P(x,y));
            }
        }
    }
    ll white = (h-2)*(w-2);
    for(auto p:cand){
        int cnt = 0;
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                int x = p.first+j;
                int y = p.second+k;
                if(black.count(P(x,y))==1)cnt++;
            }
        }
        ans[cnt]++;
        if(cnt)white--;
    }
    ans[0]=white;
    for(int i=0;i<10;i++)cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 47872
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	m := getNextInt(scanner)
	seg := Segment{}
	seg.init(n)
	for i := 0; i < n; i++ {
		seg.maximize(i, getNextInt(scanner))
	}
	for i := 0; i < m; i++ {
		seg.maximize(seg.top(), seg.bucket[seg.h-1][0]>>1)
	}

	var ans int64
	for i := 0; i < n; i++ {
		ans += int64(seg.bucket[0][i])
	}

	fmt.Fprintln(writer, ans)
	writer.Flush()
}

// Segment ...
type Segment struct {
	n, h, i, chunk int
	unit           []int
	bucket         [][]int
}

func (seg *Segment) init(n int) {
	seg.n = n
	seg.unit = make([]int, 1)
	seg.unit[0] = 1
	seg.bucket = make([][]int, 1)
	seg.bucket[0] = make([]int, n)

	chunk := 2
	for i := 0; n > 1; i++ {
		n = (n-1)/chunk + 1
		seg.bucket = append(seg.bucket, make([]int, n))
		seg.unit = append(seg.unit, seg.unit[i]*chunk)
	}
	seg.h = len(seg.unit)
	seg.chunk = chunk
}

func (seg *Segment) maximize(index, value int) {
	seg.bucket[0][index] = value
	for seg.i = 0; seg.i < seg.h-1; seg.i++ {
		s := index - index%seg.chunk
		parent := index / seg.chunk
		max := 0
		for i := 0; s+i < len(seg.bucket[seg.i]) && i < seg.chunk; i++ {
			if max < seg.bucket[seg.i][s+i] {
				max = seg.bucket[seg.i][s+i]
			}
		}
		seg.bucket[seg.i+1][parent] = max
		index /= seg.chunk
	}
}

func (seg *Segment) top() int {
	index := 0
	for seg.i = seg.h - 2; seg.i >= 0; seg.i-- {
		for i := 0; index*seg.chunk+i < len(seg.bucket[seg.i]) && i < seg.chunk; i++ {
			if seg.bucket[seg.i][index*seg.chunk+i] == seg.bucket[seg.i+1][index] {
				index = index*seg.chunk + i
				break
			}
		}
	}

	return index
}


Measured memory_bytes: 4480
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;

int tim(string s){
  int h = (s[0] - '0') * 10 + (s[1] - '0');
  int m = (s[3] - '0') * 10 + (s[4] - '0');
  return h * 60 + m;
}

int main(){
  int n,t;
  cin>>n>>t;
  vector<pair<string , int> > d;
  int l = 0;
  rep(i,n){
    string t1,t2,n1,n2;
    cin>>t1>>n1>>t2>>n2;
    int tt1 = tim(t1),tt2 = tim(t2);
    //cout<<n1<<endl;
    if(i == 0){
      l = tt2; 
      continue;
    }
    if(tt1 - l >= t)
      d.push_back(make_pair(n1,tt1-l));
    //cout<<n1<<" "<<tt1-l<<endl;    
    //cout<<n1<<" "<<tt1<<" "<<n2<<" "<<tt2<<endl;
    l = tt2;
  }
  cout<<d.size()<<endl;
  rep(i,d.size())cout<<d[i].first<<" "<<d[i].second<<endl;

}

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

int main() {
    string s;
    cin >> s;
    for (char i = 'a'; i <= 'z'; i++){
        if (s.find(i) == -1){
            cout << i;
            return 0;
        }
    }
    cout << "None";
    return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};
 
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 (a > b) { a = b; return 1; } return 0; }
 
struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};
 



signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Timer TM;


    ll n;
    cin>>n;
    ll ans=1;
    ll cnt=0;
    rep(i,n){
        ll a;
        cin>>a;
        if(a<cnt*2+1){
            ans*=(cnt+1);
            ans%=MOD;
            cnt--;
        }
        cnt++;
    }
    rep2(i,1,cnt+1){
        ans*=i;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  // 
  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  ll x;cin>>x;
  ll elemod=x%11;
  ll elesum=x/11;
  if(elemod==0){
    P(elesum*2);
  }else if(elemod>=1 && elemod<=6){
    P(2*elesum+1);
  }else{
    P(elesum*2+2);
  }
  return 0;
}


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

int dfs(vector<int>& v, int n) {
	if(!v.size() || v[v.size() - 1] >= n) {
		for(int i = 0; i < v.size(); ++i)
			cout << v[i] << " ";

		cout << n << endl;
	}

	for(int i = n - 1; i >= 1; --i) if(!v.size() || v[v.size() - 1] >= i) {
		v.push_back(i);
		dfs(v, n - i);
		v.pop_back();
	}
}

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

	for(int n; cin >> n, n;) {
		vector<int> v;
		dfs(v, n);
	}

	return EXIT_SUCCESS;
}

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

typedef long long ll;

int main(){
	rep(i,3)rep(j,3){
		char c; cin >> c;
		if(i==j)cout << c;
	}
	cout << endl;
	return 0;
}

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var K = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var A = input[0];
            var B = input[1];

            Console.WriteLine(A % K == 0 || (1 + A / K) * K <= B ? "OK" : "NG");
        }
    }
}


Measured memory_bytes: 28276