akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7;

int n,st=1,tot=1,cnt=0;
int head[500005],size[200005],ans[200005];

struct edge
{
	int next;
	int to;
}e[500005];

int quick_power(int a,int b)
{
	if (b==0)  return 1;
	
	int res=1;
	for (;b;b=b>>1,a=(a*a)%mod)
	{
		if (b&1)  res=(res*a)%mod; 
	}
	return res;
}

int ny(int k)
{
	return quick_power(k,mod-2)%mod;
}

int divide(int a,int b)
{
	return (a*ny(b))%mod;
}

inline void add_edge(int u,int v)
{
	cnt++;
	e[cnt].to=v;
	e[cnt].next=head[u];
	head[u]=cnt;
}

inline void dfs(int now,int fath)
{
	size[now]=1;
	for (int i=head[now];i;i=e[i].next)
	{
		if (e[i].to!=fath)
		{
			dfs(e[i].to,now);
			size[now]+=size[e[i].to];
		}
	}
}

inline void change_root(int now,int last)
{
	if (last==0)
	{
		ans[now]=divide(tot,st)%mod;
		for (int i=head[now];i;i=e[i].next)
		{
			if (e[i].to!=last)  change_root(e[i].to,now);
		}
	}
	else
	{
		int x=size[now],y=size[last];
		st=divide(st,size[now])%mod;
		st=divide(st,size[last])%mod;		
		size[last]-=size[now];
		size[now]+=size[last];
		st=(st*size[now])%mod;
		st=(st*size[last])%mod;

		ans[now]=divide(tot,st);
	
		for (int i=head[now];i;i=e[i].next)
		{
			if (e[i].to!=last)  change_root(e[i].to,now);
		}
		st=divide(st,size[last])%mod;
		st=divide(st,size[now])%mod;
		st=(st*y)%mod;
		st=(st*x)%mod;
		size[now]=x;
		size[last]=y;
	}
}

signed main()
{
	cin>>n;
	for (int i=1;i<=n;i++)  tot=(tot*i)%mod;
	for (int i=1;i<n;i++)
	{
		int u,v;
		cin>>u>>v;
		add_edge(u,v);
		add_edge(v,u);
	}
	dfs(1,0);
	for (int i=1;i<=n;i++)  st=(st*size[i])%mod;

	change_root(1,0);
	for (int i=1;i<=n;i++)  cout<<ans[i]%mod<<endl;
	
	return 0;
}

Measured memory_bytes: 16640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 2e5 + 314;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;

void solve(){
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    //
    ll l = 0, r = k, f = -1;

    while(l <= r) {
        ll md = l + r >> 1;
        if(md >= LINF / d) {
            r = md - 1;
            continue;
        }
        if(md * d <= x){
            l = md + 1;
            f = md;
        }else {
            r = md - 1;
        }
    }
    k -= f;
    ll ans = x - d * f;
    if(k % 2)
        ans -= d;
    cout << abs(ans);
    //
    
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ld a[55];
ll C[55][55];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,l,r; cin>>n>>l>>r;
	for(int i=0;i<n;i++) cin>>a[i];
	for(int i=0;i<=n;i++) C[i][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=i;j++)
		{
			C[i][j]=C[i-1][j];
			if(j) C[i][j]+=C[i-1][j-1];
		}
	}
	sort(a,a+n); reverse(a,a+n);
	ld avg = 0;
	for(int i=0;i<l;i++) avg+=a[i];
	avg/=l;
	cout<<fixed<<setprecision(20)<<avg<<'\n';
	ll cnt=0; int fixed=0;
	for(int i=0;i<n;i++)
	{
		if(a[i]==a[l-1]) cnt++;
		if(a[i]>a[l-1]) fixed++;
	}
	l-=fixed; r-=fixed;
	//pick [l,r] from cnt;
	ll ans =0;
	if(fixed==0)
	{
		for(int i=l;i<=r;i++)
		{
			ans+=C[cnt][i];
		}
	}
	else
	{
		ans+=C[cnt][l];
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;

struct node{
	int score;
	int left;
	int right;
};

bool operator< (const node &LHS, const node &RHS){
		return LHS.score < RHS.score;
}

int main()
{
	priority_queue<node,vector<node>> q;
	int n;
	cin>>n;
	vector<int> numList(n);
	for(int i = 0; i < n; i++){
		cin>>numList[i];
	}
	sort(numList.begin(),numList.end(),greater<int>());
	ll ans = 0;
	node node1,node2;
	node1.score = numList[1];
	node1.left = numList[0];
	node1.right = numList[1];
	
	node2.score = numList[1];
	node2.left = numList[0];
	node2.right = numList[1];

	q.push(node1);
	q.push(node2);
	ans += numList[0];
	for(int i = 2; i < n; i++){
		//cout<<q.top().score<<endl;
		node temp = q.top();
		q.pop();
		ans += temp.score;
		node nextNode1,nextNode2;
		nextNode1.score = numList[i];
		nextNode1.left = temp.left;
		nextNode1.right = numList[i];

		nextNode2.score = numList[i];
		nextNode2.left = numList[i];
		nextNode2.right = temp.right;
		q.push(nextNode1);
		q.push(nextNode2);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6700
import sys
from collections import defaultdict

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def main():
	n = int(input())
	al = list(IN())
	odd_dd=defaultdict(lambda : 0)
	odd_dd[-1]=0
	even_dd=defaultdict(lambda :0)
	even_dd[-1]=0
	
	for i, v in enumerate(al):
		if i%2==0:
			odd_dd[v] += 1
		else:
			even_dd[v] += 1
	
	odd_ll=[(odd_dd[key], key) for key in odd_dd.keys()]
	even_ll=[(even_dd[key], key) for key in even_dd.keys()]
	
	odd_ll.sort(reverse=True)
	even_ll.sort(reverse=True)
	kk=n//2
	pa(odd_ll)
	pa(even_ll)
	
	#先頭が同じ
	if odd_ll[0][1] == even_ll[0][1]:
		ra=(kk-odd_ll[0][0])+(kk-even_ll[1][0])
		rb=(kk-odd_ll[1][0])+(kk-even_ll[0][0])
		return min(ra, rb)
	else:
		ret= (kk-odd_ll[0][0])+(kk-even_ll[0][0])
		return ret
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int n; cin >> n;
  vector<int> l(n); rep(i,n) cin >> l[i];

  sort(l.begin(),l.end());
  
  int sum = 0;
  rep(i,n-1) sum+=l[i];

  if(sum>l[n-1]) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main(){
  int i,j,k,n,h,w,x=0,y=0;
  bool ch=true;
  cin >> h >> w;
  char a[h][w],b[h][w],c[h][w];
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      cin >> a[i][j];
    }
  }
  for(i=0;i<h;i++){
    ch = true;
    for(j=0;j<w;j++){
      if(a[i][j]!='.'){
        for(k=0;k<w;k++){
          b[x][k]=a[i][k];
        }
        x++;
        break;
      }
    }
  }
  for(i=0;i<w;i++){
    ch = true;
    for(j=0;j<x;j++){
      if(b[j][i]!='.'){
        for(k=0;k<x;k++){
          c[k][y]=b[k][i];
        }
        y++;
        break;
      }
    }
  }
  for(i=0;i<x;i++){
    for(j=0;j<y;j++){
      cout << c[i][j];
    }
    cout << endl;
  }
  return 0;
}


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

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  int res = 0;
  for (int i = 0; i < n; i++) {
    int minj = i;
    for (int j = i; j < n; j++) {
      if (a[j] < a[minj]) {
        minj = j;
      }
    }
    res += i != minj;
    swap(a[i], a[minj]);
  }
  for (int i = 0; i < n; i++) {
    cout << a[i];
    if (i == n - 1) break;
    cout << ' ';
  }
  cout << '\n' << res << '\n';
  return 0;
}


Measured memory_bytes: 3188
#include <stdio.h>

int t[105];
int v[105];

double maxv[50000];

double min(double a,double b){
	if(a<=b){return a;}
	else{return b;}
}

int main(){

	int N;

	scanf("%d",&N);

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

	for(i=0;i<N;i++){
	scanf(" %d",&v[i]);
	}

	int sum=0;
	for(i=0;i<N;i++){
		for(j=sum;j<=sum+(t[i]*2);j++){
			if(maxv[j]>0){
			maxv[j]=min(maxv[j],(double)v[i]);
			}
			else{
			maxv[j]=(double)v[i];
			}
		}
		sum+=t[i]*2;
	}
	maxv[0]=0;
	maxv[sum]=0;
	for(i=1;i<=sum;i++){
	maxv[i]=min(maxv[i],maxv[i-1]+0.5);
	}
	for(i=(sum)-1;i>=0;i--){
	maxv[i]=min(maxv[i],maxv[i+1]+0.5);
	}

	double ans=0;

	for(i=0;i<sum;i++){
	ans+=(maxv[i]+maxv[i+1])/4.0;
	}
	printf("%lf\n",ans);

	return 0;
}

Measured memory_bytes: 512
n = int(input())
s1 = str(input())
s2 = str(input())

L = []

for i in range(n):
    if s1[i] == s2[i]:
        L.append(0)
    else:
        if i == n-1:
            continue
        if s1[i] == s1[i+1]:
            L.append(1)

m = len(L)
ans = 1
mod = 10**9+7
for i in range(m):
    if i == 0:
        if L[i] == 0:
            ans *= 3
        else:
            ans *= 6
        ans %= mod
    else:
        if L[i-1] == 0 and L[i]== 0:
            ans *= 2
        elif L[i-1] == 0 and L[i] == 1:
            ans *= 2
        elif L[i-1] == 1 and L[i] == 0:
            ans *= 1
        else:
            ans *= 3
        ans %= mod
ans %= mod
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

int main(void) {
    int n;
    cin>>n;
    vector<int> P(n+1);

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

    int ans = 0;
    for(int i = 1;i < n - 1;i++) {
        vector<int> v;
        v.push_back(P[i-1]);
        v.push_back(P[i]);
        v.push_back(P[i+1]);
        sort(v.begin(),v.end());

        if(v[1] == P[i])
            ans++;
    }
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 256
def examA():
    A, B = LI()
    ans = A*B
    print(ans)
    return

def examB():
    N = I()
    A = LI()
    for a in A:
        if a==0:
            print(0)
            return
    ans = 1
    for a in A:
        ans *= a
        if ans>10**18:
            print(-1)
            return
    print(ans)
    return

def examC():
    A, B = list(map(float,input().split()))
    ans = (int(A*B*100))//100
    print(ans)
    return

def examD():
    def factorization(n):
        arr = defaultdict(int)
        temp = n
        for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
            if temp % i == 0:
                cnt = 0
                while temp % i == 0:
                    cnt += 1
                    temp //= i
                arr[i] = cnt
        if temp != 1:
            arr[temp] = 1
        if arr == []:
            arr[n] = 1
        return arr
    C = [0,1,3,6,10,15,21,28,36,45]
    N = I()
    F = factorization(N)
    ans = 0
    #print(F)
    for f in F.values():
        for i in range(10):
            if C[i]>f:
                ans += i-1
                break
    print(ans)
    return

def examE():
    N = I()
    A = [0]*N
    B = [0]*N
    for i in range(N):
        A[i],B[i] = LI()
    A.sort()
    B.sort()
    if N%2==0:
        L = (A[N//2-1] + A[N//2])/2
        R = (B[N//2-1] + B[N//2])/2
        ans = int((R-L)*2) +1
    else:
        L = A[N//2]
        R = B[N//2]
        ans = (R-L)+1

    print(ans)
    return

def examF():
    N, S = LI()
    A = LI()

    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 1<<60
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examE()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Measured memory_bytes: 26236
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
signed main(){
	int H1, M1, H2, M2, K;
	cin >> H1 >> M1 >> H2 >> M2 >> K;

	int minute = max(0, (H2-H1)*60+(M2-M1)-K);

	cout << minute << endl;
 
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=200005,INF=1<<30;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N,K;cin>>N>>K;
    cout<<min(N%K,K-N%K)<<endl;
}



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

#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y
//#define CPP_STR(x) CPP_STR_I(x)
//#define CPP_STR_I(args...) #args
//#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
//using f80 = __float80;
#pragma endregion

#pragma region const
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#pragma endregion

#pragma region util
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T(&)[N]) { return static_cast<i64>(N); }

template<typename T, typename U, typename Comp = less<>>
bool chmax(T& xmax, const U& x, Comp comp = {}) {
	if (comp(xmax, x)) {
		xmax = x;
		return true;
	}
	return false;
}
template<typename T, typename U, typename Comp = less<>>
bool chmin(T& xmin, const U& x, Comp comp = {}) {
	if (comp(x, xmin)) {
		xmin = x;
		return true;
	}
	return false;
}
#pragma endregion

#pragma region init
struct ProconInit {
	static constexpr int IOS_PREC = 15;
	static constexpr bool AUTOFLUSH = false;

	ProconInit() {
		cin.tie(nullptr);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(IOS_PREC);
		if (AUTOFLUSH)
			cout << unitbuf;
	}
} PROCON_INIT;
#pragma endregion

int main()
{
	class Rest
	{
	public:
		i64 no;
		string city;
		i64 score;
	};

	i64 N;
	cin >> N;
	vector<Rest> R(N);
	REP(i, N)
	{
		R[i].no = i + 1;
		cin >> R[i].city;
		cin >> R[i].score;
	}

	ALL(sort, R, [](Rest l, Rest r) -> bool
	{
		if (l.city < r.city) return true;
		if (l.city > r.city) return false;
		if (l.score < r.score) return false;
		if (l.score > r.score) return true;
		return false;
	});

	REP(i, N)
	{
		cout << R[i].no << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <array>
int main(void){
	int a, b, c,count=0;
	std::cin >> a >> b >> c;
	for (a; a <= b; a++){
		if (c%a == 0){
			count++;
		}
	}
	std::cout << count << std::endl;
	return 0;
}

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

using namespace std;

typedef int64_t ll;
#define For(i, a, b) for(ll i = a; i <= b; i++)

ll d, t, s;

void process()
{
    if (d / s < t || (d / s == t && d % s == 0))
        cout << "Yes" << "\n";
    else
        cout << "No" << "\n";
}

void input()
{
    cin >> d >> t >> s;
}

int main()
{
    input();
    process();
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

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

int N, A[112345];

int main() {

	scanf("%d", &N);
	rep(i, N) scanf("%d", &A[i]);

	sort(A, A + N);

	if (A[0] >= 0) {
		if (N == 2) {
			printf("%d\n%d %d\n", A[1] - A[0], A[1], A[0]);
			return 0;
		}
		else {
			vector<pair<int, int>> ans;
			int cur = A[0];
			rep(i, N - 2) {
				ans.push_back({ cur, A[i + 1] });
				cur = cur - A[i + 1];
			}
			ans.push_back({ A[N - 1], cur });
			printf("%d\n", A[N - 1] - cur);
			for (auto a : ans) printf("%d %d\n", a.first, a.second);
			return 0;
		}
	}
	else if (A[N - 1] < 0) {
		vector<pair<int, int>> ans;
		int cur = A[N - 1];
		rep(i, N - 1) {
			ans.push_back({ cur, A[N - 2 - i] });
			cur = cur - A[N - 2 - i];
		}
		printf("%d\n", cur);
		for (auto a : ans) printf("%d %d\n", a.first, a.second);
		return 0;
	}
	else {
		if (N == 2) {
			printf("%d\n%d %d\n", A[1] - A[0], A[1], A[0]);
			return 0;
		}
		int s = lower_bound(A, A + N, 0) - A;
		vector<pair<int, int>> ans;
		int cur1 = A[0];
		for (int i = s; i < N - 1; ++i) {
			ans.push_back({ cur1, A[i] });
			cur1 = cur1 - A[i];
		}
		int cur2 = A[N - 1];
		for (int i = 0; i < s - 1; ++i) {
			ans.push_back({ cur2, A[i+1] });
			cur2 = cur2 - A[i+1];
		}
		ans.push_back({ cur2, cur1 });
		printf("%d\n", cur2 - cur1);
		for (auto a : ans) printf("%d %d\n", a.first, a.second);
		return 0;
	}

	return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;

int64_t dfs(const vector<vector<int64_t>>& links, int64_t v, vector<int64_t>* dp) {
    if ((*dp)[v] >= 0) {
        return (*dp)[v];
    }

    int64_t w = 0;
    for (const auto& dst : links[v]) {
        w = max(w, dfs(links, dst, dp) + 1);
    }

    (*dp)[v] = w;

    return w;
}

main() {
    int64_t n, m;
    cin >> n >> m;

    vector<vector<int64_t>> links(n);
    for (auto _ : irange(0L, m)) {
        int64_t src, dst;
        cin >> src >> dst;
        links[src - 1].push_back(dst - 1);
    }

    vector<int64_t> dp(n, -1);
    for (auto v : irange(0L, n)) {
        dfs(links, v, &dp);
    }

    cout << *max_element(dp.begin(), dp.end()) << endl;
}

Measured memory_bytes: 9216
#include<bits/stdc++.h>
#define rep(i,n) for (int i=1; i<=n; i++)
using namespace std;
int main(){
    int K;
    cin >> K;
    int sum = 0;
    rep (i,K) rep(j,K) rep(l,K) sum += gcd(i, gcd(j, l));
    cout << sum;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int>data(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        data[a-1]++;
        data[b-1]++;
    }
    rep(i,n)cout << data[i] << endl;
    return 0;
}

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

namespace Myatcoder
{
    public class Program
    {
        public static void Main()
        {
            Console.ReadLine();
            int[] A = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            int max = A.Max();
            int min = A.Min();
            Console.WriteLine(max - min);
        }
    }
}

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

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define MOD 1000000007

#define trace1(x)                    cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;

typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    ll i,j,n,m;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll cnt=0;
    for(i=1;i<n-1;i++)
    {
        if(max(a[i+1],a[i-1])>a[i] && min(a[i+1],a[i-1])<a[i])
        cnt++;
    }
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main (){
    int p[10];
    int N;
    int M = 0;
    int Mth;
    cin>>N;
    int sum =0;
    for (int i = 0; i < N; i++){
        cin>>p[i];
    }
    for (int i = 0; i < N; i++){
        if(p[i]>M){
            M = p[i];
            Mth = i;
        }
    }
    p[Mth] = p[Mth]/2;
    for(int i = 0; i<N; i++){
        sum += p[i];
    }
    cout<<sum;
}

Measured memory_bytes: 256
def main():
  N, M = map(int, input().split())
  edge = [[[] for _ in range(3)] for _ in range(N)]
  for i in range(M):
    u, v = map(int, input().split())
    edge[u-1][0].append([v-1,1])
    edge[u-1][1].append([v-1,2])
    edge[u-1][2].append([v-1,0])
  d = [[-1]*3 for _ in range(N)]
  S, T = map(int, input().split())
  d[S-1][0] = 0
  que = [[S-1, 0]]
  while len(que)>0:
    now = que.pop(0)
    for nex in edge[now[0]][now[1]]:
      if d[nex[0]][nex[1]] != -1:continue
      d[nex[0]][nex[1]] = d[now[0]][now[1]]
      if now[1] == 2:
        d[nex[0]][nex[1]] += 1
      que.append(nex)
  print(d[T-1][0])
  
if __name__ == "__main__":
  main()

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N;
    cin>>N;
    vector<ll> A(N);
    REP(i,N) cin>>A[i];
    vector<ll> B(N);
    REP(i,N) B[i] = A[i] - i - 1;
    sort(ALL(B));
    ll b;
    if (N%2 == 1) {
        b = B[N/2];
    }
    else {
        b = (B[N / 2 - 1] + B[N/2]) / 2;
    }
    ll sad = 0;
    REP(i,N) {
        sad += abs(A[i] - (b + i + 1));
    }
    cout<<sad<<endl;
    return 0;
}

Measured memory_bytes: 3328
io = STDIN
n=io.gets.to_i
a=io.gets.split.map(&:to_i).sort
max=0
ans=a[0]
l=a[-1]
near=l
aaa = a[0]
a[0..-2].each do |aa|
  if near > (aa-l/2.0).abs
    near = (aa-l/2.0).abs
    aaa=aa
  end
end
puts "#{l} #{aaa}"


Measured memory_bytes: 10112
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
string slowo;
int i[400];
int main()
{
	ios_base::sync_with_stdio( 0 );
	cin.tie( 0 );
	cin>>slowo;
	for( int a = 0; a < slowo.size(); a++ )
	{
		if( slowo[a] >= 'a' && slowo[a] <= 'z' )i[int( slowo[a] )]++;	
	}
	for( int a = 1; a <= 300; a++ )
	{
		if( i[a]%2 )
		{
			cout<<"No";
			return 0;	
		}
	}	
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

template<typename T>
constexpr std::vector<std::pair<T, T>> primeFactorization(T number) noexcept {
	std::vector<std::pair<T, T>> primeFactors;
	T quotient = number;
	for (T i = 2; i * i <= quotient; ++i) {
		if (quotient % i == 0) {
			T prime = i, power = 1;

			quotient /= i;
			while (quotient % i == 0) {
				++power;
				quotient /= i;
			}

			primeFactors.push_back(std::pair<T, T>(prime, power));
		}
	}
	if (quotient != 1) primeFactors.push_back(std::pair<T, T>(quotient, 1));

	return primeFactors;
}

template<typename T>
constexpr int countDivisor(std::vector<std::pair<T, T>> primeFactors) noexcept {
	int counter = 1;
	for (int i = 0; i < primeFactors.size(); ++i) {
		counter *= (primeFactors[i].second + 1);
	}

	return counter;
}

template<typename T>
constexpr std::vector<T> findDivisor(T number) noexcept {
	std::vector<std::pair<T, T>> primeFactors = primeFactorization(number);

	std::vector<T> divisor(countDivisor(primeFactors));
	divisor[0] = 1;

	int counter = 1;
	for (int i = 0; i < primeFactors.size(); ++i) {
		int currentSize = counter;
		for (int j = 1; j <= primeFactors[i].second; ++j) {
			T x = 1;
			for (int k = 0; k < j; ++k) {
				x *= primeFactors[i].first;
			}

			for (int k = 0; k < currentSize; ++k) {
				divisor[counter + k] = divisor[k] * x;
			}
			counter += currentSize;
		}
	}
	sort(divisor.begin(), divisor.end());

	return divisor;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	int* a = new int[n];
	rep(i, n) cin >> a[i];

	int* k = new int[1000001];
	memset(k, 0, sizeof(int) * 1000001);
	rep(i, n) ++k[a[i]];

	int ans = n;
	rep(i, n) {
		if (k[a[i]] >= 2) {
			--ans;
			continue;
		}

		vector<int> divisor = findDivisor(a[i]);
		rep(j, divisor.size() - 1) {
			if (k[divisor[j]]) {
				--ans;
				break;
			}
		}
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 8344
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b float64
	var v, w, t int64
	fmt.Scan(&a, &v, &b, &w, &t)

	vt := v * t
	wt := w * t

	if vt >= wt+int64(math.Abs(b-a)) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1808
#include <bits/stdc++.h>
#define ld long double
#define ll long long int
#define mod 1000000007
#define ll_inf 1000000000000000000
#define int_inf 1000000000
#define pb push_back
#define endl '\n'
#define Endl '\n'
#define eps 1e-9
#define PI acos(-1.0)
#define ii pair<int,int>
#define se second
#define fi first
#define prout(x) cout.precision(x)
using namespace std;
map<ll,ll>dp[101];
int n;
ll W, w[101], v[101];
ll cal(int pos, int rem){
    //cout<<pos<<" "<<rem<<endl;
    if(pos==n)return 0;
    if(dp[pos].count(rem))return dp[pos][rem];
    if(rem<w[pos])return dp[pos][rem]=cal(pos+1, rem);
    return dp[pos][rem]=max(cal(pos+1, rem), v[pos]+cal(pos+1, rem-w[pos]));
}
int main(){
    cin>>n>>W;
    for(int i=0;i<n;i++){
        cin>>w[i]>>v[i];
    }
    cout<<cal(0,W)<<endl;
}



Measured memory_bytes: 6272
# include <bits/stdc++.h>
  typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second
#define all v.begin(),v.end()
#define fio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
typedef unsigned long long ulll;
 
using namespace std ;
int main () {

 int a,b;
 cin>>a>>b;
 
 int c = a*b;
 
 if(c&1)
    cout<<"Odd";
    
    else
    cout<<"Even";
   
  return 0;
}

Measured memory_bytes: 256
from collections import deque
h, w = map(int, input().split())
C = [list(input()) for _ in range(h)]
# '#'の地点をスタートとしてqueに全部入れる
# その際にseenもかねたdist配列を-1で初期化して，スタート地点だけ0にする，（-1のところは未踏）
# タプルでqueに入れると少し早くなるらしい
que = deque()
dist = [[-1] * w for _ in range(h)]
for y in range(h):
    for x in range(w):
        if C[y][x] == '#':
            que.append((y, x))
            dist[y][x] = 0

while len(que) > 0:
    # 現在地点の座標と距離を取得
    now_y, now_x = que.popleft()
    now_d = dist[now_y][now_x]
    for dy, dx in ((1,0), (-1, 0), (0, 1), (0, -1)):
        next_y = now_y + dy
        next_x = now_x + dx
        if 0 <= next_y < h and 0 <= next_x < w:
            if dist[next_y][next_x] == -1:
                # もしまだ見ていない地点ならqueに追加し，distを現在の距離+1に更新する
                que.append((next_y, next_x))
                dist[next_y][next_x] = now_d + 1

print(now_d)


Measured memory_bytes: 122844
import math
        
def func(A, B):
    tmp = 0
    for a, b in zip(A,B):
        tmp += (a- b)**2
        
    return math.sqrt(tmp)
N, D = list(map(int, input().split(" ")))

X = []
cnt = 0
for _ in range(N):
      X.append(list(map(int, input().split(" "))))

for i in range(N-1):
    for j in range(i+1,N):
        ans = func(X[i], X[j])
        if ans % 1 == 0:
            cnt += 1
            
print(cnt)

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

int main(){
  ll n, a, b, c, tmp;
  cin >> n;
  a=b=c=0;
  ll ans=1;
  ll count=0;
  for(int i=0; i<n; i++){
    count = 0;
    cin >> tmp;
    if(a==tmp){
      a++;count++;
      if(b==tmp){count++;}
      if(c==tmp){count++;}
    }else if(b==tmp){
      b++;count++;
      if(c==tmp){count++;}
    }else if(c==tmp){c++;count++;}
    ans = (ans%1000000007)*count;
  }
  cout << ans%1000000007 << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

c = [0 for i in range(n+1)]
comb = [0 for i in range(n+1)]

for i in range(n):
    c[a[i]] += 1
for i in range(1, n+1):
    if c[i] >= 2:
        comb[i] = int(c[i]*(c[i]-1)/2)

s = sum(comb)
for i in range(n):
    tmp = s - comb[a[i]]
    if c[a[i]]-1 <= 1:
        print(tmp)
    else:
        print(tmp+int((c[a[i]]-1)*(c[a[i]]-2)/2))


Measured memory_bytes: 32428
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

s = stdin.readline().rstrip()
k = int(stdin.readline().rstrip())


finish = set()
S = len(s)

for i in range(S):
    for j in range(1,6):
        finish.add(s[i:i+j])

finish = list(finish)
finish.sort()

print(finish[k-1])

Measured memory_bytes: 4464
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = Integer.toString(n);
        int ans = 0;
        for (int i=0;i<s.length();i++){
            ans+=s.charAt(i)-'0';
        }
        if (n%ans==0)System.out.println("Yes");
        else System.out.println("No");
    }
}


Measured memory_bytes: 35572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x;
  cin >> x;
  int fx = x % 10;
  
  for(int i = x; i >= 10; i /= 10){
    fx += i / 10 % 10;
  }
  
  if(x % fx == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
N = int(input())
D = list(map(int,input().split()))

D.sort()
T = []
for i,d in enumerate(D):
    if i % 2 == 1:
        d = 24- d
    T.append(d)

T.sort()
T = [0] + T
MIN = 24
for i in range(N):
    diff = T[i+1] - T[i]
    MIN = min(diff,MIN)
print(MIN)


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

using namespace std;

#define int long long

template <typename T> T gcd(T m, T n) { return n == 0 ? m : gcd(n, m % n); }
template <typename T> T lcm(T m, T n) { return n * m / gcd(n, m); }
template <typename T> T fact(T n) { return (n == 0 ? 1 : n * fact(n - 1)); }
template <typename T> T modpow(T a, T e, T m) { return (e == (T)0 ? 1 : ((a % m) * modpow((a % m), e - 1, m)) % m); }

constexpr int MOD = 1e9 + 7;

signed main(void) {
  string s;
  cin >> s;

  int num = 0;
  // s[i] s[s.length - (i + 1)]

  
  for (int i = 0; i < s.length() / 2; ++i) {
    if (*(s.begin() + i) != *(s.rbegin() + i)) { ++num; }
  }
  cout << num << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	static void add_point(int[] point, int a, int b, int ascore, int bscore) {
		int diff = ascore - bscore;
		if(diff == 0) {
			point[a]++;
			point[b]++;
		} else if(diff > 0)
			point[a] += 3;
		else
			point[b] += 3;
	}
	
	static void print_rank(int[] point) {
		int[] rank = new int[point.length];
		int idx = 0, count = 1;
		
		for(int r = 0; r < point.length; r++) {
			int max = point[0];
			for(int c = 0; c < point.length; c++) {
				if(point[c] > max) {
					max = point[c];
					idx = c;
				}
			}
			final int cnt = count;
			for(int c = idx; c < point.length; c++) {
				//final int cnt = count; //怪しい箇所
				if(point[c] == max) {
					rank[c] = cnt;
					point[c] = -1;
					if(c != idx) count++;
				}
			}
			count++;
		}
		
		for(int r = 1; r < point.length; r++) {
			System.out.println(rank[r]);
		}
	}
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner stdIn = new Scanner(System.in);
		
		int team = stdIn.nextInt();
		int[] point = new int[team + 1];
		final int match_num = team * (team - 1) / 2;
		//System.out.println(match_num); DEBUG
		for(int r = 0; r < point.length; r++)
			point[r] = 0;
		
		for(int r = 0; r < match_num; r++) {
			int a = stdIn.nextInt();
			int b = stdIn.nextInt();
			int ascore = stdIn.nextInt();
			int bscore = stdIn.nextInt();
			
			add_point(point, a, b, ascore, bscore);
		}
		/*for(int r = 1; r < point.length; r++) {
			System.out.println("DEBUG:" + point[r]);
		} DEBUG*/ 
		print_rank(point);
	}

}

Measured memory_bytes: 41928
import java.util.*;
import java.io.*;
import static java.lang.System.in;

public class Main {
    static int n,m,C;
    static int[] B;
    static HashSet<Integer>[] graph;
    public static void main(String[] args)throws IOException {
        //BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt(); m = sc.nextInt(); C = sc.nextInt();
        B = new int[m];
        for(int i=0;i<m;i++) B[i]=sc.nextInt();
        int[] a = new int[m];
        int ans = 0;
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++) a[j] = sc.nextInt();
            if(check(a)) ans++;
        }
        System.out.println(ans);
    }
    static boolean check(int[] a){
        int res = C;
        for(int j=0;j<m;j++) res += a[j]*B[j];
        return res>0;
    }
}

Measured memory_bytes: 22228
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

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

#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define dloop(i,n) for(int i=n-1;i>=0;i--)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

int32_t main(){
	NINJA;

	int n; cin >> n;
	
	if(n>=400 && n<=599)cout << 8 << endl;
	if(n>=600 && n<=799)cout << 7 << endl;
	if(n>=800 && n<=999)cout << 6 << endl;
	if(n>=1000 && n<=1199)cout << 5 << endl;
	if(n>=1200 && n<=1399)cout << 4 << endl;
	if(n>=1400 && n<=1599)cout << 3 << endl;
	if(n>=1600 && n<=1799)cout << 2 << endl;
	if(n>=1800 && n<=19999)cout << 1 << endl;



	
	return 0;
}

Measured memory_bytes: 3636
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 4e5 + 10 ;
const ll INF = 1e18 + 10 ;
int main(){
    fastio
    int n ;
    cin >> n ;
    vector<int> p(n) , q(n) ; 
    for(int i = 0; i < n; i++){
        cin >> p[i] ; 
    }
    for(int i = 0; i < n; i++){
        cin >> q[i] ; 
    }
    vector<int> t = q ; 
    sort(t.begin(), t.end()) ; 
    int cnt = 0 ; 
    int a = 0 , b = 0 ; 
    do{
        if ( t == p ) a = cnt ; 
        if ( t == q ) b = cnt ; 
        cnt++ ; 
    }while(next_permutation(t.begin(), t.end()));
    cout << abs(a - b) << endl;
    return 0; 
}

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

int main()
{
  int N;
  cin >> N;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  int64_t ma = 0, ans = 0;
  for (int i = 0; i < N; i++)
  {
    if (ma > A.at(i))
    {
      ans += (ma - A.at(i));
    }
    ma = max(ma, A.at(i));
  }
  cout << ans << endl;
}


Measured memory_bytes: 4840
from collections import deque

k = int(input())
q = deque()

for i in range(1, 10):
    q.append(i)

while True:
    # print(q)
    if len(q)>= k:
        print(q[k-1])
        exit()
    k -= len(q)

    for _ in range(len(q)):
        x = q.popleft()
        for i in [-1, 0, 1]:
            d = x % 10 + i
            if d < 0 or d > 9:
                continue
            q.append(10 * x + d)


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H); //H個の文字列
  for(int i = 0; i < H; i++){
    cin >> S[i];
  }

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

      if(S[i][j] == '.'){ //もし空きマスなら0にする
        S[i][j] = '0';

        for(int dx = -1; dx <= 1; dx++){ // 変数dxを-1,0,1で回す
          for(int dy = -1; dy <= 1; dy++){
            int nx = i + dx,  ny = j + dy;
            // i,j と足すことで周囲八方を確認するためのnx,nyを用意
            if(0 <= nx && nx < H && 0 <= ny && ny < W){
              if(S[nx][ny] == '#') S[i][j]++;
              //  もし爆弾マスなら元のマスをインクリメント
            }
          }
        }
      }
    }
  }
  for(int i = 0; i < H; i++){
    cout << S[i] << endl;
  }
}


Measured memory_bytes: 3624
m = map(int, raw_input().split())
a = [map(int, raw_input().split()) for i in xrange(m[0])]
b = [int(raw_input()) for i in xrange(m[1])]
for i in xrange(m[0]):
    print sum(a[i][j] * b[j] for j in xrange(m[1]))

Measured memory_bytes: 6468
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,j=0,k,sum=0,a;
    cin>>m;
    cin>>n;
    cin>>k;
    if(m>n)
    {
        j = k/m;
        if(k%m==0)
        {
            cout<<j;
        }
        else
        {
            cout<<j+1;
        }
    }
    else
    {
        i = k/n;
        if(k%n==0)
        {
            cout<<i;
        }
        else
        {
            cout<<i+1;
        }
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, A, B;
    cin >> N;
    pair<int , int> p[200000];
    for(int i=0;i<N;i++){
        cin >> A >> B;
        p[i] = make_pair(B, A);
    }
        
    // 昇順ソート（第一要素）
    int time = 0;
    sort(p, p + N);
    for(int i=0;i<N;i++){
        time += p[i].second;
        if(time > p[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 1005;

int cnt[MAX_N][MAX_N];
int n, D, mx;
int sm[2*MAX_N][2*MAX_N][2];

#define comp(a, b, c, d, k) (sm[c+1][d+1][k] - sm[c+1][b][k] - sm[a][d+1][k] + sm[a][b][k])

bool possible(int b)
{
    rep(i,D){
        rep(j,D){
            if(comp(i+b+1,j+b+1,i+D-1,j+D-1,0) == 0 && comp(i+b+1,j,i+D-1,j+b,1) == 0 && comp(i,j+b+1,i+b,j+D-1,1) == 0) return true;
        }
    }
    return false;
}

#define getchar getchar_unlocked

inline int in() {
    int n = 0; short c;
    while ((c = getchar()) >= '0') n = n * 10 + c - '0';
    return n;
}

int main()
{
    n = in(), D = in();
    rep(i,n){
        int x = in(), y = in();
        cnt[x%D][y%D]++;
    }
    rep(i,D){
        rep(j,D){
            cmx(mx,(int)ceil(sqrt(cnt[i][j]))-1);
        }
    }
    rep(i,D){
        rep(j,D){
            sm[i+1][j+1][0] = sm[i+D+1][j+1][0] = sm[i+1][j+D+1][0] = sm[i+D+1][j+D+1][0] = (cnt[i][j] > mx*mx);
            sm[i+1][j+1][1] = sm[i+D+1][j+1][1] = sm[i+1][j+D+1][1] = sm[i+D+1][j+D+1][1] = (cnt[i][j] > mx*(mx+1));
        }
    }
    rep(i,2*D+1){
        rep(j,2*D){
            rep(k,2){
                sm[i][j+1][k] += sm[i][j][k]; 
            }
        }
    }
    rep(j,2*D+1){
        rep(i,2*D){
            rep(k,2){
                sm[i+1][j][k] += sm[i][j][k];
            }
        }
    }
    int l = -1, r = D-1;
    while(r-l>1){
        int mid = (l+r)/2;
        if(possible(mid)){
            r = mid;
        }else{
            l = mid;
        }
    }
    cout << (ll)mx*D+r << "\n";
    return 0;
}

Measured memory_bytes: 35712
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int A[100005];
int B[100001];
int main(){
    int N;cin >> N;
    rep(i,N-1){
        cin >> B[i];
    }
    A[0] = B[0];
    for(int i=1;i<N-1;i++){
        A[i] = min(B[i],B[i-1]);
    }
    if(N-2>=0){
    A[N-1] = B[N-2];
    }
    ll ans = 0;
    for(int i=0;i<N;i++){
        ans += A[i];
        //cout << A[i] << endl;
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
fun main (args : Array<String>) {
	val n = readLine()
	val N : Int = n!!.toInt()
	var X : Float
	var U : String
	var xList : MutableList<Float> = mutableListOf()
	var uList : MutableList<String> = mutableListOf()
	var result : Double = 0.0
	for (i in 0..N - 1) {
		val (x, u) = readLine()!!.split(" ")
		X = x.toFloat()
		U = u.toString()
		xList.add(X)
		uList.add(U)
	}
	
	for (i in 0..N - 1) {
		if (uList[i] == "JPY") {
			result += xList[i]
		} else if (uList[i] == "BTC") {
			result += (xList[i] * 380000.0)
		}
	}
	
	println("${result}")
	
}

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

int main()
{
    std::string input;

    std::cin >> input;

    if (input <= "2019/04/30")
    {
        std::cout << "Heisei" << std::endl;
    }
    else
    {
        std::cout << "TBD" << std::endl;
    }
    return 0;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		Pair[] robots = new Pair[n];
		Arrays.setAll(robots, i -> {
			int x = sc.nextInt();
			int l = sc.nextInt();
			return new Pair(x - l, x + l);
		});
		Arrays.sort(robots, (r1, r2) -> r1.right - r2.right);
		
		int cur = Integer.MIN_VALUE;
		int cnt = 0;
		
		for (int i = 0; i < n; i++) {
			if (cur <= robots[i].left) {
				cnt++;
				cur = robots[i].right;
			}
		}
		
		System.out.println(cnt);
		sc.close();
	}
	
}

class Pair {
	int left;
	int right;
	
	Pair(int left, int right) {
		this.left = left;
		this.right = right;
	}
}



Measured memory_bytes: 54884
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

import collections
import fractions

a, b = map(int,input().split())
gcd = fractions.gcd(a, b)

c = collections.Counter(prime_factorize(gcd))
print(len(c.keys())+1)

Measured memory_bytes: 5056
H,W = map(int,input().split())
a = [list(input())for i in range(H)]
ans = [['#']*(W+2) for i in range(H+2)]
for i in range(H):
  ans[i+1][1:W+1] = a[i]
[print(''.join(ans[i])) for i in range(H+2)]

Measured memory_bytes: 3188
n=input()
a=list(map(int,input().split()))
b=[i for i in a if i%2==0]
c=len(b)
d=[i for i in b if i%3==0]
e=len(d)     
f=[i for i in b if i%5==0]
g=len(f)
h=[i for i in b if i%15==0]
j=len(h)
if c==e+g-j:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  lvector A(n,0);rep(i,n) cin>>A[i];
  ll tag=1;
  for(ll a:A) if(a==tag) tag++;
  print((tag>1)?n-(tag-1):-1);
  return 0;
}

Measured memory_bytes: 1792
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    ll arr[4];
    for(int i = 0; i < 4; i++)
        cin>>arr[i];
    ll ans = 0;
    ans = max(arr[0]*arr[2], arr[1]*arr[3]);
    ans = max(ans, arr[1]*arr[2]);
    ans = max(ans, arr[3]*arr[0]);
    cout<<ans;
}
int main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}

Measured memory_bytes: 3648
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<stack>
using namespace std;


int main()
{
	int D, T, S;
	cin >> D >> T >> S;

	if (D <= S * T)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}


}


Measured memory_bytes: 3632