akhauriyash/Code-Regression huggingface dataset:
function*stdinIter(){const t=require("fs").readFileSync("/dev/stdin","utf-8").trim().split(/\n|\s/);yield*t}function readMany(t,e){const i=e||this.iter||(this.iter=stdinIter()),n=[];for(let e=0;e<t;e+=1)n.push(i.next().value);return n};

(() => {
    const [ h, w ] = readMany(2).map(it => parseInt(it))
    const s = []
    const map = []

    for (let i = 0; i < h; i += 1) {
        const tmp = readMany(1)[0].split('')
        s.push(tmp)
        map.push([])
    }

    const get = (arr, i, j) => {
        const tmp = arr[i]
        if (tmp) {
            return tmp[j]
        } else {
            return void 0
        }
    }

    for (let i = 0; i < h; i += 1) {
        for (let j = 0; j < w; j += 1) {
            if (s[i][j] == '#') {
                map[i][j] = '#'
                continue
            }

            let boms = 0
            if (get(s, i - 1, j) == '#') boms += 1
            if (get(s, i - 1, j + 1) == '#') boms += 1
            if (get(s, i - 1, j - 1) == '#') boms += 1
            if (get(s, i, j) == '#') boms += 1
            if (get(s, i, j + 1) == '#') boms += 1
            if (get(s, i, j - 1) == '#') boms += 1
            if (get(s, i + 1, j) == '#') boms += 1
            if (get(s, i + 1, j + 1) == '#') boms += 1
            if (get(s, i + 1, j - 1) == '#') boms += 1

            map[i][j] = boms
        }
    }

    for (let i = 0; i < h; i += 1) {
        console.log(map[i].join(''))
    }
})()


Measured memory_bytes: 11468
void main()
{
    int[] path = new int[4];

    foreach (i; 0 .. 3)
    {
        int[] tmp = readln.split.to!(int[]);
        int a = tmp[0] - 1, b = tmp[1] - 1;
        ++path[a], ++path[b];
    }

    writeln(path.all!"a < 3" ? "YES" : "NO");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		boolean ok = true;


		if(S.charAt(2) != S.charAt(3)) ok = false;
		if(S.charAt(4) != S.charAt(5)) ok = false;

		if(ok) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}
}




Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define  show for(int j=0;j<v.size();j++) cout<<v[j]<<" ";
#define ld long double
#define e endl
#define bc __builtin_popcount
#define MOD 1000000007
#define INT_SIZE 32
#define me(x) memset(x,0,sizeof(x))
ll fast_expo(ll x,ll p)
{if(p==0) return 1;
else if(p%2==0){ ll t=fast_expo(x,p/2)%MOD;return (t*t)%MOD;} else return (x*(fast_expo(x,p-1))%MOD)%MOD;}
int main()
{
    string s;
    cin>>s;
    int l=s.size();
    for(int i=0;i<l;i++)
    {
        s[i]='x';
    }
    cout<<s;
}


Measured memory_bytes: 256
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().trim().split_whitespace()
        .map(|w| w.parse().ok().unwrap()).collect()
}

fn main() {
    let n = read::<usize>();
    let mut av = read_vec::<usize>();
    let mut bv = read_vec::<usize>();
    let mut cv = read_vec::<usize>();
    av.sort();
    bv.sort();
    cv.sort();
    let mut dv = vec![0;n];
    let mut c = 0;
    for i in 0..n {
        while c < n && bv[i] >= cv[c] {
            c += 1;
        }
        dv[i] = n - c;
    }
    for i in 0..n-1 {
        dv[n - i - 2] += dv[n - i - 1];
    }
    c = 0;
    let mut ans = 0;
    for i in 0..n {
        while c < n && av[i] >= bv[c] {
            c += 1;
        }
        if c == n {
            break;
        }
        ans += dv[c];
    }
    println!("{}",ans);
}


Measured memory_bytes: 13168
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<int,int>
#define poly vector<ll>
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
int n,k;
poly a[7];
poly inv(poly a){
	poly b(n);
	For(i,0,n-1)b[a[i]]=i;
	return b;
}
poly operator *(poly a,poly b){
	poly c(n);
	For(i,0,n-1)c[i]=a[b[i]];
	return c;
}
poly ksm(poly a,int b){
	poly ans(n); For(i,0,n-1)ans[i]=i;
	for(;b;b>>=1){
		if(b&1)ans=ans*a;
		a=a*a;
	}
	return ans;
}
int main(){
	n=read(),k=read();
	For(i,1,n)a[1].pb(read()-1);
	For(i,1,n)a[2].pb(read()-1);
	int t=k%6; if(!t)t=6;
	For(i,3,t)a[i]=a[i-1]*inv(a[i-2]);
	poly A=a[2]*inv(a[1])*inv(a[2])*a[1];
	a[t]=ksm(A,(k-t)/6)*a[t]*ksm(inv(A),(k-t)/6);
	for(auto i:a[t])wri(i+1);
}

Measured memory_bytes: 12496
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty |) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty | $n:expr) => {
        (0..$n).map(|_| get!($t |)).collect::<Vec<_>>()
    };
}

fn main() {
    let (N, M) = get!(usize, usize);
    let LRs = get!(isize, isize; M);
    let minR = LRs.iter().map(|&(_, R)| R).min().unwrap();
    let maxL = LRs.iter().map(|&(L, _)| L).max().unwrap();
    println!("{}", std::cmp::max(0, minR - maxL + 1));
}


Measured memory_bytes: 6396
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace 東京海上日動2020B
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = RLong;
            var v = RLong;
            var b = RLong;
            var w = RLong;
            var t = RLong;

            bool ans;
            if (a < b)
            {
                ans = (v - w) * t >= (b - a);
            }
            else
            {
                ans = (v - w) * t >= (a - b);
            }

            if (ans) Console.WriteLine("YES");
            else Console.WriteLine("NO");
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String RNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int RInt => int.Parse(RNext());
        public static long RLong => long.Parse(RNext());
        public static int[] RInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] RLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
        public static string RString => RNext();
        //以下未テスト
        public static int[] RIntsC(int c) => Enumerable.Repeat(0, c).Select(x => int.Parse(RNext())).ToArray();
        public static long[] RLongsC(int c) => Enumerable.Repeat(0, c).Select(x => long.Parse(RNext())).ToArray();
        public static char[][] RMap(int h) => Enumerable.Repeat(0, h).Select(x => Console.ReadLine().ToCharArray()).ToArray();
    }

    static class Debug
    {
        static public void Draw2D<T>(T[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            string[,] map2 = new string[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0.ToString();
                    else if (i == 0) map2[i, j] = (j - 1).ToString();
                    else if (j == 0) map2[i, j] = (i - 1).ToString();
                    else map2[i, j] = map[i - 1, j - 1].ToString();
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j].Last());
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D<T>(T[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 27776
N, T = map(int, input().split(" "))
inf = float('inf')

from operator import itemgetter
roots = [tuple(map(int, input().split(" "))) for i in range(N)]
roots = sorted(roots, key=itemgetter(1, 0))

def dfs(i, csum, tsum):
    if tsum + roots[i][1] <= T:
        return csum+roots[i][0] \
            if i + 1 == N else dfs(i + 1, csum+roots[i][0], tsum + roots[i][1])
    else:
        return inf if csum == 0 else csum

clist = [dfs(i, 0, 0) for i in range(N)]
ans = min(clist)

print('TLE' if ans == inf else ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	map<pair<int,string >,int>m1;
	int penaltis = 0;
	int ac = 0;
	while(m--){
		int x;
		string s;
		cin>>x>>s;
		if(s == "WA"){
			if(m1[{x,"AC"}] == 0)
				m1[{x,s}]++;
		}else{
			if(m1[{x,s}] == 0){
				ac++;
				penaltis += m1[{x,"WA"}];
				m1[{x,s}]  = 1;
			}
		}
	}
	cout<<ac<<" "<<penaltis<<endl;
	return 0;
}


Measured memory_bytes: 22200
S = input()
N = len(S)
flag = True
if S != S[::-1]:
    flag = False
SS = S[0:(N-1)//2]
if SS != SS[::-1]:
    flag = False
SS = S[(N+3)//2:-1]
if SS != SS[::-1]:
    flag = False
if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
import sys
import math
from itertools import combinations
n, d = [int(i) for i in sys.stdin.readline().split()]
xs = []
for i in range(n):
    xs.append([int(i) for i in sys.stdin.readline().split()])
cnt = 0
for (x, y) in combinations(xs, 2):
    if (math.sqrt(sum([(_x - _y)**2 for _x, _y in zip(x, y)])) % 1 == 0):
        cnt += 1
print(cnt)

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

int main()
{
  while(true){
    int n,p;
    scanf("%d%d",&n,&p);
    if(n==0&&p==0)break;
    int pebbles[MAX]={0,};
    int left=p;
    int now=0;
    int winner=-1;
    while(winner<0){
      if(left>0){
	--left;
	pebbles[now]++;
      }else{
	left+=pebbles[now];
	pebbles[now]=0;
      }
      now++;
      if(now==n)now=0;
      for(int i=0;i<MAX;++i){
	if(pebbles[i]==p){
	  winner=i;
	  break;
	}
      }
    }
    printf("%d\n",winner);
  }
  return 0;
}

Measured memory_bytes: 872
import java.util.Scanner;

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

		int x = sc.nextInt();
		int count = 0;
		int xc = 0;
		while (true) {
			count++;
			xc += x;
			if (xc % 360 == 0)
				break;
		}

		System.out.println(count);

	}

}


Measured memory_bytes: 35708
#include <stdio.h>
 
int main(void) {
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if((a<b)&&(b<c)){
		printf("Yes\n");
	}
 	else{
 		printf("No\n");
 	}
 return 0;
}

Measured memory_bytes: 580
from itertools import groupby
S = list(input())
Sl = len(S)
ans = [0]*Sl
RL = 0
count = -1
for _, v in groupby(S):
    x = list(v)
    xl = len(x)
    if RL == 0:
        count += xl
        if xl % 2 == 0:
            ans[count] += xl//2
            ans[count+1] += xl//2
        else:
            ans[count] += xl//2+1
            ans[count+1] += xl//2
        RL = 1
    else:
        if xl % 2 == 0:
            ans[count+1] += xl//2
            ans[count] += xl//2
        else:
            ans[count+1] += xl//2+1
            ans[count] += xl//2
        RL = 0
        count += xl
for i in ans:
    print(i, end=" ")


Measured memory_bytes: 11416
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		while(true) {
			int n=in.nextInt();
			if(n==0)break;
			List<Integer> A=new ArrayList<>();
			for(int i=0;i<n;i++)A.add(Integer.parseInt(in.next()));
			Collections.sort(A);
			int min=A.get(n-1);
			for(int i=0;i<n-1;i++)min=Math.min(min, A.get(i+1)-A.get(i));
			System.out.println(min);
		}
	}

}



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

ll   n, k;
bool ok(ll x) {
    if (x == 0)
        return 1;

    ll ttl = 0, ppl = k;
    while (x >= 1 && ttl <= n && ppl > 0) {
        ttl += x;
        x = (x / 2);
        ppl--;
    }

    return ttl <= n;
}

bool obj(ll x) { return !ok(x); }

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

    cin >> k >> n;

    // {
    //     ll x   = 0;
    //     ll ttl = 0;
    //     ll ppl = k;
    //     cin >> x;
    //     while (x > 1) {
    //         ttl += x;
    //         x = (x / 2) + (x % 2);
    //         ppl--;
    //     }
    //     ttl += ppl;
    //     cout << ttl << endl;
    // }

    {
        ll first = 0, last = n + 2, value = 1;
        ll it, count, step;
        count = last - first;
        while (count > 0) {
            it   = first;
            step = count / 2;
            it += step;
            if (obj(it) < value) {
                first = ++it;
                count -= step + 1;
            } else {
                count = step;
            }
        }
        cout << first - 1 << endl;
    }
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
int a[300];
int main()
{
	int n;
	cin>>n;
	int res=0;
	for(int i=0;i<n*2;i++)cin>>a[i];
	sort(a,a+n*2);
	for(int i=0;i<n*2;i+=2)res+=min(a[i],a[i+1]);
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;

int n, a[1005];

int main(){
	cin >> n;
	for(int i=0; i<2*n; i++) cin >> a[i];
	sort(a, a+2*n);
	int ret = 0;
	for(int i=0; i<2*n; i+=2){
		ret += a[i];
	}
	cout << ret << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
    cin>>n;int a[n],b[n];for(int i=0;i<n-1;i++)cin>>b[i];b[n-1]=b[n-2];
    for(int i=n-2;i>0;i--){
        a[i]=min(b[i],b[i-1]);
    }
    a[n-1]=b[n-1];a[0]=b[0];
    int sum=0;
    for(int i=0;i<n;i++){sum+=a[i];}
    cout<<sum<<endl;
    }



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

int x,y,ans;
int flag[10],osenbei[10][10000];

int count()
{
	int cnt,res=0;
	for(int i=0;i<x;i++)
	{
		cnt=0;
		for(int j=0;j<y;j++)
		{
			if(!flag[j]&&osenbei[j][i]||flag[j]&&!osenbei[j][i]) cnt++;//ある列における，現在の表の枚数
		}
		if(cnt<y-cnt) res+=y-cnt;//裏の方が多かった場合
		else res+=cnt;
	}
	return res;
}		

void dfs(int num)
{
	if(num==y)
	{
		int tmp=count();
		ans=max(ans,tmp);
		return;
	}

	flag[num]=0;
	dfs(num+1);

	flag[num]=1;
	dfs(num+1);

	return;
}

int main()
{
	while(cin>>y>>x&&y)
	{
		for(int i=0;i<y;i++)
		{
			for(int j=0;j<x;j++)
				cin>>osenbei[i][j];
		}

		dfs(0);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,l;
  cin>>n>>l;
  string s[n];
  string p1;
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
 	sort(s,s+n);
  for(int i=0;i<n;i++){
      p1+=s[i];
  }
  cout<<p1;
}

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

using namespace std;

int main() {
  int N, A, B, C;
  cin >> N >> A >> B >> C;

  vector<string> s(N + 1);
  for (int i = 0; i < N; i++) {
    cin >> s[i];
  }
  s[N] = "ABC";

  bool is_ok = true;
  vector<string> ans(N);

  for (int i = 0; i < N; i++) {
    if (s[i] == "AB") {
      if (A == 0 && B == 0) {
        is_ok = false;
        break;
      }
      if (A == 0) {
        ans[i] = "A";
        A++;
        B--;
      } else if (B == 0) {
        ans[i] = "B";
        A--;
        B++;
      } else {
        if (s[i + 1][0] == 'A' || s[i + 1][1] == 'A') {
          ans[i] = "A";
          A++;
          B--;
        } else {
          ans[i] = "B";
          A--;
          B++;
        }
      }
    }
    if (s[i] == "AC") {
      if (A == 0 && C == 0) {
        is_ok = false;
        break;
      }
      if (A == 0) {
        ans[i] = "A";
        A++;
        C--;
      } else if (C == 0) {
        ans[i] = "C";
        A--;
        C++;
      } else {
        if (s[i + 1][0] == 'A' || s[i + 1][1] == 'A') {
          ans[i] = "A";
          A++;
          C--;
        } else {
          ans[i] = "C";
          A--;
          C++;
        }
      }
    }
    if (s[i] == "BC") {
      if (B == 0 && C == 0) {
        is_ok = false;
        break;
      }
      if (B == 0) {
        ans[i] = "B";
        B++;
        C--;
      } else if (C == 0) {
        ans[i] = "C";
        B--;
        C++;
      } else {
        if (s[i + 1][0] == 'B' || s[i + 1][1] == 'B') {
          ans[i] = "B";
          B++;
          C--;
        } else {
          ans[i] = "C";
          B--;
          C++;
        }
      }
    }
  }
  cout << (is_ok ? "Yes" : "No") << "\n";
  if (is_ok) {
    for (int i = 0; i < N; i++) {
      cout << ans[i] << endl;
    }
  }

  return 0;
}

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

int n, m;
string s[510];

void dfs(int &ans, int tmp, int idx, vector<bool> is_odd){

    //cout << idx << endl;
    if(idx == n){
        int ok = true;
        for(int i = 0; i < m; i++){
            if(is_odd[i]){
                ok = false;
                break;
            }
        }

        if(ok) ans = max(ans, tmp);
        return;
    }

    //取らない
    dfs(ans, tmp, idx + 1, is_odd);

    //取る
    for(int i = 0; i < m; i++){
        if(s[idx][i] == '1') is_odd[i] = is_odd[i] ^ 1;
    }

    dfs(ans, tmp + 1, idx + 1, is_odd);

    return;
}

int main(){

    while(1){
        
        cin >> n >> m;
        if(!n) break;

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


        if(n < m){
            //深さ優先
            int ans = 0;
            vector<bool> is_odd(m, false);
            dfs(ans, 0, 0, is_odd);
            cout << ans << endl;
        }else{
            //dp
            vector<int> bit(n);
            for(int i = 0; i < n; i++){
                int tmp_bit = 0;
                for(int j = 0; j < m; j++){
                    if(s[i][j] == '1') tmp_bit = tmp_bit | (1 << j);
                }
                bit[i] = tmp_bit;
            }

            vector<vector<int> > dp(2, vector<int> ((1 << m), -1000000));
            dp[0][0] = 0;
            int now = 0;
            int next = 1;
            for(int i = 0; i < n; i++){
                
                for(int j = 0; j < (1 << m); j++) dp[next][j] = -10000;

                for(int j = 0; j < (1 << m); j++){

                    //取らない
                    dp[next][j] = max(dp[next][j], dp[now][j]);

                    //取る
                    int next_bit = j ^ bit[i];
                    //cout << i << " " << j << " " << next_bit << endl;
                    dp[next][next_bit] = max(dp[next][next_bit], dp[now][j] + 1);
                    
                }

                swap(now, next);
            }

            cout << dp[now][0] << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 52208
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			long[] a = new long[n], b = new long[n], sa = new long[n];
			for (int i = 0; i < n; i++) {
				a[i] = in.nextLong();
				b[i] = in.nextLong();
				sa[i] = (a[i]-b[i])%b[i];
				if (sa[i] > 0) {
					sa[i] -= b[i];
				}
			}

			long sum = 0;
			for (int i = n-1; i >= 0; i--) {
				sa[i] += sum;
				sa[i] %= b[i];
				if (sa[i] > 0) {
					sa[i] -= b[i];
				}
				sum += Math.abs(sa[i]);
			}

			out.println(sum);



		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

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

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 48360
# B
n = int(input())
s = [str(s) for s in input().split()]
l = ['P', 'W', 'G', 'Y']
ans = 0
for c in l:
    if s.count(c) > 0:
        ans += 1
if ans == 4:
    print('Four')
else:
    print('Three')

Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll n; cin>>n;
	vector<string> s(n);
	REP(i,n) cin>>s[i];
	sort(s.begin(),s.end());
	ll ans=0;
	REP(i,n){
		if(i==0){
			ans++;
		}else{
			if(s[i]!=s[i-1]){
				ans++;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

const int inf = 1000000007;

int T[102], V[20004], dp[20004][102];

int solve(int x, int y)
{
    if(y < 0 || y > V[x])
        return -inf;

    if(x == 0)
        return 0;

    if(dp[x][y] != -1)
        return dp[x][y];
    
    int ans = solve(x-1, y) + y * 4;
    ans = max(ans, solve(x-1, y-1) + (y-1) * 4 + 2);
    
    if(y != V[x])
    {
        ans = max(ans, solve(x-1, y+1) + y * 4 + 2);
        ans = max(ans, solve(x-1, y) + y * 4 + 1);
    }

    return dp[x][y] = ans;
}

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

    int N;
    cin >> N;

    for(int i=1; i<=N; i++)
        cin >> T[i];

    int k = 0;
    
    for(int i=1; i<=N; i++)
    {
        int v;
        cin >> v;

        while(T[i]--)
            V[++k] = v;
    }

    memset(dp, -1, sizeof(dp));

    cout << fixed << setprecision(6) << solve(k, 0) / 4.0 << "\n";
    return 0;
}


Measured memory_bytes: 9856
fun main(args: Array<String>) {
    val s = readLine()!!
    val N = s.length
    var r = 0
    val sum = Array(s.length){0}
    s.forEachIndexed { i, c ->
        if (c == 'R') r++
        else {
            sum[i] += r / 2
            sum[i-1] += r / 2 + r % 2
            r = 0
        }
    }
    var l = 0
    s.reversed().forEachIndexed { i, c ->
        if (c == 'L') l++
        else {
            sum[N - i - 1] += l / 2
            sum[N - 1 - (i-1)] += l / 2 + l % 2
            l = 0
        }
    }
    sum.forEach { c -> print(c.toString() + " ") }
}

Measured memory_bytes: 44304
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >


using namespace std;

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

const long double Pi=acos(-1),e=2.718;
const int N=2e3+10,mod=1e9+7;

int main ()
{
    FASTIO
    string s;
    cin >> s;
    if(s=="ABC")cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}
/**

*/


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


int main(){
    while(1){
	int n,k,m;
	cin>>n>>k>>m;
	if(n==0)break;
	vector<int> s;
	for(int i=1;i<=n;i++)s.push_back(i);
	for(int i=0;i<n-1;i++){
	    auto it = find( s.begin(),s.end(),m );
	    int cnt = it-s.begin() ;
	    cnt += k-1;
	    s.erase(it);
	    cnt %= s.size();
	    it = s.begin();
	    it += cnt;
	    m = *it;
	}
	cout<<m<<endl;
    }
    return 0;
}



Measured memory_bytes: 3244
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	string s;
	cin >> s;
	long long n = s.length(), ans = n * (n - 1) / 2, i, j, k;
	vector<long long> ct(26, 0);
	for (i = 0; i < n; i++) ans -= ct[s[i] - 'a']++;
	cout << ans + 1 << "\n";

	return 0;
}



Measured memory_bytes: 1144
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    int a, i;
    string s,s1, s2, ret;
    ret = "No";
    cin >> s1 >> s2;
    s = s1 + s2;
    a = stoi(s);
    int m = 1+(int)sqrt(a);
    for(i = 1; i <= m; i++){
        if(i * i == a){
            ret = "Yes";
            break;
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
import math
n, k = list(map(int, input().split()))
# n, k = map(int, input.split())
ans = 0
for n in range(1, n+1):
    # (cnt) = log_2(k/n)
    cnt = max(0, math.ceil(math.log2(k/n)))
    ans += (1/2) ** cnt

print( ans*(1/n) )

Measured memory_bytes: 3188
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

vector2<P> g;
vector<int> d;
vector<P> edge;
vector<bool> used;

void dfs1(int v, int p){
    if(used[v]){
        return;
    }
    used[v] = true;

    for(P pa : g[v]){
        int u = pa.first;
        int e = pa.second;
        if(u == p){
            continue;
        }
        if(used[u]){
            continue;
        }
        d[e] = 0;
        dfs1(u, v);
    }
}

void dfs2(int v, int p){
    if(used[v]){
        return;
    }
    used[v] = true;

    for(P pa : g[v]){
        int u = pa.first;
        if(u == p){
            continue;
        }
        if(used[u]){
            continue;
        }
        dfs2(u, v);
    }

    if(v == 0){
        return;
    }

    int cnt = 0;
    int ep;
    for(P pa : g[v]){
        int u = pa.first;
        int e = pa.second;
        if(u == p){
            ep = e;
        }
        if(d[e] == 1 && edge[e].first == v){
            cnt++;
        }
        if(d[e] == -1 && edge[e].second == v){
            cnt++;
        }
    }
    if(cnt % 2){
        if(edge[ep].first == v){
            d[ep] = 1;
        }else{
            d[ep] = -1;
        }
    }else{
        if(edge[ep].first == v){
            d[ep] = -1;
        }else{
            d[ep] = 1;
        }
    }
}

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

    int n, m;
    cin >> n >> m;

    if(m % 2){
        cout << -1 << endl;
        return 0;
    }

    g = initVec2<P>(n, 0);
    used = vector<bool>(n);
    edge = vector<P>(m);

    rep(i, m){
        int a, b;
        cin >> a >> b;
        if(a > b){
            swap(a, b);
        }
        a--;
        b--;
        g[a].emplace_back(b, i);
        g[b].emplace_back(a, i);
        edge[i] = {a, b};
    }

    d = vector<int>(m, INF);
    used = vector<bool>(n);
    dfs1(0, -1);
    rep(i, m){
        if(d[i] != 0){
            d[i] = 1;
        }
    }
    used = vector<bool>(n);
    dfs2(0, -1);

    rep(i, m){
        if(d[i] == 1){
            cout << edge[i].first + 1 << " " << edge[i].second + 1 << endl;
        }else{
            cout << edge[i].second + 1 << " " << edge[i].first + 1 << endl;
        }
    }


    return 0;
}


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

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

ll N;

deque<ll> prime_factors(ll n)
{
  deque<ll> result;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      result.push_back(i);
      n /= i;
    }
  }
  if (n != 1) result.push_back(n);
  return result;
}

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  deque<ll> primes = prime_factors(N);

  ll ans = INF;
  for (ll i = 1; i * i <= N; i++) {
    if (N % i != 0) continue;
    ll b = N / i;
    ans = min(ans, b - 1 + i - 1);
  }

  printf("%lld\n", ans);

  return 0;
}


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

int MOD=1000000007;
struct edge {
    int to, cost;
};

int modpow(int a,int x){
  if(a<0)a+=MOD;
  int ans=1;
  while(x>0){
    if(x&1) ans=ans*a%MOD;
      a=a*a%MOD;
      x>>=1;
  }
  return ans;
}

int gyaku(int n){
    return modpow(n,MOD-2);
}

auto factor(int n){
  map<int,int>res;
  for(int i=2;i*i<=n;i++){
      for(; n%i==0;n/=i) res[i]++;
  }
  if(n>1)res[n]++;
  return res;
}
////////////////////////////////////////////////////////////
signed main() {
  int n;
  cin>>n;
  vector<vector<int>>f(n,vector<int>(10));
rep(i,n){
  rep(j,10)cin>>f[i][j];
}
vector<vector<int>>p(n,vector<int>(11));
rep(i,n){
  rep(j,11)cin>>p[i][j];
}
int ans=-INF;
for(int bit=1;bit<(1<<10);bit++){

int t=0;

    rep(j,n){
          int kaburi=0;
      for(int i=0;i<10;i++){
      if(f[j][i]==1&&(bit&(1<<i)))kaburi++;
    }
    t+=p[j][kaburi];
  }
  ans=max(t,ans);
}
cout<<ans<<endl;
}


Measured memory_bytes: 3568
#include <stdio.h>

int main(void)
{
    int N=0;
    long int max=0,sum=0;
    long int array[200000];

    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%ld",&array[i]);
        if(max<array[i]){
            max=array[i];
            //printf("a");
        } else {
            sum+=max-array[i];
            //printf("b");
        }
    }

    printf("%ld",sum);
    return 0;
}


Measured memory_bytes: 3268
n,q = map(int,input().split())
a = []
for i in range(n):
  a.append(list(input().split()))
  a[i][1] = int(a[i][1])
time = 0
while a:
  if a[0][1] > q:
    time += q
    a[0][1] -= q
    a.append([a[0][0],a[0][1]])
    del a[0]
  else:
    time += a[0][1]
    print(a[0][0] + ' ' + str(time))
    del a[0]


Measured memory_bytes: 14032
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input()) # n=1
def inpm(): return map(int,input().split()) # x=1,y=2
def inpl(): return list(map(int, input().split())) # a=[1,2,3,4,5,...,n]
def inpls(): return list(input().split())  # a=['1','2','3',...,'n']
def inplm(n): return list(int(input()) for _ in range(n)) # x=[] 複数行
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return sorted([list(map(int, input().split())) for _ in range(n)]) # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 
def graph():
    n=inp()
    g=[[] for _ in range(n)]
    for i in range(n):
        a = inp()
        a -= 1
        g[i].append(a)
        g[a].append(i)
    return n,g

def main():
    h = inp()
    x = []
    while h>0:
        x.append(h%2)
        h //= 2
    s = sum(x)
    n = len(x)
    for i in range(n):
        if x[i] > 0:
            x[i] = s
            s -= 1
        else:
            x[i] = s
    ans = 0
    for i in range(n):
        ans += pow(2,i)
    print(ans)
    
if __name__ == "__main__":
    main()




Measured memory_bytes: 39020
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define INF 1LL << 60;
#define LLINF 1e12
#define PI 3.14159265359
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
int ny, nx;
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll m, ll n)
{
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n);
}

ll llpow(ll x, ll y)
{
    ll ans = 1;
    REP(i, y)
    ans *= x;
    return ans;
}

ll llmin(ll x, ll y) { return x < y ? x : y; }
ll llmax(ll x, ll y) { return x > y ? x : y; }

template <typename Container>
bool exist_in(const Container &c, const typename Container::value_type &v)
{
    return (c.end() != std::find(c.begin(), c.end(), v));
}

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

//std::cout << std::defaultfloat << std::setprecision(10);
////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    string S; cin >> S;

    REP(i, S.size()-1){
        if(S[i]=='A' and S[i+1]=='C'){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
string YES[2] = {"NO", "YES"};
string yes[2] = {"No", "Yes"};

int main(){
    ll n, k;    cin >> n >> k;
    vector<pair<ll, ll>> seg(k);
    ll md = 998244353;
    vector<ll> csum(n+2, 0);
    set<pair<ll, ll>> key;
    rep(i, k){
        ll a, b;    cin >> a >> b;
        //a--, b--;
        seg[i] = {a, b};
        csum[a] += 1;
        csum[b+1] -= 1;
        key.insert({a, b+1});
    }
    
    // rep(i, n+2){
    //     csum[i+1] += csum[i];
    //     if(0<csum[i+1]) key.insert(i+1);
    // }
    // rep(i, n+1) cout << csum[i+1] << ' ';
    // cout << endl;
    vector<ll> dp(n+2, 0);
    dp[1] = 1;
    FOR(i, 1, n){
        //cout << i << endl;
        for(auto x: key){
            ll a=min(i+x.first, n+1), b=min(i+x.second, n+1);
            dp[a] += dp[i];
            dp[b] -= dp[i];
            dp[a] = (dp[a]+md)%md;
            dp[b] = (dp[b]+md)%md;
            // rep(i, n+1) cout << dp[i+1] << ' ';
            // cout << endl;
        }
        if(i<n-1) dp[i+1] += dp[i];
        dp[i+1] %= md;
    }
    // rep(i, n+1) cout << dp[i+1] << ' ';
    // cout << endl;
    // rep(i, n) dp[i+1] = (dp[i]+dp[i+1])%md;
    // rep(i, n+1) cout << dp[i+1] << ' ';
    // cout << endl;

    cout << dp[n] << endl;
}


Measured memory_bytes: 6424
import java.util.Arrays;
import java.util.Scanner;

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

        for (int i = 0; i < n; i++) {
            String city = sc.next();
            int point = sc.nextInt();
            sp[i] = city + "_" + (1100 - point) + "_" + (i+1);
        }

        Arrays.sort(sp);
        for (String s: sp) {
            String ans = s.split("_")[2];
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 21332
#include<iostream>
using namespace std;
int main(){
  long long L,R; cin >> L >> R;
  if(R-L>=2019){
    cout << 0 << endl;
    return 0;
  }
  int ans=2019;
  for(long long i=L;i<R;++i){
    for(long long j=i+1;j<=R;++j){
      if((i*j)%2019 < ans) ans = (i*j)%2019;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N = gets.to_i
A = gets.split.map(&:to_i)

if A.include?(0)
  puts 0
else
  ans = 1
  flg = true
  A.each do |a|
    ans *= a

    if ans > 10**18
      flg = false
      break
    end
  end

  flg ? puts(ans) : puts(-1)
end


Measured memory_bytes: 21524
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int A[N];
  int maxa = 0;
  int maxN = 0;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    if(maxa < A[i]) {
      maxa = A[i];
      maxN = i;
    }
  }
  sort(A, A + N, greater<int>());
  
  if(A[0] == A[1]) {
    for(int i = 0; i < N; i++) {
      cout << A[0] << endl;
    }
  }
  else {
    for(int i = 0; i < N; i++) {
      if(i != maxN) {
        cout << A[0] << endl;
      }
      else {
        cout << A[1] << endl;
      }
    }
  }
}

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

namespace ABC_Training
{

    class Program
    {
        static void Main(string[] args)
        {
            var Weather = Console.ReadLine();
            Console.WriteLine(WeatherPrediction.GetNextWeather(Weather));
        }
    }
    public static class WeatherPrediction
    {
        public static string GetNextWeather(string s)
        {
            if (s == "Sunny")
            {
                return "Cloudy";
            }
            if(s== "Cloudy")
            {
                return "Rainy";
            }
            return "Sunny";
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
using namespace std;
int main() {
	int n;
	int T;
	int c[1000];
	int t[1000];
	int i;
	int a = 1000000;
	cin >> n >> T;
	for (i = 0; i < n; i++)cin >> c[i] >> t[i];
	for (i = 0; i < n; i++) {
		if (t[i] <= T && c[i] < a)a = c[i];
	}
	if (a == 1000000)cout << "TLE";
	else cout << a;
	return 0;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		
		long[] sum = new long[10];
		sum[0] = (H-2)*(W-2);
		HashSet<long> Hs = new HashSet<long>();
		for(int i=0;i<N;i++){
			
			for(int rc=-2;rc<=0;rc++){
				if(!InRange(rc+A[i],1,H))continue;
				if(!InRange(rc+A[i]+2,1,H))continue;
				for(int cc=-2;cc<=0;cc++){
					if(!InRange(cc+B[i],1,W))continue;
					if(!InRange(cc+B[i]+2,1,W))continue;
					
					long br = A[i] + rc;
					long bc = B[i] + cc;
					int cnt = 1;
					for(int ii=0;ii<3;ii++){
						for(int jj=0;jj<3;jj++){
							if(br+ii == A[i] && bc+jj == B[i])continue;
							if(Hs.Contains(enc(br+ii,bc+jj)))cnt++;
						}
					}
					sum[cnt]++;
					sum[cnt-1]--;
				}
			}
			Hs.Add(enc(A[i],B[i]));
		}
		
		for(int i=0;i<10;i++){
			Console.WriteLine(sum[i]);
		}
		
	}
	long H;
	long W;
	int N;
	long[] A,B;
	
	bool InRange(long n,long l,long u){
		return l <= n && n <= u ;
	}
	
	long enc(long r,long c){ return (r*1000000200L)+c ;}
	long decR(long s){ return s/1000000200L;}
	long decC(long s){ return s%1000000200L;}
	
	public Sol(){
		var d = ria();
		H = d[0]; W = d[1]; N = d[2];
		A = new long[N];
		B = new long[N];
		for(int i=0;i<N;i++){
			var dd = rla();
			A[i] = dd[0];
			B[i] = dd[1];
		}
	}
	
	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

int main()
{
  int n, m;
  char c;
  
  cin >> n;
  while (1){
    cin >> c;
    if (c == '='){
      cout << n << endl;
      break;
    }

    if (c == '+'){
      cin >> m;
      n += m;
    }
    if (c == '-'){
      cin >> m;
      n -= m;
    }
    if (c == '*'){
      cin >> m;
      n *= m;
    }
    if (c == '/'){
      cin >> m;
      n /= m;
    }
  }

  return 0;
}

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

int main() { 
  int n, v;
  cin >> n;
  map<int, int> mp1, mp2;
  for(int i = 0; i < n; ++i) {
    cin >> v;
    if(i%2 == 0) {
      /* 偶数番目 */
      mp1[v]++;
    } else {
      /* 奇数番目 */
      mp2[v]++;
    }
  }

  pair<int, int> mp1_1 = {0, 0}, mp1_2 = {0, 0}, mp2_1 = {0, 0}, mp2_2 = {0, 0}; // _1:最頻値, _2:2番目に多い値
  for(auto iter = begin(mp1); iter != end(mp1); iter++) {
    int key = iter->first, cnt = iter->second;
    if(cnt > mp1_1.second) {
      mp1_2 = mp1_1;
      mp1_1 = make_pair(key, cnt);
    } else {
      if(cnt > mp1_2.second) {
        mp1_2 = make_pair(key, cnt);
      }
    }
  }
  for(auto iter = begin(mp2); iter != end(mp2); iter++) {
    int key = iter->first, cnt = iter->second;
    if(cnt > mp2_1.second) {
      mp2_2 = mp2_1;
      mp2_1 = make_pair(key, cnt);
    } else {
      if(cnt > mp2_2.second) {
        mp2_2 = make_pair(key, cnt);
      }
    }
  }
  long long int ans = 0;
  if(mp1_1.first != mp2_1.first) {
    ans = n - mp1_1.second - mp2_1.second;
  } else {
    long long int mp12 = mp1_1.second + mp2_2.second, mp21 = mp1_2.second + mp2_1.second;
    if(mp12 > mp21) {
      ans = n - mp12;
    } else {
      ans = n - mp21;
    }
  }
  cout << ans << '\n';
}


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

using namespace std;

int main()
{
  int n;
  cin>>n;
  
  int a[n+5];
  
  for(int i=1;i<=n;i++)cin>>a[i];
  
  int cnt=0;
  
  for(int i=1;i<=n;i++)
  {
    if(a[i]!=i)cnt++;
  }
  if(cnt<=2)
    cout<<"YES"<<'\n';
  else
    cout<<"NO"<<'\n';
  
 return 0; 	
}

Measured memory_bytes: 256
s = input()
lst_s = ["0", "0"]
lst_s.extend(list(s))
min_comparsion = 9999999999
for i in range(len(lst_s) - 2):
    check_num = int(lst_s[i]) * 100 + int(lst_s[i + 1]) * 10 + int(lst_s[i + 2])
    comparsion = check_num - 753
    if 0 <= comparsion:
        if comparsion < min_comparsion:
            min_comparsion = comparsion
    else:
        comparsion = comparsion * - 1
        if comparsion < min_comparsion:
            min_comparsion = comparsion

print(min_comparsion)

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

using namespace std;

typedef long long ll;

#define newline cout<<"\n"
#define deb(x) cout<<#x<<" "<<x<<endl;

template<typename... T>
void read(T&... args){
    ((cin>>args), ...);
}

template<typename... T>
void write(T... args){
    ((cout<<args<<" "), ...);
}

void printarr(vector<int> &v){
    for(int x: v){
        cout<<x<<" ";
    }
    newline;
}

const int MOD = 1e9+7;
const int nax = 1e7+7;

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    
    string s; cin>>s;

    stack<char> st;

    int ans = 0;

    for(char c: s){
        if(st.empty() || st.top()==c){
            st.push(c);
        }
        else{
            st.pop();
            ans += 2;
        }
    }

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

Measured memory_bytes: 3780
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def main():
    n, x, t = [int(i) for i in input().split()]
    ans = n // x
    if n % x > 0:
        ans += 1
    print(t * ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 61692
mod = int(1e9 + 7)
h, w = map(int, input().split())
MAP = ['#' * (w + 1)] + ['#' + input() for _ in range(h)]
dp = [[0] * (w + 1) for _ in range(h + 1)]
dp[0][1] = 1
for i in range(1, h + 1):
    for j in range(1, w + 1):
        if MAP[i][j] == '.':
            dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % mod
print(dp[h][w])


Measured memory_bytes: 43620
#include<cstdio>
#include<cstring>
using namespace std;
int main(){
  int n;
  char s[6];
  scanf("%s",s);
  n=strlen(s);
  for(int i=0;i<n-1;i++)
    if(s[i]=='A'&&s[i+1]=='C'){
      printf("Yes\n");
      return 0;
    }
  printf("No\n");
}

Measured memory_bytes: 128