akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int movey[] = {0, 0, 1, -1};
int movex[] = {1, -1, 0, 0};
int n;
void dfs(vector<vector<pii>> &board, int posx, int posy){
  int a = (board[posy][posx].second ^ 1);
  rep(i, 4){
    int x = posx + movex[i], y = posy + movey[i];
    if(x >= n || y >= n || x < 0 || y < 0) continue;
    if(board[y][x].first > board[posy][posx].first + a){
      board[y][x].first = board[posy][posx].first + a;
      dfs(board, x, y);
    }
  }
}
int main(){
  cin >> n;
  vector<vector<pii>> board(n, vector<pii>(n, make_pair(0, 0)));
  rep(y, n){
    rep(x, n){
      int num = min({x, y, n - x - 1, n - y - 1});
      board[y][x].first = num;
    }
  }
  int ans = 0;
  rep(i, n * n){
    int p;
    cin >> p;
    p--;
    int posy = p / n, posx = p % n;
    board[posy][posx].second = 1;
    ans += board[posy][posx].first;
    dfs(board, posx, posy);
  }
  cout << ans << endl;
}

Measured memory_bytes: 24928
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	ll n;
	cin >> n;
	vector<ll> a(n);
	for(int i = 0; i < n; i++) {
		cin >> a [i];
	}
	ll sum = 0;
	
	for(ll i = 0; i <= 61; i++) {
		ll one = 0;
		ll zero = 0;
		for(ll j = 0; j < n; j++) {
			if ((a[j] & (1LL<<i))){
				one += 1;
			}
			else{
				zero += 1;
			}
		}
		ll tmp = (1LL << i) % mod;
		ll tmp2 = (one * zero) % mod;
		sum += (tmp2 * tmp) % mod; 
	}
	cout << sum % mod << endl;
	return 0;
} 

Measured memory_bytes: 2560
p=print
r=range
def a(i,j,k,l=0):p("+<"[l],i,j,k)
def b(i):a(i,i,i+1)
def d(x,i):
	for t in r(30):b(p:=i+t+30);a(q:=p+1,n,q);[*map(b,r(q,i+60))];a(i+60,x,i+t,1);b(p);a(q,i+t,q)
p(n:=3933)
a(0,1,n)
a(2,n,n,1)
a(0,n,3)
a(1,n,4)
d(3,9)
d(4,50)
for t in r(59):a(2,2,2);[t-30<s<30!=(a(9+t-s,50+s,5),a(n,5,6,1),a(2,6,2))for s in r(t+1)]

Measured memory_bytes: 9256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define int long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define BS binary_search
#define all(c) (c).begin(),(c).end()
#define sz(x) (int)(x).size()
#define get(a,t) get<a>(t)
#define EPS 0.000000001 //1e-9
using pii=pair<int,int>;
const int INF=1e18;

void dprint(string s) { cout << endl;}
void dprint() { cout << endl;}
template <class T, class... U> void dprint(string s, T t, U... u) 
{int w=s.find(','); cout <<"["<< s.substr(0,w) << ": " << t << "] " ; dprint(s.substr(w+1, sz(s)-w), u...);} 


#define DEBUG 
#ifdef DEBUG
#define dbg(X...) dprint(#X,X)
#else
#define dbg(X...); 
#endif
const int N=100005;

int32_t main()
{
    IOS;
    int k,a,b; cin>>k>>a>>b;
    int rem=b%k;
    if(b-rem >=a) cout<<"OK";
    else cout<<"NG";
    return 0;
}

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

signed main(){
  int A,B,C,X;
  cin>>A>>B>>C>>X;
  int ans=0;
  rep(i,A){
    rep(j,B){
      rep(k,C){
        if(i*500+j*100+k*50==X)ans+=1;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
n = int(input())
L = sorted(list(map(int, input().split())), reverse = True)

def judge(a:int, b:int, c:int):
    if a < b + c:
        pass
    else:
        return False
    if b < c + a:
        pass
    else:
        return False
    if c < a + b:
        pass
    else:
        return False
    return True

def binary_search(l:int, r:int):
    while r - l > 1:
        mid = (l + r) // 2
        c = L[mid]
        if judge(a, b, c) == True:
            l = mid
        else:
            r = mid
    return l

ans = 0
for i in range(n - 2):
    a = L[i]
    for j in range(i + 1, n - 1):
        b = L[j]
        f1 = judge(a, b, L[j + 1])
        f2 = judge(a, b, L[n - 1])
        if f1 == True:
            if f2 == False:
                ans += binary_search(j, n - 1) - j 
            else:
                ans += n - j - 1
        else:
            pass
    
print(ans)

Measured memory_bytes: 49400
#include <stdio.h>

int main()
{
  int a, b;
  scanf("%d\n", &a);
  scanf("%d\n", &b);

  if (a > b) {
    printf("a > b\n");
  } else if (a < b) {
    printf("a < b\n");
  } else {
    printf("a == b\n");
  }
}



Measured memory_bytes: 2136
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#define int long long
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
using namespace std;
using namespace __gnu_pbds;

tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderset;

const int N=2e5+5;


main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    long double x,y,a,b;
    cin>>x>>y>>a>>b;
    long double de=fabs((a*30+b/2)-b*6);
    long double val=cos(de*3.14159265359/180);
    long double res=sqrt(x*x+y*y-2*x*y*val);
    cout<<fixed<<setprecision(10)<<res;
}


Measured memory_bytes: 4116
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
int main(void){
    // Your code here!
 int i,n;
 string s;
 cin >> s;
 n=s.length();
 for(i=0;i<n;i++)
 {
  if((i%2 && s[i]=='R') || (i%2==0 && s[i]=='L'))
  {
   cout << "No";
   return 0;
  }
 }
 cout << "Yes";
 return 0;
}


Measured memory_bytes: 3628
#include<iostream>


#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
using namespace std;

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

typedef pair<int, int> pii;


int main() {
	
	int n, m;
	pii arr[100001];
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		arr[i] = make_pair(y, x);
	}
	sort(arr, arr + m);

	int cnt = 1,cmp=arr[0].first;
	for (int i = 0; i < m; i++) {
		if (cmp <= arr[i].second) {
			cnt++;
			cmp = arr[i].first;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 1024
n,m = map(int,input().split())
A = [0]*m
B = [0]*m
for i in range(m):
    A[i],B[i] = map(int,input().split())
# print(A,B)
for i in range(n):
    ans = 0
    for k in range(m):
        if (A[k] == i+1) or (B[k] == i+1):
            ans += 1
    print(ans)     

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main() {
    string s;
    cin>>s;

    int sum = 0;
    for(int i=0;i<s.length();i++)
    sum += s[i] - '0';

    if(sum%9==0)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
}


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

int main(){
  ll N;cin>>N;
  vector<ll> a(N);rep(i,N)cin>>a[i];
  ll cnt=0;
  rep(i,N){
    while(a[i]%2==0){
      cnt++;
      a[i]/=2;
    }
  }
  cout << cnt << endl;
} 

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

void solve(long long a) { cout << a + a * a + a * a * a << endl; }

int main() {
    long long a;
    scanf("%lld", &a);
    solve(a);
    return 0;
}


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

using namespace std;

int main()
{
    int N;
    cin >> N;
    int a[3000];
    for(int i = 0; i < N; ++i) cin >> a[i];
    int sum = 0;
    for(int i = 0; i < N; ++i) sum += a[i];
    cout << sum - N << endl;
    return 0;
}



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

static const int INF=1e9;

int main(){
    int N,ma,mb;
    cin >> N >> ma >> mb;
    int a[N],b[N],c[N];
    for(int i=0;i<N;i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    int dp[N+1][401][401];
    for(int i=0;i<=N;i++){
        for(int s=0;s<=400;s++){
            for(int t=0;t<=400;t++){
                dp[i][s][t]=INF;
            }
        }
    }
    dp[0][0][0]=0;
    for(int i=0;i<N;i++){
        for(int s=0;s<=400;s++){
            for(int t=0;t<=400;t++){
                if(s+a[i]<=400&&t+b[i]<=400){
                    dp[i+1][s+a[i]][t+b[i]]=min(dp[i+1][s+a[i]][t+b[i]],dp[i][s][t]+c[i]);
                }
                dp[i+1][s][t]=min(dp[i+1][s][t],dp[i][s][t]);
            }
        }
    }
    int ans=INF;
    for(int i=1;i<=400;i++){
        for(int j=1;j<=400;j++){
            //cout << dp[N][i][j] << " ";
            if(i*mb==j*ma){
                ans=min(ans,dp[N][i][j]);
            }
        }
        //cout << endl;
    }
    if(ans==INF){
        cout << -1 << endl;
    }else{
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 25984
<?php
define("MOD", 10 ** 9 + 7);

# 入力
fscanf(STDIN, '%s', $s);
$s = strrev($s);
$n = strlen($s);

$dp[0] = array_fill(0, 13, 0);
$dp[0][0] = 1;
$mul = 1;
for ($i = 0; $i < $n; $i++) {
    $dp[$i + 1] = array_fill(0, 13, 0);
    if ($s[$i] === '?') {
        for ($j = 0; $j < 10; $j++) {
            $diff = $mul * $j;
            for ($k = 0; $k < 13; $k++) {
                $dp[$i + 1][($diff + $k) % 13] += $dp[$i][$k];
            }
        }
    } else {
        $j = (int)$s[$i];
        $diff = $mul * $j;
        for ($k = 0; $k < 13; $k++) {
            $dp[$i + 1][($diff + $k) % 13] = $dp[$i][$k];
        }
    }
    for($k = 0; $k < 13; $k++) {
        $dp[$i + 1][$k] %= MOD;
    }
    $mul *= 10;
    $mul %= 13;
}
echo $dp[$n][5].PHP_EOL;

Measured memory_bytes: 76276
#[allow(unused_macros)]
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 ( 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(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
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: u64, m: u64
    }

    let ret = if n == 1 && m == 1 {
        1
    } else if n == 1 {
        m - 2
    } else if m == 1 {
        n - 2
    } else {
        (n-2)*(m-2)
    };
    println!("{}", ret);
}

Measured memory_bytes: 4352
import sys
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
C = Counter(A)
C = sorted(C.items(), reverse=True)
a, b = 0, 0
for k, v in C:
    if a == 0 and v >= 4:
        print(k * k)
        sys.exit()
    if v >= 2:
        if a == 0:
            a = k
        elif b == 0:
            print(a * k)
            sys.exit()
print(0)

Measured memory_bytes: 25820
#include <iostream>
#include <string>
using namespace std;
    int main(){
    string A,B,C;
    cin >> A >> B >> C;
    if(A.back() == B[0] && B.back() == C[0]){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    }

Measured memory_bytes: 256
/* ex20_20
    nnasy   */

#include <stdio.h>

int main(void) {
    int length_N, white;

    //入力の受け取り（N, A）
    scanf("%d%d", &length_N, &white);

    //黒色のマスの個数(N*N-A)の出力
    printf("%d\n", length_N*length_N-white);
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	x := make([][]int, n)
	y := make([][]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		x[i] = make([]int, a[i])
		y[i] = make([]int, a[i])

		for j := 0; j < a[i]; j++ {
			fmt.Scan(&x[i][j], &y[i][j])
		}
	}

	ans := 0
	for bits := 1; bits < (1 << uint64(n)); bits++ {
		ok := true
		for i := 0; i < n; i++ {
			if (bits & (1 << uint64(i))) == 0 {
				continue
			}
			for j := 0; j < a[i]; j++ {
				if ((bits>>uint64(x[i][j]-1))&1)^y[i][j] == 1 {
					ok = false
				}
			}
		}
		if ok {
			ans = max(ans, counter(bits))
		}
	}
	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func counter(x int) int {
	if x == 0 {
		return 0
	}
	return counter(x>>1) + (x & 1)
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, pair<ll, ll> > P3;

const ll MOD = ll(1e9 + 7);
const ll LLINF = LLONG_MAX;
const int IINF = INT_MAX;
const int MAX_N = int(3e5) + 5;
const double EPS = 1e-8;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

ull n, x, a[MAX_N], cum[MAX_N]{};

int main() {
    cin >> n >> x;
    REP(i,n){
        cin >> a[i];
        cum[i+1] += cum[i]+a[i];
    }
    ull ans = LLINF;
    for(ull i=1ull;i<=n;i++){
        ull tmp = 5ull*cum[n], k = n - i;
        while(1){
            if(k<=i)break;
            k -= i;
            tmp += 2ull*cum[k];
        }
        tmp += (n+i)*x;
        ans = min(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}


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





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

    ll n,d,a;
    cin>>n>>d>>a;
    array<ll,3> x[n];
    map<ll,ll> mp;
    vector<ll> v;
    for(int i=0;i<n;i++){
        cin>>x[i][0] >> x[i][1];
        x[i][2]=1;
        mp[x[i][0]]=1;
        v.push_back(x[i][0]);
    }
    ll c = 0;
    mp[1e15]=1;
    v.push_back(1e15);
    sort(v.begin(),v.end());
    for(auto &i:mp){
        i.second = c;
        c++;
    }
    sort(x,x+n);
    ll ans = 0;
    ll cnt[n+1]={};
    ll now = 0;
    for(int i=0;i<n;i++){
        x[i][1] -= now;
        now -= cnt[i];
        if(x[i][1]<=0) continue;
        auto itr = upper_bound(v.begin(),v.end(),x[i][0] + 2*d);
        itr--;
        ll p = mp[*itr];
        ll ret = (x[i][1]+a-1)/a;
        ans += ret;
        if(p==i) continue;
        now += ret*a;
        cnt[p] += ret*a;
    }
    cout << ans << endl;
}


Measured memory_bytes: 20592
#include <bits/stdc++.h>
using namespace std;
//debug
#ifdef grief
#define debug(...) do{\
	fprintf(stderr , "%s - %d : (%s) = " , __PRETTY_FUNCTION__ , __LINE__ , #__VA_ARGS__ );\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){
	cerr<<x<<endl;
}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){
	cerr<<x<<" , ";
	_DO(tail...);
}
#else
#define debug(...)
#endif
//type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef priority_queue<pll,vector<pll>,greater<pll> > heap;
//macro
#define SZ(x) ((ll)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define mkp make_pair
#define pb push_back
#define IOS do{ios_base::sync_with_stdio(0); cin.tie(0);}while(0)
const ll INF=4e18;
const ll MAX=1e5+5;
const ll MOD=1e9+7;
//}}}
ll gcd(ll a,ll b){
	if(a==0)	return b;
	return gcd(b%a,a);
}
int main(){
	IOS;
	int t;
	cin>>t;
	ll ans=1;
	while(t--){
		ll x;
		cin>>x;
		ll g=gcd(x,ans);
		ans=ans/g*x;
	}
	cout<<ans<< '\n';
	return 0;
}

Measured memory_bytes: 256
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a,b=[0],[0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])
ans,j=0,M
for i in range(N + 1): 
	if a[i]>K:
    		break
	while b[j] > K - a[i]:
    		j -= 1
	ans = max(ans, i + j)
print(ans)



Measured memory_bytes: 47312
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array
-- import Data.Array.Unboxed
import Control.Monad.ST
import Data.Array.ST

main :: IO ()
main = getLine >>= solve . map read . words
solve :: [Int] -> IO ()
solve (n:k:_) = forM_ [1..k] $ print . f
  where
    facts = listArray (0, n) $ scanl' modmul 1 [1..(toInteger n)]
    select l m 
      | l < m = 0
      | otherwise = (facts!l) `moddiv` ((facts!m) `modmul` (facts!(l - m)))
    f i = (select (n - k + 1) i) `modmul` (select (k - 1) (i - 1))

divConst = 10^9 + 7 :: Integer
modadd x y = (x + y) `mod` divConst
modsub x y = (x - y) `mod` divConst
modmul x y = ((x `mod` divConst) * (y `mod` divConst)) `mod` divConst
moddiv x y = modmul x (power y (divConst - 2))
power x y
  | y == 0 = 1
  | y == 1 = x `mod` divConst
  | y `mod` 2 == 0 = (power x (y `div` 2))^2 `mod` divConst
  | otherwise = (power x (y `div` 2))^2 * x `mod` divConst


Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
const int N = 300;

char ch[N+5]; int f[N+5][N+5][N+5], k, n;

void work() {
    scanf("%s%d", ch+1, &k); n = strlen(ch+1);
    for (int i = 1; i <= n; i++) f[i][i][0] = 1;
    for (int l = 1; l <= n; l++)
    for (int i = 1; i+l <= n; i++)
        for (int p = 0, j = i+l; p <= k; p++) {
        f[i][j][p] = max(f[i+1][j][p], f[i][j-1][p]);
        if (ch[i] == ch[j]) f[i][j][p] = max(f[i][j][p], f[i+1][j-1][p]+2);
        if (p) f[i][j][p] = max(f[i][j][p], f[i+1][j-1][p-1]+2);
        }
    int ans = 0;
    for (int i = 0; i <= k; i++) ans = max(ans, f[1][n][i]);
    printf("%d\n", ans);
}
int main() {work(); return 0; }

Measured memory_bytes: 110464
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A, B;
    std::cin >> A >> B;
    if(A+B>=A-B&&A+B>=A*B){
        std::cout << A+B << std::endl;
    }
    else if (A-B>=A+B&&A-B>=A*B){
        std::cout << A-B << std::endl;
    }
    else{
        std::cout << A*B << std::endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
int main(){
    int n;
    cin >> n;
    string s,t;
    cin >> s >> t;
    rep(i,n){
        cout << s[i] << t[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
/******************************************
* AUTHOR : GEEOTHERMAL/CODEFORCES
  USED BY : Shivam Jalotra
  COLLEGE : Nit Kurukshetra
******************************************/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for(int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

// Function Declaration
long long int Knapsack(int wt[], int v[], int W, int n);
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    

	// Dynamic Programming
	// SO we are given a int wt[] and a int value[] and a max weight that the knapsack can hold  
	// We have to maximize the total value of knapsack also the weights has to be taken in
	// such as the total sum of the weights is less than W

	// Inputs are wt[], v[], W(total_weight), n 
	int N,W;
	cin >> N >> W;
	int v[N];
	int wt[W];

	FOR(i,0,N)
	{
		cin>> wt[i] >> v[i]; 
	}
	cout << Knapsack(wt, v, W, N);
	
	return 0;
}

long long int Knapsack(int wt[], int v[], int W, int n)
{
	
	long long K[n+1][W+1] ;
	// Base case 
	// k[n][0] = 0
	// k[0][w] = 0

	// FOR(i,0,n+1)
	// {
	// 	FOR(j,0,W+1)
	// 	{
	// 		K[i][j] = 0;
	// 	}
	// }

	// Now building the matrix in bottom up manner
	FOR(i,0,n+1)
	{
		FOR(w,0,W+1)
		{
			if(i == 0 || w == 0)
			{
				K[i][w] = 0;
			}
			else if(wt[i-1] <= w)
			{
				K[i][w] = max(v[i-1]+ K[i-1][w-wt[i-1]], K[i-1][w]);
			}
			else
			{
				K[i][w] = K[i-1][w];
						}
		}
	}


	return K[n][W];
}

Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F(i,a,b) for(int i = a ; i <=b ; i++)
#define R(i,a,b) for(int i = a ; i >= b ; i--)
#define pb push_back
#define speed ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ub(a,x) upper_bound(a.begin(),a.end(),x)-a.begin()
#define lb(a,x) lower_bound(a.begin(),a.end(),x)-a.begin()
#define ALL(v)   v.begin(),v.end()
bool comp(pair<pair<string,int> , int> a, pair<pair<string,int> , int> b )
{
	if(a.first.first  != b.first.first)
		return a.first.first < b.first.first;
	else
		return a.first.second >  b.first.second;
}
int main()
	{
		
		int a, p;
		cin >> a >> p;
		int ans = a * 3  +p;
		ans /= 2;
		cout << ans;

		
}



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

int dp[105][4][2];

int main() {
	string S;
	int K;
	cin >> S;
	cin >> K;
	int N = S.size();
	dp[0][0][0] = 1;

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 2; k++) {
				int nd = S[i] - '0';
				for (int d = 0; d < 10; d++) {
					int ni = i + 1;
					int nj = j;
					int nk = k;
					if (d != 0) {
						nj++;
					}
					if (nj > K) {
						continue;
					}
					if (k == 0) {
						if (d > nd) {
							continue;
						}
						if (d < nd) {
							nk = 1;
						}
					}
					dp[ni][nj][nk] += dp[i][j][k];
				}
			}
		}
	}

	int ans = dp[N][K][0] + dp[N][K][1];
	cout << ans << endl;

}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <typeinfo>
#include <queue>

using namespace std;

typedef long long ll;
int main(){
	int n;
	ll l,r;
	ll past_l,past_r,tmp_l,tmp_r;
	cin >> n;
	cin >> l >> r;
	past_l = l;
	past_r = r;
	ll bai_l,bai_r,amari_l,amari_r;
	for(int i=0; i < n-1; i++){
		//bai = 1;
		cin >> l >> r;
		tmp_l = l;
		tmp_r = r;
		if(tmp_l >= past_l && tmp_r >= past_r){
			past_l = tmp_l;
			past_r = tmp_r;
		}
		else{
			bai_l = past_l / tmp_l;
			bai_r = past_r / tmp_r;
			if(bai_l > bai_r){
				if(bai_l*tmp_l != past_l){
					bai_l++;
				}
				bai_r = bai_l;
			}
			else if(bai_l < bai_r){
				if(bai_r*tmp_r != past_r){
					bai_r++;
				}			
				bai_l = bai_r;	
			}
			else{
				amari_l = past_l % tmp_l;
				amari_r = past_r % tmp_r;
				if(amari_l > amari_r){
					if(bai_l*tmp_l != past_l){
						bai_l++;
					}
					bai_r = bai_l;		
				}
				else{
					if(bai_r*tmp_r != past_r){
						bai_r++;
					}			
					bai_l = bai_r;
				}
			}
			past_l = bai_l * tmp_l;
			past_r = bai_r * tmp_r;
		}

	}
	cout << past_l + past_r << endl;
	return 0;
}


int mai(){
	int n;
	int l,r;
	int past_l,past_r,tmp_l,tmp_r;
	cin >> n;
	cin >> l >> r;
	past_l = l;
	past_r = r;
	int bai;
	for(int i=0; i < n-1; i++){
		//bai = 1;
		cin >> l >> r;
		tmp_l = l;
		tmp_r = r;
		bai = max(past_l / l, past_r / r);		
		while(true){
			tmp_l = l * bai;
			tmp_r = r * bai;
			bai++;
			//cout << tmp_l << " " << tmp_r << endl;
			if(tmp_l >= past_l && tmp_r >= past_r){
				past_l = tmp_l;
				past_r = tmp_r;
				//cout << tmp_l + tmp_r << endl;
				break;
			}
		}

	}
	cout << 1 / 3 << endl;
	cout << past_l + past_r << endl;
	return 0;
}




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


int n,y,x,cnt;

vector< string > a;
vector< string > b;

string tmp=",#@";

void change(ll p){
  cnt=0;
  for(int i=n-1;i>=0;i--){
    for(int j=n-1;j>=0;j--){
      a[i][j]=tmp[p%3];
      if(a[i][j]=='#')cnt++;
      if(a[i][j]=='@')y=i,x=j;
      p/=3;
    }
  }
}

ll change2(){
  ll res=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      res*=3;
      if(a[i][j]=='#')res++;
      if(a[i][j]=='@')res+=2;
    }
  }
  return res;
}

ll change3(){
  b=a;
  ll res=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(a[i][j]=='@'){
        a[i][j]='@';
      }else{
        int cnt=0;
        for(int k=-1;k<=1;k++){
          for(int l=-1;l<=1;l++){
            if(k==0&&l==0)continue;
            if(i+k<0 || n<=i+k)continue;
            if(j+l<0 || n<=j+l)continue;
            if(b[i+k][j+l]!=',')cnt++;
          }
        }
        if(b[i][j]=='#'&&(cnt==3||cnt==2)){
          a[i][j]='#';
        }else if(b[i][j]==','&&cnt==3){
          a[i][j]='#';
        }else{
          a[i][j]=',';
        }
      }
      
      res*=3;
      if(a[i][j]=='#')res++;
      if(a[i][j]=='@')res+=2;
    }
  }
  return res;
}

int solve(){
  map< ll , int > d;
  queue< ll > Q;
  d[ change2() ]=0;
  Q.push( change2() );
  while(!Q.empty()){
    ll p=Q.front();Q.pop();
    change(p);
    
    /*
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
        cout<<a[i][j];
      }
      cout<<endl;
    }
    */
    if(cnt==0)return d[p];

    for(int ny=y-1;ny<=y+1;ny++){
      for(int nx=x-1;nx<=x+1;nx++){
        if(ny<0 || nx<0)continue;
        if(ny>=n || nx>=n)continue;
        if(a[ny][nx]!=',')continue;

        swap(a[ny][nx],a[y][x]);

        ll next=change3();
        if( d.count(next) == 0)d[next]=1e9;
        if( d[p] + 1 < d[next]){
          d[next]=d[p]+1;
          Q.push(next);
        }
        
        change(p);
      }
    }
  }
  return -1;
}
int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    a.clear();
    a.resize(n);
    for(int i=0;i<n;i++)cin>>a[i];
    cout<< solve() <<endl;
  }
  return 0;
}

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

friends = [[] for _ in range(n+1)]
blocks = [[] for _ in range(n+1)]

for _ in range(m):
    a, b = map(int, input().split())
    friends[a].append(b)
    friends[b].append(a)

for _ in range(k):
    c, d = map(int, input().split())
    blocks[c].append(d)
    blocks[d].append(c)

groups = [-1]*(n+1)
n_groups = []
g = 0
for i in range(1, n+1):
    if groups[i]>=0:
        continue
    stack = [i]
    cnt = 0
    groups[i] = g
    while len(stack)>0:
        node = stack.pop()
        for c_node in friends[node]:
            if groups[c_node]>=0:
                continue
            stack.append(c_node)
            groups[c_node] = g
            cnt += 1
    n_groups.append(cnt)
    g += 1

ans = []
for i in range(1, n+1):
    tmp = n_groups[groups[i]]
    for j in friends[i]:
        if groups[i] == groups[j]:
            tmp -= 1
    for j in blocks[i]:
        if groups[i] == groups[j]:
            tmp -= 1
    ans.append(tmp)

print(*ans)


Measured memory_bytes: 46816
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner in = new Scanner(System.in)) {
			int n = in.nextInt();
			int r = 0;
			int trail = 0;
			int lead = 0;
			int dbl = 0;
			for (int i = 0; i < n; i++) {
				String s = in.next();
				int p = -1;
				while (true) {
					p = s.indexOf("AB", p + 1);
					if (p == -1) {
						break;
					}
					r++;
				}
				boolean st = s.startsWith("B");
				boolean ed = s.endsWith("A");
				if (st && ed) {
					dbl++;
				} else {
					if (st) {
						lead++;
					}
					if (ed) {
						trail++;
					}
				}
			}
			
			//System.out.println("r" + r + " d" + dbl + " l" + lead + " t" + trail);
			
			// double 同士を1つに連結。
			if (dbl > 1) {
				r += dbl - 1;
				dbl = 1;
			}
			if (dbl == 1) {
				if (lead > 0) {
					lead--;
					r++;
				}
				if (trail > 0) {
					trail--;
					r++;
				}
			}
			r += Math.min(lead, trail);
			
			System.out.println(r);
		}
	}
	
}


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

using namespace std;

typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const int MX = 100005;
int fw[MX];
int a[105];

//1:first 0:second
int main(){
  int n,k; scanf("%d %d", &n, &k);
  for(int i=0;i<n;i++){
    scanf("%d", a+i);
  }
  fw[0] = 0;
  for(int i=0;i<=k;i++){
    for(int j=0;j<n;j++){
      if(i-a[j] >= 0 && fw[i-a[j]] == 0){
        fw[i] = 1;
        break;
      }
    }
  }
  if(fw[k] == 1) cout << "First";
  else cout << "Second";
  return 0;
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    long long n, m, max = -1;
    cin >> n >> m;
    int d = 2;
    while (d * d <= m) {
        if (m % d == 0) {
            if (m/d >= n)
                if (d >= max)
                    max = d;
            if (d >= n)
                if (m/d >= max)
                    max = m/d;
        }
        d++;
    }
    if (n == 1)
        cout << m;
    else if (max == -1) {
        if (n == 1)
            cout << m;
        else
            cout << 1;
    }
    else
        cout << max;
    return 0;
}


Measured memory_bytes: 256
X, Y = list(map(int,input().split()))

from functools import reduce

def cmb(n, r):
    INF = 10 ** 9 + 7
    r = min(n - r, r)
    if r == 0:  return 1
    numer = reduce(lambda x, y: (x * y) % INF, range(n, n - r, -1))
    denom = reduce(lambda x, y: (x * y) % INF, range(1, r + 1))
    return (numer * pow(denom, INF - 2, INF)) % INF

temp1 = 2 * X - Y
temp2 = 2 * Y - X
if temp1 % 3 or temp2 % 3:  print(0)
elif temp1 < 0 or temp2 < 0:  print(0)
else:
    a = temp1 // 3
    b = temp2 // 3
    print(cmb(a + b, a))

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

int P[10010];
void init(int N) {
	for (int i = 0; i < N; ++i) P[i] = i;
}
int root(int a) {
	if (P[a] == a) return a;
	return P[a] = root(P[a]);
}
bool is_same_set(int a, int b) {
	return root(a) == root(b);
}
void unite(int a, int b) {
	P[root(a)] = root(b);
}

signed main() {
	int g;
	cin >> g;
	vector<pair<int, pair<int, int>>> a;
	int weight;

	init(g);

	for (int i = 0; i < g; ++i) {
		for (int j = 0; j < g; ++j) {
			cin >> weight;
			if (i > j and weight != -1) {
				a.push_back(make_pair(weight, make_pair(i, j)));
			}
		}
	}

	sort(a.begin(), a.end());

	int ans = 0;

	for (auto e : a) {
		//cout << e.first << ' ' << e.second.first << ' ' << e.second.second << endl;
		if (!is_same_set(e.second.first, e.second.second)) {
			unite(e.second.first, e.second.second);
			ans += e.first;
		}
		else {
			continue;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 3140
def main():
    from fractions import gcd
    from collections import Counter
    a,b=map(int,input().split())
    c=len(Counter(soinsuu(gcd(a,b))))+1
    print(c)
    
def soinsuu(a):
    yy,j=[],2
    y=yy.append
    while(a>1):
        for i in range(j,int(a**0.5)+1):
            if a%i==0:
                y(i)
                a,j=a//i,i
                break
        else:
            y(a)
            break
    yy.sort()
    return yy
    
if __name__ == '__main__':
	main()


Measured memory_bytes: 5180
#include <stdio.h>
int main(){
  int n, t;
  scanf("%d", &n);
  int a[2000000]={0};
  for(int i=0; i<n-1; i++){
    scanf("%d", &t);
    a[t-1]++;
  }
  for(int i=0; i<n; i++) printf("%d\n", a[i]);
}

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

#define VARNAME(x) #x
#define show(x) cerr << #x << " = " << x << endl

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

constexpr ll MOD = 1000000007LL;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;
template <typename T, typename A>
ostream& operator<<(ostream& os, const vector<T, A>& v)
{
    os << "sz:" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> a(N);
    vector<ll> b(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> b[i];
    }
    vector<vector<ll>> on(29);
    vector<vector<ll>> off(29);
    for (int i = 0; i < 29; i++) {
        for (int j = 0; j < N; j++) {
            if (b[j] & (1LL << i)) {
                on[i].push_back(b[j] % (1LL << i));
            } else {
                off[i].push_back(b[j] % (1LL << i));
            }
        }
        sort(on[i].begin(), on[i].end());
        sort(off[i].begin(), off[i].end());
    }
    // show(on);
    // show(off);
    ll ans = 0;
    for (int i = 0; i < 29; i++) {
        for (int j = 0; j < N; j++) {
            const bool ON = (a[j] & (1LL << i)) > 0;
            const ll res = (1LL << i) - a[j] % (1LL << i);
            int num;
            if (ON) {
                num = (on[i].end() - lower_bound(on[i].begin(), on[i].end(), res)) + (lower_bound(off[i].begin(), off[i].end(), res) - off[i].begin());
            } else {
                num = (lower_bound(on[i].begin(), on[i].end(), res) - on[i].begin()) + (off[i].end() - lower_bound(off[i].begin(), off[i].end(), res));
            }
            if (num % 2 == 1) {
                ans = ans ^ (1LL << i);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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


Measured memory_bytes: 4324
#include <cstdio>
#include <vector>


#define maxn 120000
#define ll long long


int main()
{

    int a,b;

    scanf("%d%d", &a, &b);
    if (a > 8 || b > 8)
        printf(":(");
    else
        printf("Yay!");
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int>A(N);
  int ans=0;
  int count=0;
  for(int i=0;i<N;i++){
    cin >> A[i];
    if(i==0){
      ans++;
      count=A[i];
      continue;
    }
    count=min(count,A[i]);
    if(count==A[i]){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3912
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
import numpy as np

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

N, M, X = LI()
C = np.array([0 for i in range(N)])
A = np.array([[0 for i in range(M)] for j in range(N)])
for i in range(N):
    ca = LI()
    C[i] = ca[0]
    for j in range(M):
        A[i][j] = ca[1+j]


ans = mod
# 10進数のnをk進数のリストに変換
def n2kdigit(n,k):
    digits = []
    while n > 0:
        digits.append(n % k)
        n = n // k
    while len(digits) < N:
        digits.append(0)
    return digits

for i in range(2 ** N):
    skill = np.array([0 for i in range(M)])
    digit = np.array(n2kdigit(i, 2))
    for j in range(N):
        if digit[j]:
            skill += A[j]
    # print(skill)
    if np.all(skill >= X):
        ans = min(ans, sum(digit * C))
        # print(ans)

if ans == mod:
    print("-1")
else:
    print(ans)
    

Measured memory_bytes: 27464
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>

using namespace std;
int main()
{

	string s;
	cin >> s;

	for (int i = 0; i < s.size(); i = i + 2) {
		cout << s[i];
	}


	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std ;
int main ()
{
char s,s1;
cin>>s>>s1;
if (s=='H'&&s1=='H')
cout<<"H";
else if (s=='H'&&s1=='D')
cout<<"D";
else if (s=='D'&&s1=='H')
cout<<"D";
else if (s=='D'&&s1=='D')
cout<<"H";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define li long long int
#define mx 100005
li len_s,len_t;
char s[3005],t[3005];
vector <char> res;

int dp[3005][3005];

void f()
{
    dp[0][0]=0;
    for(int i=1;i<=len_t;i++)
    {
        dp[0][i]=0;
    }
    for(int i=1;i<=len_s;i++)
    {
        dp[i][0]=0;
    }

    for(int i=1;i<=len_s;i++)
    {
        for(int j=1;j<=len_t;j++)
        {
            if(s[i-1]==t[j-1])
            {
                dp[i][j]=1+dp[i-1][j-1];
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
}


void gen()
{
    int i=len_s,j=len_t,k;
    int idx=0;

    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
        {
            res.push_back(s[i-1]);
            i=i-1;
            j=j-1;
        }
        else
        {
            if(dp[i][j]==dp[i-1][j])
            {
                i=i-1;
            }
            else
            {
                j=j-1;
            }
        }
    }
    reverse(res.begin(),res.end());
    for(i=0;i<res.size();i++)
        cout<<res[i];
    return;
}

int main()
{
    cin>>s>>t;
    len_s=strlen(s);
    len_t=strlen(t);
    f();
    gen();
    return 0;
}


Measured memory_bytes: 35456
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;
ll MOD = 1000000007;

void print_map(map<P, ll> mp){
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        std::cout << "key = " << itr->first.first << ":" << itr->first.second           // キーを表示
                        << ", val = " << itr->second << "\n";    // 値を表示
    }
}

int main()
{
    ll H, W, N;
    cin >> H >> W >> N;
    map<P, ll> mp;
    rep(i, N) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        for(int i = -1; i <= 1; i++) {
            for (int j = -1; j <= 1; j++) {
                if (a+i <= 0 || a+i >= H-1 || b+j <= 0 || b+j >= W-1) continue;
                mp[make_pair(a+i, b+j)]++;
            }
        }
    }
    vector<ll> vec(10, 0);
    ll count = 0;
    for(pair <P, ll> p : mp) {
        vec[p.second]++;
        count++;
    }
    cout << (H-2) * (W - 2) - count << endl;
    for(ll i = 1; i < vec.size(); ++i){
        cout << vec[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 56448
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    int64_t p0=2,p1=1;
    if(N==0){
        cout<<p0<<endl;
        return 0;
    }
    if(N==1){
        cout<<p1<<endl;
        return 0;
    }
    for(int i=2;i<=N;++i){
        int64_t t=p0+p1;
        p0=p1;
        p1=t;
    }
    cout<<p1<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

void gaussian_elimination(double, double, double, double, double, double);
void pivot(double, double, double, double, double, double);

int main(){
	double a, b, c, d, e, f;
	while(scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != EOF){
		gaussian_elimination(a, b, c, d, e ,f);
	}
 	return 0;
}

void gaussian_elimination(double x1, double y1, double z1, double x2, double y2, double z2){
	double x, y, tmp;

	pivot(x1, y1, z1, x1, y2, z2);
	
	tmp = x1;
	x1 = x1/tmp;
	y1 = y1/tmp;
	z1 = z1/tmp;

	tmp = x2;
	x2 = x2-x1*tmp;
	y2 = y2-y1*tmp;
	z2 = z2-z1*tmp;

	y = z2/y2;
	x = z1-y*y1;

	printf("%1.3lf %1.3lf\n", x, y);
}

void pivot(double x1, double y1, double z1, double x2, double y2, double z2){
	int x, y, z;
	if(x1 <  x2){
		x = x1;
		y = y1;
		z = z1;

		x1 = x2;
		y1 = y2;
		z1 = z2;

		x2 = x;
		y2 = y;
		z2 = z;
	}
}

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

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

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

const int MAXN = 200100;

int n;

ll p[MAXN];

unordered_map <int, int> cnt;

int main() {
  scanf("%d",&n);
  REP(i, n) {
    scanf("%lld",&p[i]);
    cnt[p[i]]++;
  }
  
  sort(p, p + n);
  int sol = 0;
  for (int i = 31; i >= 0; i--) {
    ll x = (1LL << i);
    int lo = 0, hi = n - 1, mid;
    while (lo != hi) {
      mid = (lo + hi + 1) / 2;
      if (p[mid] > x) hi = mid - 1;
      else lo = mid;
    }
    REP(j, lo + 1) {
      if (x - p[j] != p[j] && cnt[p[j]] && cnt[x - p[j]]) {
        cnt[p[j]]--;
        cnt[x - p[j]]--;
        sol++;
      }
      while (x - p[j] == p[j] && cnt[p[j]] >= 2) {
        cnt[p[j]] -= 2;
        sol++;
      }
    }
  }

  cout << sol << endl;
  return 0;
}


Measured memory_bytes: 35472
#include <stdio.h>
#include <string>

using namespace std;


int main() {
  int a, b;

  scanf("%d %d", &a, &b);

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

  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long i,j,k,n,a[100005],b[100005],c[100005],dp[100005][5],mx=0,x;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    dp[1][1]=a[1];
    dp[1][2]=b[1];
    dp[1][3]=c[1];

    for(i=2;i<=n;i++)
    {
        for(j=1;j<=3;j++)
        {
            for(x=1;x<=3;x++)
            {
                if(x!=j)
                {
                    mx=max(mx,dp[i-1][x]);
                    //cout<<mx<<endl;
                }
            }

            if(j==1){dp[i][j]=a[i]+mx; }
            if(j==2){dp[i][j]=b[i]+mx; }
            if(j==3){dp[i][j]=c[i]+mx; }
            mx=0;
        }

     }
     cout<<max(dp[n][1],max(dp[n][2],dp[n][3]));


    return 0;
}


Measured memory_bytes: 6528
S = input().split()
A = int(S[0])
B = int(S[1])
C = 0
D = 0



for i in range(1,100000,1):
  if A > B:
  	C = A * i
  else:
    C = B *i
  
  if A > B:
  	D = B
  else:
    D = A
    
  if C % D == 0:
    print(C)
    break

Measured memory_bytes: 3060
#include<stdio.h>
int main(){
    int n, i;
    scanf("%d", &n);
    for (i=0; i<n; i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        if (a*a + b*b == c*c ||
            b*b + c*c == a*a ||
            c*c + a*a == b*b)
            puts("YES");
        else
            puts("NO");
    }
    return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vll;
const int INF = 0x3f3f3f3f;

int main() {
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> numsr(R);
    for (int i = 0; i < R; ++i) {
        cin >> numsr[i];
    }
    vector<vector<ll>> dp(210, vector<ll>(210, INF));
    ll A, B, C;
    for (int i = 0; i < M; ++i) {
        cin >> A >> B >> C;
        dp[A][B] = dp[B][A] = min(dp[A][B], C);
    }
    for (int k = 1; k <= N; ++k) {
        for (int i = 1; i <= N; ++i) {
            for (int j = 1; j <= N; ++j) {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    ll ans = INF;
    ll curr = 0;
    sort(numsr.begin(), numsr.end());
    do {
        curr = 0;
        for (int i = 0; i < R - 1; ++i) {
            curr += dp[numsr[i]][numsr[i + 1]];
        }
        ans = min(ans, curr);
    } while (next_permutation(numsr.begin(), numsr.end()));
    cout << ans << endl;
    return 0;
}


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

string s;

void solve() {
}
int main() {
  cin >> s;
  int num=s.size();
  string first=s.substr(0,(num-1)/2),second=s.substr((num+1)/2);
  if(first==second) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
  



Measured memory_bytes: 256
#include<stdio.h>

int main(void){

	int a[10];
	int i;
	int max1 = 0;
	int max2 = 0;
	int max3 = 0;
	int m = 0;
	for(i = 0; i < 10; i++){
		scanf("%d",&a[i]);
		if(a[i] < 0 || a[i] > 10000){
			continue;
		}
		if(a[i] > max3){
			max3 = a[i];
		}

		if(max2 < max3){
			m = max2;
			max2 = max3;
			max3 = m;
		}

		if(max1 < max2){
			m = max1;
			max1 = max2;
			max2 = m;
		}
	}

	printf("%d\n",max1);
	printf("%d\n",max2);
	printf("%d\n",max3);
	return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define pii pair<int, int>
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
using namespace std;



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

	ll d, t, s;
	cin >> d >> t >> s;
	if (s * t >= d) {
		cout << "Yes\n";

	}
	else {
		cout << "No\n";
	}
	

}

Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int count_5 = 0;
		int count_7 = 0;
		if(a == 5) {
			count_5++;
		} else if(a == 7) {
			count_7++;
		}
		if(b == 5) {
			count_5++;
		} else if(b == 7) {
			count_7++;
		}
		if(c == 5) {
			count_5++;
		} else if(c == 7) {
			count_7++;
		}
		if(count_5 == 2 && count_7 == 1) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21460
#include <iostream>
#include <string>
#include <map>
#include <vector>
using namespace std;
int main(){
    map<string,int>m;
    string s;
    vector<string>v;
    while(cin>>s){
        if('A'<=s[0]&&s[0]<='Z'){
            s[0]=s[0]-'A'+'a';
        }
        m[s]++;
        v.push_back(s);
    }
    int ans1=-1;
    int ans2=-1;
    string ans1s;
    string ans2s;
    for(int i=0;i<v.size();i++){
        if(ans1<m[v[i]]){
            ans1=m[v[i]];
            ans1s=v[i];
        }
        if(ans2<(int)v[i].size()){
            ans2=v[i].size();
            ans2s=v[i];
        }
    }
    cout<<ans1s<<" "<<ans2s<<endl;
}

Measured memory_bytes: 2988
#include <stdio.h>
int min(int a,int b){
  if(a > b)return b;
  return a;
}
int zet(int a){
  if(a > 0)return a;
  return -a;
}
int main(){
  int n,k,ans = 0;
  scanf("%d %d",&n,&k);
  int a[n];
  for(int i = 0;i < n;i++){
    scanf("%d",&a[i]);
    ans += 2 * min(a[i],k - a[i]);
  }
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128