akhauriyash/Code-Regression huggingface dataset:
s = gets.chomp.split('')

if s.uniq.length == 1
    puts("No")
else
    a = s.slice!(0)
    if s.include?(a)
        s.slice!(s.index(a))
        if s.uniq.length == 1
            puts("Yes")
        else
            puts("No")
        end
    else
        puts("No")
    end
end

Measured memory_bytes: 1788
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
ll n, k;
int d;
bool ds[11];

bool check(int p){
	string str = to_string(p);
	
	bool ans = true;
	for(ll i  = 0; i < str.size(); i++){
		if(ds[(int)(str[i]-'0')]){ans = false;}
	}
	
	return ans;
}

int main(){
	cin >> n >> k;
	memset(ds, 0, sizeof(ds));
	for(ll j = 1; j <= k; j++){
		cin >> d;
		ds[d] = true;
	}
	
	for(ll i = n;; i++){
		if(check(i)){
			cout << i << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import numpy as np


def solve(n, s_list):
    return np.unique(s_list).shape[0]


def main():
    n = int(input())
    s_list = [input() for _ in range(n)]
    res = solve(n, s_list)
    print(res)


def test():
    assert solve(3, ["apple", "orange", "apple"]) == 2
    assert solve(5, ["grape", "grape", "grape", "grape", "grape"]) == 1
    assert solve(4, ["aaaa", "a", "aaa", "aa"]) == 4


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 74392
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
//typedef pair<int, P> PP;
const int mod = 1000000007;
typedef pair<P, P> PP;

int w, h, c[4];
int s[50][50], d[50][50][4];
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

bool In(int x, int y) { return 0 <= x && x < h && 0 <= y && y < w; }
void solve()
{
    priority_queue<PP, vector<PP>, greater<PP>> que;
    for (int i = 0; i < 50; i++)
        for (int j = 0; j < 50; j++)
            for (int k = 0; k < 4; k++)
                d[i][j][k] = INF;
    d[0][0][0] = 0;
    que.push(PP(P(0, 0), P(0, 0)));
    while (!que.empty())
    {
        PP p = que.top();
        que.pop();
        int v = p.first.second;
        int cost = p.first.first;
        int x = p.second.first;
        int y = p.second.second;
        if (d[x][y][v] < cost)
            continue;
        if (x == h - 1 && y == w - 1)
            continue;
        rep(i, 4)
        {
            int nx = x + dx[(v + i) % 4];
            int ny = y + dy[(v + i) % 4];
            int nv = (v + i) % 4;
            if (!In(nx, ny))
                continue;
            int ncost = cost;
            if (s[x][y] != i)
                ncost += c[i];
            if (d[nx][ny][nv] > ncost)
            {
                d[nx][ny][nv] = ncost;
                que.push(PP(P(ncost, nv), P(nx, ny)));
            }
        }
    }
}

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

    while (1)
    {
        cin >> w >> h;
        if (w == 0)
            break;
        rep(i, h) rep(j, w) cin >> s[i][j];
        cin >> c[0] >> c[1] >> c[2] >> c[3];
        solve();
        int ans = INF;
        rep(i, 4) ans = min(ans, d[h - 1][w - 1][i]);
        cout << ans << endl;
    }
}


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

const int maxn = 107;

int n, l[maxn], yes = 1;
char s[maxn][20];

int main() {
	cin >> n;
	for(int i = 1;i <= n;i++) {
		cin >> s[i] + 1, l[i] = strlen(s[i] + 1);
		if(i == 1) continue;
		if(s[i - 1][l[i - 1]] != s[i][1]) yes = 0;
		for(int j = 1;j < i;j++) {
			if(strcmp(s[i] + 1, s[j] + 1) == 0) yes = 0;
		}
	}
	if(yes) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#[allow(dead_code)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(dead_code)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        h: usize,
        n: usize,
        aa: [usize; n]
    }
    let dmg = aa.into_iter().fold(0, |sum, a| sum + a);

    if h <= dmg {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,s,n) for(int i=s; i<n; i++)
#define ALL(x) x.begin(), x.end()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;

struct Team {
	int id;
	int corr;
	ll pen;
};

bool operator<(const Team& lhs, const Team& rhs) {
	if( lhs.corr == rhs.corr ) {
		if( lhs.pen == rhs.pen ) {
			return lhs.id < rhs.id;
		}
		return lhs.pen < rhs.pen;
	}
	return lhs.corr > rhs.corr;
}

int main() {
	int T, P, R;
	while(cin >> T >> P >> R, T) {
		int wrong[51][11] = {};
		vector<Team> team(T);
		rep(i, T) {
			team[i].id = i+1;
		}
		rep(i, R) {
			int t, p, ti;
			string m;
			cin >> t >> p >> ti >> m;
			if( m == "CORRECT" ) {
				team[t-1].corr++;
				team[t-1].pen += 1200 * wrong[t][p] + ti;
			} else {
				wrong[t][p]++;
			}
		}
		sort( team.begin(), team.end() );
		rep(i, T) {
			cout << team[i].id << " " << team[i].corr << " " << team[i].pen << endl;
		}
	}
	return 0;
}

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

using namespace std;

int main() {
	unsigned long long a;
	string b;
	cin >> a >> b;
	
	auto f = b.find('.');
	b.erase(f, 1);
	
	unsigned long long c = atoi(b.c_str());
	cout << (a * c / 100) << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    string S;
    cin >> N >> S;

    int x = 0;
    int maximum = 0;

    for (int i = 0; i < N; i++){
        if(S[i] == 'I'){
            x++;
        }
        else {
            x--;
        }
        maximum = max(x, maximum);
    }
    cout << maximum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
#include <string.h>

#define rep(i,a,n) for(ll int (i) = (a);(i) < (n);(i)++)
#define urep(i,a,n) for(ll int (i) = (a);(i) > (n);(i)--)
#define MOD 1000000007
#define ll long long

using namespace::std;

int jo(ll int jxo, ll int jyo){
	ll int jhogeo = 1;
	rep(jinto,0,jyo) jhogeo=jhogeo*jxo;
	return jhogeo;
}
char tobig(char toxbig){
  return (toxbig-0x20);
}
char tolow(char toxlow){
  return (toxlow+0x20);
}
  


int main(){
  int a,b;
  cin>>a>>b;
  vector<int> s(3);
  s[0]=a+b;
  s[1]=a-b;
  s[2]=a*b;
  sort(s.begin(),s.end());
  cout<<s[2];
}
// int *p = new int[N];

//  vector<int> 変数名(要素数);
//  sort(変数名.begin(),変数名.end());//昇順ソート

// vector<vector<int>> 変数名(左の個数, vector<int>(右の個数));

//


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll max3(ll a,ll b,ll c){ return max( max(a,b),c ); }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

const int N = 3005;
ll dp[N][N];
ll a[N];

ll solve(int st,int en)
{
    if(st>en) return 0;
    if(st==en){ dp[st][en] = a[st]; return a[st]; }
    if(dp[st][en]>-3e9) return dp[st][en];
    dp[st][en] = max( a[st] - solve(st+1,en) , a[en] - solve(st,en-1) );
    return dp[st][en];
}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; cin>>n;
	forn(i,n) cin>>a[i];
	forn(i,N) forn(j,N) dp[i][j] = -3e9;
	cout<<solve(0,n-1);
	
	return 0;
}


Measured memory_bytes: 70912
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, K = MAP()
xy = [LIST() for _ in range(N)]

ans = INF
for (ax, ay), (bx, by) in combinations(xy, 2):
	edge_left = min(ax, bx)
	edge_right = max(ax, bx)
	edge_top = max(ay, by)
	edge_bottom = min(ay, by)
	cnt = 0
	for cx, cy in xy:
		if cx == ax or cx == bx:
			continue
		elif edge_left <= cx <= edge_right and edge_bottom <= cy <= edge_top:
			cnt += 1
	if K <= cnt+2:
		ans = min((edge_right-edge_left)*(edge_top-edge_bottom), ans)

for (ax, ay), (bx, by), (cx, cy) in combinations(xy, 3):
	edge_left = min(ax, bx, cx)
	edge_right = max(ax, bx, cx)
	edge_top = max(ay, by, cy)
	edge_bottom = min(ay, by, cy)
	cnt = 0
	for dx, dy in xy:
		if dx == ax or dx == bx or dx == cx:
			continue
		elif edge_left <= dx <= edge_right and edge_bottom <= dy <= edge_top:
			cnt += 1
	if K <= cnt+3:
		ans = min((edge_right-edge_left)*(edge_top-edge_bottom), ans)

for (ax, ay), (bx, by), (cx, cy), (dx, dy) in combinations(xy, 4):
	edge_left = min(ax, bx, cx, dx)
	edge_right = max(ax, bx, cx, dx)
	edge_top = max(ay, by, cy, dy)
	edge_bottom = min(ay, by, cy, dy)
	cnt = 0
	for ex, ey in xy:
		if ex == ax or ex == bx or ex == cx or ex == dx:
			continue
		elif edge_left <= ex <= edge_right and edge_bottom <= ey <= edge_top:
			cnt += 1
	if K <= cnt+4:
		ans = min((edge_right-edge_left)*(edge_top-edge_bottom), ans)

print(ans)

Measured memory_bytes: 87236
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		String StringA = String.valueOf(a);
		String StringB = String.valueOf(b);
		String StringC = String.valueOf(c);
		
		if (a >= b && a >= c) {
			if (b  >= c) {
				System.out.println(Integer.parseInt(StringA + StringB)+ c);
			} else  {
				System.out.println(Integer.parseInt(StringA + StringC)+ b);
			}
		} else if (b>=a && b >= c){
			if (a>=c) {
				System.out.println(Integer.parseInt(StringB + StringA) + c);
			} else {
				System.out.println(Integer.parseInt(StringB + StringC)+a);	
			}
		} else {
			if(a>= b) {
				System.out.println(Integer.parseInt(StringC + StringA)+b);
			} else {
				System.out.println(Integer.parseInt(StringC + StringB)+a);
			}
		}

	}
}


Measured memory_bytes: 23124
#![allow(non_snake_case)]

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let mut dp:Vec<Vec<Vec<f64>>> = vec![vec![vec![-1 as f64;301];301];301];
    let N:usize = sc.read();
    let A:Vec<usize> = sc.vec(N);
    let mut count:Vec<usize> = vec![0;4];
    for a in A{
        count[a] += 1;
    }
    println!("{}", memodp(&mut dp, count[1], count[2], count[3], N));


}

fn memodp(dp:&mut Vec<Vec<Vec<f64>>>, i:usize, j:usize, k:usize, N:usize) -> f64{
    if dp[i][j][k] >= 0.0{
        return dp[i][j][k]
    }
    if (i == 0) && (j == 0) && (k == 0){
        return 0f64
    }
    let mut res = N as f64;
    if i > 0{
        res += memodp(dp,i-1,j,k,N)*(i as f64)
    }
    if j > 0{
        res += memodp(dp,i+1,j-1,k,N)*(j as f64)
    }
    if k > 0{
        res += memodp(dp,i,j+1,k-1,N)*(k as f64)
    }
    dp[i][j][k] = res/((i+j+k) as f64);
    dp[i][j][k]
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
        .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 237820
#include <stdio.h>

int main(void)
{
    int n, m;

    while (scanf("%d %d", &n, &m), n != 0){
        int bucket[1024] = {-1};
        int i;
        int flag = 0;

        while (n-- > 0){
            for (i = 1; i <= m; i++){
                int t;

                scanf("%d", &t);
                bucket[i] += t;
            }
        }
        for (i = 1; i <= m; i++){
            int maxi = 0;
            int j;

            for (j = 1; j <= m; j++){
                if (bucket[maxi] < bucket[j]) maxi = j;
            }
            if (flag == 0){
                printf("%d", maxi);
                flag = 1;
            }
            else {
                printf(" %d", maxi);
            }
            bucket[maxi] = -1;
        }
        puts("");
    }

    return 0;
}

Measured memory_bytes: 616
n = int(input())
A = [int(i) for i in input().split(" ")]

pref = [0]

for i in range(1,n+1):
    pref.append(pref[i-1] + A[i-1])

lt = 1
rt = 3
ans = 10**18
for i in range(2,n):
    while lt+1<i and abs(pref[i] - pref[lt+1] - pref[lt+1]) < abs(pref[i] - pref[lt] - pref[lt]):
        lt+=1
    
    while rt>=i and rt<n and (abs(pref[n] - pref[rt+1] - pref[rt+1] + pref[i]) < abs(pref[n] - pref[rt] - pref[rt] + pref[i])):
        rt+=1
    #print(i)
    ans = min(ans, abs(max(pref[lt], pref[i]-pref[lt], pref[rt]-pref[i], pref[n]-pref[rt]) - min(pref[lt], pref[i]-pref[lt], pref[rt]-pref[i], pref[n]-pref[rt])))

print(ans)


Measured memory_bytes: 24684
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int A[] = new int[N];
    for (int i = 0; i < N; i++){
      A[i] = Integer.parseInt(sc.next());
    }

    int L[] = new int[N];
    int R[] = new int[N];
    L[0] = A[0];
    for (int i = 1; i < N; i++){
      L[i] = gcd(L[i-1], A[i]);
    }
    R[N-1] = A[N-1];
    for (int i = N-2; i > 0; i--){
      R[i] = gcd(R[i+1], A[i]);
    }
    int ans = Math.max(R[1], L[N-2]);
    for (int i = 1; i <= N-2; i++){
      ans = Math.max(ans, gcd(L[i-1], R[i+1]));
    }
    System.out.println(ans);
  }

  static int gcd(int a, int b){
    int tmp;
    if (a < b){
      tmp = a;
      a = b;
      b = tmp;
    }
    while (true) {
      tmp = a % b;
      if (tmp == 0) {
        return b;
      }
      a = b;
      b = tmp;
    }
  }
}


Measured memory_bytes: 48816
import sys

sys.setrecursionlimit(4100000)

H,W = map(int,input().split(' '))
sx,sy = 0,0
move_list = [ list(input()) for _ in range(H) ]
possible_list = [ [-1 for _ in range(W) ] for _ in range(H) ]
possible_list[sx][sy] = 0

x_start_list = [sx]
y_start_list = [sy]

def bfs(target_list,possible_list,x_queue,y_queue,cnt=0):
    x_list = [1,-1,0,0,]
    y_list = [0,0,1,-1]
    cnt += 1
    next_x_queue = []
    next_y_queue = []

    for i in range(4):
        for j in range(len(x_queue)):
            dx = x_queue[j] + x_list[i]
            dy = y_queue[j] + y_list[i]
            if dx < 0 or H <= dx or dy < 0 or W <= dy:
                continue
            if target_list[dx][dy] == '#':
                continue
            if possible_list[dx][dy] != -1:
                continue
            possible_list[dx][dy] = cnt
            next_x_queue.append(dx)
            next_y_queue.append(dy)
    if len(next_x_queue) > 0:
        bfs(target_list,possible_list,next_x_queue,next_y_queue,cnt)
    else:
        return

bfs(move_list,possible_list,x_start_list,y_start_list)

cnt_all_panel = 0
for row in move_list:
    for val in row:
        if val == '.':
            cnt_all_panel += 1
if possible_list[H-1][W-1] == -1:
    print(-1)
else:
    print(cnt_all_panel - possible_list[H-1][W-1] -1)


Measured memory_bytes: 3316
n=int(input())
h=list(map(int,input().split()))
ans=0
i=0
while i<=n-2:
    ans_s=0
    j=i
    while h[j]>=h[j+1]:
        ans_s+=1
        j+=1
        if j>=n-1:
            break
    if ans_s>ans:
        ans=ans_s
    i+=(ans_s+1)
    #print(ans_s) 
print(ans)

Measured memory_bytes: 15020
#include<cstdio>
#include<cstdlib>
#include<utility>
#include<vector>
#include<set>
using namespace std;
int N,W,D,p,s;
typedef pair<int,int>P;
vector<P>C;
multiset<int>S;
int main()
{
	for(;scanf("%d%d%d",&N,&W,&D),W;)
	{
		C.clear();
		S.clear();
		C.push_back(make_pair(W,D));
		for(int i=0;i<N;i++)
		{
			scanf("%d%d",&p,&s);
			vector<P>::iterator I=C.begin();
			for(int j=1;j<p;j++)
				I++;
			P tmp=*I;
			I=C.erase(I);
			int pos=s%(tmp.first+tmp.second);
			if(pos<tmp.first)
			{
				int n=tmp.first/2<pos?tmp.first-pos:pos;
				C.push_back(make_pair(n,tmp.second));
				C.push_back(make_pair(tmp.first-n,tmp.second));
			}
			else
			{
				pos-=tmp.first;
				int n=tmp.second/2<pos?tmp.second-pos:pos;
				C.push_back(make_pair(tmp.first,n));
				C.push_back(make_pair(tmp.first,tmp.second-n));
			}
		}
		
		for(vector<P>::iterator I=C.begin();I!=C.end();I++)
			S.insert(I->first*I->second);
		for(multiset<int>::iterator I=S.begin();I!=S.end();I++)
			printf("%s%d",I!=S.begin()?" ":"",*I);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 1048
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <sstream>
#include <map>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

int main() {
  int H, W, N;
  while (scanf("%d%d%d", &H, &W, &N) != EOF) {
    map<pair<int, int>, int> mp, tocheck;
    for (int i : range(N)) {
      int a, b;
      scanf("%d%d", &a, &b);
      a--;
      b--;
      mp[{a, b}] = 1;

      for (int i : range(-1, 1+1))
      for (int j : range(-1, 1+1)) {
        int p = a + i, q = b + j;
        if (p < 1 || q < 1 || p >= H - 1 || q >= W - 1) continue;
        tocheck[{p, q}] = 1;
      }
    }

    vector<ll> res(10);
    for (auto& pp : tocheck) {
      int a = pp.first.first;
      int b = pp.first.second;

      int cnt = 0;
      for (int i : range(-1, 1+1))
      for (int j : range(-1, 1+1)) {
        int p = a + i, q = b + j;
        if (p < 0 || q < 0 || p >= H || q >= W) continue;
        cnt += mp[{p, q}];
      }
      res[cnt]++;
    }

    res[0] = (ll)(H - 2) * (W - 2) - accumulate(res.begin() + 1, res.end(), 0LL);
    for (int i : range(10)) {
      printf("%lld\n", res[i]);
    }
  }
}


Measured memory_bytes: 212736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

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; }

int main() {
  ll n;
  cin >> n;
  ll ans = 0;
  REP(i, n) {
    ll a;
    cin >> a;
    ans = gcd(a, ans);
  }
  cout << ans << endl;
}

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

    }
    else {printf("No\n");}
    return 0;
}



Measured memory_bytes: 2108
#include <cstdio>
#include <climits>
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
#include <cstdlib>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
const double pi = acos(-1);
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define EPS 1e-4
// bool operator<(const pair<int, int> &a, const pair<int, int> &b)
// {
//     if (a.first == b.first)
//         return a.second < b.second;
//     return a.first < b.first;
// };

/*unsigned int xor128(void)
{
    static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned int t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
unsigned int xor128rnd(unsigned int m)
{
    return xor128() % m;
}*/

bool operator<(const pair<ll, ll> &a, const pair<ll, ll> &b)
{

    if (a.first == b.first)
        return a.second < b.second;

    return a.first < b.first;
}
int arr[110];
ll dp[110][100010];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);
    int N, K;
    cin >> N >> K;

    for (int i = 0; i < N; ++i)
    {
        cin >> arr[i];
    }
    for (int i = 0; i <= N; ++i)
    {
        dp[i][0] = 1;
    }

    for (int i = 0; i < N; ++i)
    {
        for (int j = 1; j <= K; ++j)
        {
            if (j - 1 - arr[i] >= 0)
            {
                dp[i + 1][j] = (dp[i + 1][j - 1] + dp[i][j] - dp[i][j - 1 - arr[i]] + MOD) % MOD;
            }
            else
            {
                dp[i + 1][j] = (dp[i + 1][j - 1] + dp[i][j]) % MOD;
            }
        }
    }
    cout << dp[N][K] << endl;
    return 0;
}


Measured memory_bytes: 79360
class _in{struct my_iterator{int it;const bool rev;explicit constexpr my_iterator(int it_, bool rev=false):it(it_),rev(rev){}constexpr int operator*(){return it;}constexpr bool operator!=(my_iterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const my_iterator i,n;public:explicit constexpr _in(int n):i(0),n(n){}explicit constexpr _in(int i,int n):i(i,n<i),n(n){}constexpr const my_iterator& begin(){return i;}constexpr const my_iterator& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;

using i64 = long long;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    string s; int k;
    cin >> s >> k;
    int N = s.size();
    vector<int> a;
    for(char c : s) a.emplace_back(c - 'a');
    for(int i : _in(N)) {
        if(k == 0) break;
        int b = a[i] == 0 ? 0 : 26 - a[i];
        if(k >= b) {
            k -= b;
            a[i] = 0;
        }
        else {
            continue;
        }
    }
    if(k > 0) a[N - 1] = (a[N - 1] + k) % 26;
    for(int x : a) cout << (char)('a' + x);
    cout << endl;
    return 0;
}

Measured memory_bytes: 1100
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    StringBuilder output = new StringBuilder();
    String crlf = System.getProperty("line.separator");
    int[] alphabet = new int[26];
    
    while (in.hasNext()) {
      String input = in.next();
      for (int i = 0; i < input.length(); i++) {
        char ch = input.charAt(i); 
        if ((ch >= 'A' && (int)ch <= 'Z') || (ch >= 'a' && ch <= 'z')) {
          int count = ch % 32 - 1;
          alphabet[count]++;
        }
      }
    }
    
    for (int i = 0; i < alphabet.length; i++) {
      output.append((char)(i + 'a')).append(" : ").append(alphabet[i]);
      if (i != alphabet.length - 1) output.append(crlf);
    }
    System.out.println(output.toString());
  }
}

Measured memory_bytes: 18684
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <cassert>
#include <bitset>
#include <cmath>
#include <iomanip>

using namespace std;

using int64 = long long;

/////////////////////
// Code starts here//
/////////////////////


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

    int N;
    int64 K;

    cin >> N >> K;

    vector<int> go(N);

    for (int i = 0; i < N; i++) {
        cin >> go[i];
        go[i]--;
    }

    vector<int> seen(N, -1);
    vector<int> path;

    K++;

    for (int x = 0; ; x = go[x]) {
        if (seen[x] == -1) {
            K--;
            path.push_back(x);
            seen[x] = path.size() - 1;

            if (!K) {
                cout << x + 1 << "\n";
                return 0;
            }
        } else {
            //cerr << "cycle\n";
            vector<int> cycle;
            for (int i = seen[x]; i < path.size(); i++) {
                cycle.push_back(path[i]);
                //cerr << path[i] << " "; cerr << "\n";
            }

            // for (auto x : cycle) {
            //     cerr << x + 1 << " "; 
            // }
            // cerr << "\n";
            K--;
            K %= (cycle.size());
            cout << cycle[K] + 1 << "\n";
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 6812
#include<stdio.h>
int main(){
	char a[10000],x;
	int b,c,d,e,f;
	b=1;
	while(1){
		scanf("%c",&a[b]);
		if(a[b]=='\n') break;
	b++;
	}
	for(c=1;c<=b;c++){
		if('a'<=a[c]&&a[c]<='z'){
			x=a[c]-32;
			printf("%c",x);
			}
		else if('A'<=a[c]&&a[c]<='Z'){
			x=a[c]+32;
			printf("%c",x);
			}
		else printf("%c",a[c]);
		}
	return 0;
}


Measured memory_bytes: 2140
n = int(input())
a = sorted([int(i) for i in input().split()])
max_a = max(a)
cnt_d = [0] * (max_a + 1)

for ai in a:
    for multi in range(ai, max_a + 1, ai):
        cnt_d[multi] += 1

print(sum(cnt_d[ai] == 1 for ai in a))

Measured memory_bytes: 31952
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
            n: usize,
            a: [u32; n],
        }
    
    let intermediate: Vec<f64> = a.iter().map(|&x| 1f64 / x as f64).collect();

    let ans: f64 = 1f64 / intermediate.iter().fold(0f64, |sum, a| sum + a);

    println!("{}", ans);
}

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

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

  int idx = s.length() - 1;
  while (idx >= 4) {
    if (s.substr(idx-4, 5).compare("dream") == 0) {
      idx -= 5;
      continue;
    } else if (s.substr(idx-4, 5).compare("erase") == 0) {
      idx -= 5;
      continue;
    }
    if (idx < 5) {
      cout<<"NO"<<endl;
      return 0;
    }
    if (s.substr(idx-5, 6).compare("eraser") == 0) {
      idx -= 6;
      continue;
    }
    if (idx < 6) {
      cout<<"NO"<<endl;
      return 0;
    }
    if (s.substr(idx-6, 7).compare("dreamer") == 0) {
      idx -= 7;
    } else {
      cout<<"NO"<<endl;
      return 0;
    }
  }
  if (idx == -1) {
    cout<<"YES"<<endl;
  } else {
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int Q;
int x;
priority_queue<ll, vector<ll>, less<ll>> l;
priority_queue<ll, vector<ll>, greater<ll>> r;
ll ls, rs, bs;

int main(){
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int q;
        cin >> q;
        if(q == 1){
            ll a, b;
            cin >> a >> b;
            bs += b;

            if(x < a){
                r.push(a);
                rs += a;
            }else{
                l.push(a);
                ls += a;
            }

            if(l.size() > r.size() + 1){
                ll t = l.top(); l.pop();
                ls -= t, rs += t;
                r.push(t);
            }
            if(l.size() < r.size()){
                ll t = r.top(); r.pop();
                rs -= t, ls += t;
                l.push(t);
            }

            x = l.top();
        }else{
            ll res = bs + rs - ls + (ll)(l.size() - r.size()) * x;
            cout << x << " " << res << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3828
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}
int main(){
  ll D,A;
  cin>>D>>A;
  if(D==0&&A<100)
  cout<<A<<endl;
  if(D==0&&A==100)
  cout<<101<<endl;
  if(D==1&&A<100)
  cout<<100*A<<endl;
  if(D==1&&A==100)
  cout<<10100<<endl;
  if(D==2&&A<100)
  cout<<10000*A<<endl;
  if(D==2&&A==100)
  cout<<1010000<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int max(int a, int b) {
	return a > b ? a : b;
}

int min(int a, int b) {
	return a < b ? a : b;
}

int main() {

	int i;
	int num;
	int value;

	int min_value = 1000000000;
	int profit = 1 - 1000000000;

	scanf("%d", &num);

	for (i = 0; i < num; i++) {

		scanf("%d", &value);

		if (i == 0) {
			min_value = value;
		}
		else {

			profit = max(profit, value - min_value);
			min_value = min(min_value, value);
		}
	}


	printf("%d\n", profit);

	return 0;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String a = in.next();
            int[] cnt = new int[26];
            for (int i = 0; i < a.length(); ++i) ++cnt[a.charAt(i) - 'a'];
            long res = 1;
            for (int i = 0; i < cnt.length; ++i)
                for (int j = i + 1; j < cnt.length; ++j)
                    res += cnt[i] * (long) cnt[j];
            out.println(res);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

    }
}



Measured memory_bytes: 25300
import java.io.IOException;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws IOException{
		Scanner sc = new Scanner(System.in);

		while(true) {
			int H = sc.nextInt();
			int W = sc.nextInt();

			if(H==0&&W==0) {
				break;
			}
			boolean tmp = false;

			for(int i=0;i<H;i++) {

				for(int j=0;j<W;j++) {
					if(!tmp) {
						System.out.print("#");
						tmp = true;
					}else {
						System.out.print(".");
						tmp = false;
					}
				}
				if(W%2==0) {
					if(tmp) {
						tmp = false;
					}else {
						tmp = true;
					}
				}
				System.out.println();
			}
			System.out.println();
		}

		sc.close();
	}
}


Measured memory_bytes: 35060
'use strict'

function main(s) {

  s = s.split('\n');

  const N = Number(s[0]);
  const a = s[1].split(' ').map(n => Number(n));

  const bucket = [...Array(100001)].fill(0);

  let ans = 0;

  for (let i = 0; i < N; i++) {
    if (a[i] > 100000) {
      ans += 1;
    } else {
      bucket[a[i]] += 1;
    }
  }

  for (let i = 0; i < bucket.length; i++) {
    if (i > bucket[i]) ans += bucket[i];
    if (i < bucket[i]) ans += bucket[i] - i;
  }

  console.log(ans);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main() {
	int n;
	cin >> n;
	uint64_t ans = 0;
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		while ((a & 1) == 0) {
			ans++;
			a >>= 1;
		}
	}
	cout << ans << endl;

}

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

int main()
{
    string n;
    cin >> n;
    if (n[0] == n[1] && n[1] == n[2] || n[1] == n[2] && n[2] == n[3])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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


int main() {
	string s;
	cin >> s;
	if (s[0] == s[1])puts("No");
	else if (s[0] == s[2])puts("No");
	else if (s[1] == s[2])puts("No");
	else puts("Yes");
	return 0;
}


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

int main() {
    long long n, i, sum = 0;
    cin >> n;
    for(i = 1; i <= n; i++){
        if(i%3 != 0 && i%5 != 0) sum += i;
    }
    cout << sum << endl;
}

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

int main() {
  int N; cin >> N;
  vector<long long> L(87,0);
  L.at(0)=2;
  L.at(1)=1;
  
  for (int i=2;i<=N;i++){
    L.at(i)=L.at(i-1)+L.at(i-2);
  }
  
  cout << L.at(N) << endl;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)


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

    vector<pair<char,int>> hougaku(4);
    hougaku[0] = make_pair('N',0);
    hougaku[1] = make_pair('S',0);
    hougaku[2] = make_pair('E',0);
    hougaku[3] = make_pair('W',0);

    ll sizeS = S.size();
    rep(i,sizeS){
        if(S[i] == hougaku[0].first){
            hougaku[0].second = 1;
        }else if(S[i] == hougaku[1].first){
            hougaku[1].second = 1;
        }else if(S[i] == hougaku[2].first){
            hougaku[2].second = 1;
        }else if(S[i] == hougaku[3].first){
            hougaku[3].second = 1;
        }
    }

    if(hougaku[0].second == 1 && hougaku[1].second == 1){
        if(hougaku[2].second == 1 && hougaku[3].second == 1){
            cout << "Yes" << endl;
            return 0;
        }else if(hougaku[2].second == 0 && hougaku[3].second == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }else if(hougaku[0].second == 0 && hougaku[1].second == 0){
        if(hougaku[2].second == 1 && hougaku[3].second == 1){
            cout << "Yes" << endl;
            return 0;
        }else if(hougaku[2].second == 0 && hougaku[3].second == 0){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 3604
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;


int main(int argc, const char * argv[]) {
  string a, b, c;
  cin >> a >> b >> c;
  cout << (char)(a.at(0) + ('A' - 'a'))
  << (char)(b.at(0) + ('A' - 'a'))
  << (char)(c.at(0) + ('A' - 'a')) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;
namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
using Real = mp::number<mp::cpp_dec_float<1024>>;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    i64 a,b,n; cin >> a >> b >> n;
    /**
     * まず a * floor(x/b)を最小化したくなる
     * -> x <= b-1
     * 次にfloor(ax/b)を最大化したくなる
     * -> x = max(b-1, n)
     * おわり
     *
     */

    cout << a*min(b-1, n)/b << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int long long
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1e9+7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k,i,j;
    cin>>n>>k;
    int arr[n+1];
    for(i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    vector<bool> dp(k+1,false);
    for(i=0;i<=k;i++)
    {
        for(j=0;j<n;j++)
        {
            if(arr[j]<=i)
            {
                if(!dp[i-arr[j]])
                    dp[i]=true;
            }
            else
            {
                break;
            }
            
        }
    }
    puts(dp[k]?"First":"Second");
}

Measured memory_bytes: 256
///#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
///#pragma GCC target("sse,sse2,sse3,ssse3,sse4,abm,mmx,popcnt,avx,avx2,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

/*
    zet:
        find_by_order(k): k-stat [k > 0]
        order_of_key(k) : {el < k}

    gp_hash_table<key, val, custom_hash>

    rope<T>:
        iterators: mutable_begin, ..
        methods  : erase, insert, substr, ..
*/

#define all(x) (x).begin(), (x).end()
#define size(x) (int)((x).size())
#define em_back emplace_back

using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;

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

template<typename T>
using zet = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

mt19937 eng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 1e2 + 4;

int n;
vector<int> a;

void no() {
    cout << "Impossible\n";
    exit(0);
}

void solve() {
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(all(a));

    int d = a[n - 1];
    int down = (d + 1) / 2;

    vector<int> b;
    for (int i = 1; i <= d + 1; ++i) {
        b.em_back(max(i - 1, d + 1 - i));
    }

    while (size(b)) {
        int last = b.back();
        b.pop_back();

        auto it = find(all(a), last);
        if (it == a.end()) {
            no();
        }

        a.erase(it);
    }

    if (size(a)) {
        if (a[0] <= down) {
            no();
        }
    }

    cout << "Possible\n";
}

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

    int z = 1;
    /// cin >> z;

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

    return 0;
}


Measured memory_bytes: 3644
import java.util.*;
import java.io.*;
public class Main {
	static int n;
	static long mod;
	static long[] dp=new long[112345];
	static long[] res=new long[112345];
	static ArrayList<Integer>[] G=new ArrayList[112345];
	static void dfs(int u,int fa) {
		dp[u]=1;
		for (int i=0;i<G[u].size();++i) {
			int v=G[u].get(i);
			if (v==fa) continue;
			dfs(v,u);
			dp[u]=dp[u]*(dp[v]+1)%mod;
		}
	}
	static void DP(int u,int fa,long now) {
		long[] pre=new long[G[u].size()];
		long[] suf=new long[G[u].size()];
		for (int i=0;i<G[u].size();++i) {
			if (G[u].get(i)==fa) pre[i]=now;
			else pre[i]=dp[G[u].get(i)]+1;
			if (i>0) pre[i]*=pre[i-1];
			if (pre[i]>=mod) pre[i]%=mod;
		}
		for (int i=G[u].size()-1;i>=0;--i) {
			if (G[u].get(i)==fa) suf[i]=now;
			else suf[i]=dp[G[u].get(i)]+1;
			if (i+1<G[u].size()) suf[i]*=suf[i+1];
			if (suf[i]>=mod) suf[i]%=mod;
		}
		long ans=now;
		for (int i=0;i<G[u].size();++i) {
			int v=G[u].get(i);
			if (v==fa) continue;
			long tmp=1;
			if (i>0) tmp=tmp*pre[i-1]%mod;
			if (i+1<G[u].size()) tmp=tmp*suf[i+1]%mod;
			DP(v,u,tmp+1);
			ans=ans*(dp[v]+1)%mod;
		}
		res[u]=ans;
	}
	public static void main(String[] args) throws IOException {
		StreamTokenizer in=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
		PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out));
		in.nextToken();
		n=(int)in.nval;
		in.nextToken();
		mod=(long)in.nval;
		for (int i=1;i<=n;++i) G[i]=new ArrayList();
		for (int i=0;i<n-1;++i) {
			in.nextToken();
			int x=(int)in.nval;
			in.nextToken();
			int y=(int)in.nval;
			G[x].add(y);
			G[y].add(x);
		}
		dfs(1,0);
		DP(1,0,1);
		for (int i=1;i<=n;++i) out.println(res[i]%mod);
		out.flush();
	}
}

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

int main(){
	double pi = 3.1415926;
	int r;
	cin >> r;

	printf("%.4lf\n",2*r*pi);

	return 0;
}

Measured memory_bytes: 3748
mseq a b = 
    let a' = (a * b) `mod` 10
    in
        a:(mseq a' b)

pow n i =
    let n' = n `mod` 10
        s@(h:t) = take 10 $ mseq n' n'
        r = h:(takeWhile (/= h) t)
        l = length r
        m = (i-1) `mod` l
    in
        r!!m

ans [n,m,k] = 
    let n' = n `mod` 10
        nm = pow n' m
        s@(h:t) = take 10 $ mseq n' nm
        r = h:(takeWhile (/= h) t)
        l = length r
        nn = k `mod` l
        mm = k `div` l
        a = mm * (sum r) + (sum $ take nn s)
    in  
        a

main = do
    l <- getLine
    let i = map read $ words l :: [Int]
        o = ans i
    print o




Measured memory_bytes: 3676
sx,sy,tx,ty=map(int,input().split())
dx,dy=tx-sx,ty-sy
print(dy*'U'+dx*'R'+dy*'D'+(dx+1)*'L'+(dy+1)*'U'+(dx+1)*'R'+'D'+'R'+(dy+1)*'D'+(dx+1)*'L'+'U')

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

int main() {
  long long n;
  cin >> n;
  int ans = 0;
  for (long long i = 2; i * i <= n; i++) {
    int cnt = 0;
    while (n % i == 0) {
      cnt++;
      n /= i;
    }
    for (int j = 1; j <= cnt; j++) {
      ans++;
      cnt -= j;
    }
  }
  if (n != 1) ans++;
  cout << ans << endl;
  return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int d, t, s; cin >> d >> t >> s;
    if (s * t >= d) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 3612