akhauriyash/Code-Regression huggingface dataset:
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**8) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,m = li()
ball = [1]*n
inred = [0]*n
inred[0] = 1

for _ in range(m):
    x,y = li_()
    if inred[x] and ball[x] == 1:
        inred[x] = 0
        ball[x] = 0
        
        inred[y] = 1
        ball[y] += 1
        
    elif inred[x] and ball[x] > 1:
        ball[x] -= 1
        
        inred[y] = 1
        ball[y] += 1
        
    else:
        ball[x] -= 1
        ball[y] += 1
        
ans = 0
for ri in inred:
    ans += ri
print(ans)


Measured memory_bytes: 4596
from collections import Counter
n = int(input())
s = input()
c = Counter(s)
for i in range(n-1):
    s = input()
    s = Counter(s)
    for i in s:
        if c[i]:
            c[i] = min(c[i],s[i])
    for i in c:
        if not s[i]:
            c[i] = 0
ans = ''
for i in c:
    ans += i*c[i]
print(''.join(sorted(ans)))

Measured memory_bytes: 39408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);
int main() {
ll n;
cin >> n;
map<string,ll> mp;
rep(i,n){
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  mp[s]++;
}
ll ans = 0;
for(auto itr = mp.begin(); itr != mp.end(); itr++){
  ll x = itr->second;
 ans += x*(x-1)/2;
}
cout << ans << endl;
 
}

Measured memory_bytes: 11356
s = [int(x) for x in list(input())]
a = [x%2 for x in range(len(s))]
b = [(1 - x%2) for x in range(len(s))]
c1=0
c2=0
for i in range(len(s)):
    if a[i] != s[i]:
        c1 += 1
    if b[i] != s[i]:
        c2 += 1

print(min([c1,c2]))

Measured memory_bytes: 5404
S = input().split(" ")
n = int(S[0])
k = int(S[1])

arr = []
for i in range(n):
    arr.append(int(input()))



def calculate(n,k,arr):
    brr = []
    arr.sort()
    for i in range(1,n):
        brr.append(arr[i] - arr[i-1])

    j = 0
    s = 0
    sums = []
    for i in range(0,len(brr) - (k-1) + 1):
        while j < i + (k-1):
            s = s + brr[j]
            j = j + 1
        sums.append(s)
        s = s - brr[i]

    print(min(sums))



calculate(n,k,arr)

Measured memory_bytes: 15564
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
const int N=2e6+3;
const int mod=1e9+7;
int f[N];int inv[N];int len;
int modp(int a,int b)
{
	if(b==0)return 1;
	int u=modp(a,b/2);
	u=(u*u)%mod;
	if(b&1)return (a*u)%mod;
	return u;
}
int ncr(int n,int r)
{
	if(n<r)return 0;
	int res=(f[n]*inv[r])%mod;
	res*=inv[n-r];
	res%=mod;
	return res;
}
int p(int n)
{
	int res=modp(25,len-n);
	res*=ncr(len,n);
	return res%mod;
}
int32_t main()
{
	f[0]=1;inv[0]=modp(f[0],mod-2);
	for(int i=1;i<N;i++)
	{
		f[i]=(f[i-1]*i)%mod;
		inv[i]=modp(f[i],mod-2);
	}
	
	int n,k;
	cin>>k;
	string s;
	cin>>s;
	n=s.length();
	len=n+k;
	int base=modp(26,len);
	int sum=0;
	for(int i=0;i<n;i++)
	{
		sum+=p(i);
		sum%=mod;
	}
	cout<<(base-sum+mod)%mod;
	
}

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

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans=n;
    for(int i=0; i<n-1; i++){
        if(s[i] ==s[i+1]){
            ans --;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3684
h,w = map(int,input().split())

ans = h*w
for i in range(1,h):
  a = w*i
  b1 = w*((h-i+1)//2)
  c1 = w*((h-i)//2)
  #print("{} {} {}".format(a,b1,c1))
  ans = min(max(a,b1,c1)-min(a,b1,c1),ans)
  b2 = (h-i)*((w+1)//2)
  c2 = (h-i)*(w//2)
  #print("{} {} {}".format(a,b2,c2))
  ans = min(max(a,b2,c2)-min(a,b2,c2),ans)
for i in range(1,w):
  a = h*i
  b1 = h*((w-i+1)//2)
  c1 = h*((w-i)//2)
  #print("{} {} {}".format(a,b1,c1))
  ans = min(max(a,b1,c1)-min(a,b1,c1),ans)
  b2 = (w-i)*((h+1)//2)
  c2 = (w-i)*(h//2)
  #print("{} {} {}".format(a,b2,c2))
  ans = min(max(a,b2,c2)-min(a,b2,c2),ans)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> p;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9



int main() {
	double T, X;
	cin >> T >> X;
	cout << T / X << endl;


	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int mod = 1000000007;
const int tmpMod = 998244353;

int main() {
  double a,b,h,m;
  double ans;
  cin>>a>>b>>h>>m;
  double ag,bg,k;
  ag=(h*PI)/6;
  bg=(m*PI)/30;
k=abs(h*30+(m/2)-m*6);// cout<<k<<endl;
 if(k>=180)k=360-k;
// cout<<k<<endl;
k*=M_PI;
k/=180;
  ans = (b * b) + (a * a) - (2 * b * a * cos( k )); // cout<<ans<<endl;
 // ans = (b * b) + (a * a) - (2 * b * a * cos( abs(h*30-m*6) )); // cout<<ans<<endl;
/* 平方根 */
ans = sqrt( ans );
  //vector<int64_t> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  cout <<setprecision(12)<< ans << endl;
}


Measured memory_bytes: 4192
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<cstring>
using namespace std;
#define LL long long
#define maxn 100010
#define inf 0x3f3f3f3f

int n,k;
int a[maxn];
int cost=inf;

int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",a+i);

	for(int i=1;i<=n-k+1;i++){
		int l=i,r=i+k-1;
		if((LL)a[l]*a[r]<0)cost=min(cost,min(2*abs(a[l])+abs(a[r]),2*abs(a[r])+abs(a[l])));
		else if(a[l]<0) cost=min(cost,abs(a[l]));
		else cost=min(cost,abs(a[r]));
	}
	cout<<cost<<endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(), (a).end()
#define int long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz() size()
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define rc(s) return cout<<s,0
using namespace std;

int n,a[25];

int32_t main(){
    ios_base::sync_with_stdio(0);cin.tie();cout.tie();
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    int maxi=0,ans=0;
    for(int i=1;i<=n;i++){
        maxi=max(maxi,a[i-1]);
        if(a[i]>=maxi) ans++;
    }
    rc(ans);
}



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

typedef long long ll;

const int MAXN = 3002;

ll dp[MAXN][MAXN];
bool vis[MAXN][MAXN];
int A[MAXN],N;

ll solve(int i,int j){

	if(vis[i][j]) return dp[i][j];

	vis[i][j] = 1;

	if(i == j) return dp[i][j] = A[i];

	return dp[i][j] = max(A[i] - solve(i+1,j), A[j] - solve(i,j-1));

}

int main(){

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

	cout << solve(1,N) << endl;

	return 0;

}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

vector<vector<uint64_t> > mult(const vector<vector<uint64_t>>& A, const vector<vector<uint64_t>>& B, const uint64_t M)
{
	int N = A.size();
	vector<vector<uint64_t>> res(N, vector<uint64_t>(N));
	forn(i, N)
	{
		forn(j, N)
		{
			forn(k, N)
			{
				res[i][j] = (res[i][j] + A[i][k] * B[k][j]) % M;
			}
		}
	}
	return res;
}

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	int N;
	uint64_t K;
	constexpr uint64_t M = 1e9 + 7;
	cin >> N >> K;
	vector<vector<uint64_t> > A(N, vector<uint64_t>(N)), B(N, vector<uint64_t>(N));
	for (auto& ar : A)
	{
		for (auto& ai : ar)
		{
			cin >> ai;
		}
	}
	forn(i, N)
		B[i][i] = 1;
	while (K)
	{
		if (K & 1)
		{
			B = mult(A, B, M);
		}
		A = mult(A, A,M);
		K >>= 1;
	}
	uint64_t res = 0;
	for (auto ar : B)
	{
		for (auto ai : ar)
			res += ai;
	}
	cout << res % M << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <utility>
#define llint long long

using namespace std;
typedef pair<llint, llint> P;

struct edge{
	llint to, cost;
	edge(){}
	edge(llint a, llint b){
		to = a, cost = b;
	}
};

llint n, m;
vector<edge> G[100005];
P p[100005];
bool used[100005];

void dfs(llint v, llint pre)
{
	used[v] = true;
	P x = p[v];
	for(llint i = 0; i < G[v].size(); i++){
		if(G[v][i].to == pre) continue;
		if(used[G[v][i].to]) continue;
		p[G[v][i].to] = make_pair(-x.first, G[v][i].cost-x.second);
		dfs(G[v][i].to, v);
	}
}

int main(void)
{
	cin >> n >> m;
	llint u, v, s;
	for(llint i = 1; i <= m; i++){
		cin >> u >> v >> s;
		G[u].push_back(edge(v, s));
		G[v].push_back(edge(u, s));
	}
	
	p[1] = make_pair(1, 0);
	dfs(1, -1);
	
	llint mn = 1, mx = 2e9;
	for(llint i = 1; i <= n; i++){
		if(p[i].first > 0) mn = max(mn, 1-p[i].second);
		else mx = min(mx, p[i].second-1);
	}
	for(llint i = 1; i <= n; i++){
		for(llint j = 0; j < G[i].size(); j++){
			llint u = G[i][j].to;
			P x = make_pair(p[i].first+p[u].first, p[i].second+p[u].second-G[i][j].cost);
			if(x.first == 0){
				if(x.second != 0){
					cout << 0 << endl;
					return 0;
				}
			}else{
				if(x.first < 0) x.second *= -1;
				x.second *= -1;
				if(x.second <= 0 || x.second % 2){
					cout << 0 << endl;
					return 0;
				}
				mn = max(mn, x.second/2);
				mx = min(mx, x.second/2);
			}
		}
	}
	
	if(mn > mx){
		cout << 0 << endl;
		return 0;
	}
	cout << mx - mn + 1 << endl;
	return 0;
}

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

int main() {
  long long num, a, b;
  long long Max,Min,kekka;
  
  cin >> num >> a >> b;
  
  if(num == 1 && a == b){
    cout << 1;
    return 0;
  }
  
  if(num == 1 && a != b){
    cout << 0;
    return 0;
  }
  
  if(a > b){
    cout << 0;
    return 0;
  }
  
  Max = a + (num-1) * b;
  Min = b + (num-1) * a;
  kekka = Max - Min + 1;
  
  cout << kekka;
}


Measured memory_bytes: 256
num = int(input())
cnt_list = [0] * (num+1)
ans = 1

for i in range(2,num+1):
    x = i
    prime = 2
    while x > 1:
        while x%prime == 0:
            cnt_list[prime] += 1
            x = x//prime
        prime += 1

for i in cnt_list:
    ans = (ans*(i+1)) % (10**9+7)
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

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

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

int main(){
    ll A,B,num=2;
    cin>>A>>B;
    if(A<B){
        ll a=A;
        A=B;
        B=a;
    }
    ll GCD;
    GCD=A%B;
    while(GCD>0){
        A=B;
        B=GCD;
        GCD=A%B;
    }
    GCD=B;
    ll lis[999999];
    ll count=1;
    lis[0]=1;
    ll check=sqrt(A)+sqrt(B);
    while(num<=check&&GCD!=1){
        if(GCD % num == 0){
            count++;
            while(GCD % num == 0){
                GCD /= num;
            }
        }
        num++;
    }
    if(GCD!=1)count++;
    cout<<count<<endl;
    return 0;
}

//参考にさせていただいたコードhttps://atcoder.jp/contests/abc142/submissions/7789711

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

int main() {
	int n;
	vector<int> vec;
	while (cin >> n) {
		if (n != 0) vec.push_back(n);
		else {
			cout << vec[vec.size() - 1] << endl;
			vec.pop_back();
		}
	}
	return 0;
}


Measured memory_bytes: 3136
N, K = map(int, input().split())
A = list(map(int, input().split()))
mod = 10**9+7
ans = 0
for i in range(N):
    Sum = 0
    Sum1 = 0
    a = A[i]
    for j in range(N):
        if A[j]<a:
            Sum+=1
        if i==j:
            Sum1 = Sum
    ans+=Sum*(K-1)*K//2+(Sum-Sum1)*K
    ans%=mod
print(ans)

Measured memory_bytes: 42220
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

LL W, H;
LL x, y;

int main(void) {
    cin >> W >> H >> x >> y;

    if (W % 2 == 0 && H % 2 == 0) {
        int o = (x == W / 2 && y == H / 2);
        cout << W * H / 2 << " " << o << endl;
    } else {
        cout << (1. * W * H) / 2 << " " << 0 << endl;
        return 0;
    }


}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

vector<int> dp;

int f(int x) {
  if (x < 0) return 0;
  if (dp[x] != -1) return dp[x];
  return dp[x] = (f(x - 1) + f(x - 2)) % mod;
}

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

  int n, m;
  cin >> n >> m;
  dp.resize(n + 1, -1);
  rep(i, m) {
    int a;
    cin >> a;
    dp[a] = 0;
  }
  dp[0] = 1;

  cout << f(n) << endl;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const int mod = 1e9+7;
const int N = 1e5+5;
//int a[N];

int main()

{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int a, b, x;

    cin >> a >> b >> x;

    if (x >= a && x-a <= b) cout << "YES";
    else cout << "NO";

    return 0;
}


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

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ll long long unsigned
#define pii pair<int,int>
#define tii tuple <int,int,int>
#define N 1000005
#define mod 2000003
#define X first
#define Y second
#define eps 0.0000000001
#define all(x) x.begin(),x.end()
#define tot(x) x+1,x+n+1
using namespace std;
int a[N],mn,mx,i,sol,n,t;
int main() {
    cin.sync_with_stdio(0);
    cout.sync_with_stdio(0);
    cin>>n>>t;
    mn=1000000005;
    for(i=1; i<=n; i++) {
        cin>>a[i];
        if(mn<a[i]) {
            if(mx<a[i]-mn) {
                sol=1;
                mx=a[i]-mn;
            } else if(mx==a[i]-mn)
                sol++;
        }
        mn=min(mn,a[i]);
    }
    cout<<sol;
    return 0;
}




Measured memory_bytes: 768
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 200005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll N;
vi C[MAXN], ans, A;

int dfs(int i){
    if(ans[i] != -1) return ans[i];

    if(C[i].empty()){
        ans[i] = 0;
        return 0;
    }
    else {
        ans[i] = C[i].size();
        rep(j, C[i].size()){
            ans[i] += dfs(C[i][j]);
        }
        return ans[i];
    }
}

void solve(){
    // for(int i = 1; i <= N; ++i) cout << dfs(i) << endl;
    for(int i = 1; i <= N; ++i) cout << C[i].size() << endl;  
}

int main(){
    cin >> N;
    ans.resize(N+1);

    fill(ans.begin(), ans.end(), -1);

    A.resize(N+1);
    A[0] = -1;
    A[1] = 1;

    for(int i = 2; i<= N; ++i) cin >> A[i];

    for(int i = 2; i<= N; ++i){
        C[A[i]].push_back(i);
    }

    solve();
}


Measured memory_bytes: 15580
#include<bits/stdc++.h>
#define y imag()
#define x real()
using namespace std;
typedef complex<double> P;

int main(){
  int n;
  P a,b;
  double ra,rb,d;
  cin>>n;
  while(n--){
    cin>>a.x>>a.y>>ra;
    cin>>b.x>>b.y>>rb;
    double A=a.x-b.x;
    double B=a.y-b.y;
    d=sqrt(A*A+B*B);
    if(d>ra+rb)cout<<0<<endl;
    else if(d+ra<rb)cout<<-2<<endl;
    else if(d+rb<ra)cout<<2<<endl;
    else cout<<1<<endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1400000;
char cn[CM], * ci = cn, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (72 - dig >> 3);
	return tmp;
}
char* di = cn;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

int A[200001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	fread(cn, 1, CM, stdin);
	int N = getint();
	rep(i, N - 1) A[getint()]++;

	rep1(i, N) putint(A[i]);

	fwrite(cn, 1, di - cn, stdout);


	Would you please return 0;
}

Measured memory_bytes: 3516
/**
*    author:  yuya1234
*    created: 05.07.2020 21:04:56
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define ALL(x) x.begin(),x.end()
#define SORT(x) sort(x.begin(),x.end())
#define SORTD(x) sort(x.rbegin(),x.rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define SZ(x) ll(x.size())

#define MEMSET(v, h) memset((v), h, sizeof(v))

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

  int n;
  cin>>n;

  int ac,wa,tle,re;
  ac=wa=tle=re=0;

  REP(i,n)
  {
    string s;
    cin>>s;
    
    if(s=="AC")ac++;
    else if(s=="WA")wa++;
    else if(s=="TLE")tle++;
    else if(s=="RE")re++;
  }

  cout<<"AC x "<<ac<<endl;
  cout<<"WA x "<<wa<<endl;
  cout<<"TLE x "<<tle<<endl;
  cout<<"RE x "<<re<<endl;
  


  return 0;
}

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

using namespace std;

int main(){
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 1 ; i < 10 && i <= N ; i++)
        ans++;
    for(int i = 100 ; i < 1000 && i <= N ; i++)
        ans++;
    for(int i = 10000 ; i < 100000 && i <= N ; i++)
        ans++;
    cout << ans;
}

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

using namespace std;

int main(){
	int n,minimum,tmp;
	scanf("%d",&n);
	int table[n][n];
	int data[n][2];

	for(int i=0;i<n;i++){
		for(int k=0;k<n;k++)table[i][k] = 0;
		scanf("%d %d",&data[i][0],&data[i][1]);
	}

	for(int col = 0; col <= n-2; col++){
		table[1][col] = data[col][0]*data[col][1]*data[col+1][0]*data[col+1][1];
	}

	for(int row = 2; row <= n-1; row++){
		for(int col = 0; col <= n-(row+1); col++){
			minimum = 2147483647;

			for(int div = 0; div <= row-1;div++){
				tmp = (table[div][col]+table[row-div-1][col+div+1])+(data[col][0]*data[col+div][1]*data[col+div+1][0]*data[col+row][1]);
				minimum = min(minimum,tmp);
			}
			table[row][col] = minimum;
		}
	}

	printf("%d\n",table[n-1][0]);

    return 0;
}

Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;

typedef signed long long ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) x.begin(),x.end()

#define DEBUG

int main()
{
	int x, a;
	cin >> x >> a;

	if(x < a)
	{
		cout << 0 << endl;
	}
	else
	{
		cout << 10 << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a == b && b == c) cout << "No" << endl;
    else if(a != b && b != c && a != c) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3672
#include <algorithm>
#include <cstdio>
#define fo(i, a, b) for (i = a; i <= b; i++)
using namespace std;
typedef long long ll;
const int maxn = 100000 + 10, mo = 1000000007;
ll a[maxn], A, B;
int tree[maxn * 4], f[maxn];
int i, j, k, l, r, t, n, m, ans;
void change(int p, int l, int r, int a, int b) {
    if (l == r) {
        (tree[p] += b) %= mo;
        return;
    }
    int mid = (l + r) / 2;
    if (a <= mid)
        change(p * 2, l, mid, a, b);
    else
        change(p * 2 + 1, mid + 1, r, a, b);
    tree[p] = (tree[p * 2] + tree[p * 2 + 1]) % mo;
}
int query(int p, int l, int r, int a, int b) {
    if (a > b) return 0;
    if (l == a && r == b) return tree[p];
    int mid = (l + r) / 2;
    if (b <= mid)
        return query(p * 2, l, mid, a, b);
    else if (a > mid)
        return query(p * 2 + 1, mid + 1, r, a, b);
    else
        return (query(p * 2, l, mid, a, mid) +
                query(p * 2 + 1, mid + 1, r, mid + 1, b)) %
               mo;
}
int main() {
    scanf("%d%lld%lld", &n, &A, &B);
    if (A < B) swap(A, B);
    fo(i, 1, n) scanf("%lld", &a[i]);
    a[0] = -A;
    a[n + 1] = a[n] + A;
    f[0] = 1;
    change(1, 0, n, 0, f[0]);
    l = 0;
    r = 0;
    fo(i, 1, n + 1) {
        while (a[i] - a[r + 1] >= A) r++;
        if (i >= 2 && a[i - 1] - a[i - 2] < B) l = i - 2;
        if (a[i] - a[i - 1] >= A) f[i] = f[i - 1];
        (f[i] += query(1, 0, n, l, min(i - 2, r))) %= mo;
        if (i <= n && a[i + 1] - a[i - 1] >= B) change(1, 0, n, i, f[i]);
    }
    ans = f[n + 1];
    (ans += mo) %= mo;
    printf("%d\n", ans);
}

Measured memory_bytes: 2304
#include<iostream>
using namespace std;
#include<algorithm>
#include<cmath>
#define N 100010
long long a[N];
int main()
{
	int n,i,k,j;
	long long tempa,tempb;
	while(cin>>n){
		tempa=0;
		tempb=0;
		k=0;
		memset(a,0,sizeof(a));
		for(i=0;i<n;i++)
			cin>>a[i];
		sort(a,a+n);
		for(i=n-1;i>=1;i--)
			if(a[i]==a[i-1])
			{
				tempa=a[i];
				k=i-1;
				break;
			}
		for(j=k-1;j>=1;j--)
			if(a[j]==a[j-1])
			{
				tempb=a[j];
				break;
			}
			printf("%lld\n",tempa*tempb);
	}
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
const int MOD = 1e9+7;
const int MOOD = 998244353;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

ll dp[101][8];
ll hoge[8];

bool is_ok(vector<int> &vec){
	if (vec.size() == 1) return true;
	for (int i = 0; i < vec.size()-1; i++){
		if (vec[i] == vec[i+1] && vec[i] == 1) return false;
	}
	return true;
}

int make_hoge(int x){
	int coun = 0;
	for (int i = 0; i < (1<<x); i++){
		vector<int> vec;
		for (int j = 0; j < x; j++){
			if ((1<<j) & i) vec.push_back(1);
			else vec.push_back(0);
		}
		if (is_ok(vec)) coun++;
	}
	return coun;
}

int main(){
	int h, w, k;
	cin >> h >> w >> k;

	for (int i = 1; i < 8; i++){
		hoge[i] = make_hoge(i);
	}
	hoge[0] = 1;
	dp[0][0] = 1;
	for (int i = 1; i <= h; i++){
		for (int j = 0; j < w; j++){
			if (j == 0){
				dp[i][0] += dp[i-1][0]*hoge[max(0, w-2)];
				dp[i][1] += dp[i-1][0]*hoge[max(0, w-3)];
				dp[i][0] %= MOD;
				dp[i][1] %= MOD;
			}else if (j == w-1){
				dp[i][w-1] += dp[i-1][w-1]*hoge[max(0, w-2)];
				dp[i][w-2] += dp[i-1][w-1]*hoge[max(0, w-3)];
				dp[i][w-1] %= MOD;
				dp[i][w-2] %= MOD;
			}else{
				dp[i][j] += dp[i-1][j]*hoge[max(0, j-1)]*hoge[max(w-j-2, 0)];
				dp[i][j-1] += dp[i-1][j]*hoge[max(0, j-2)]*hoge[max(w-j-2, 0)];
				dp[i][j+1] += dp[i-1][j]*hoge[max(0, j-1)]*hoge[max(w-j-3, 0)];
				dp[i][j] %= MOD;
				dp[i][j-1] %= MOD;
				dp[i][j+1] %= MOD;
			}
		}
	}

	cout << dp[h][k-1] << endl;

	return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <string>
#include <climits>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
#define ll long long
#define M 1000000007
int main() {
    int n;cin>>n;
    int c=0,f=0;
    for(int i=0;i<n;i++)
    {
        int k1,k2;cin>>k1>>k2;
        if(k1==k2)
        {
            c++;
        }
        else if(k1!=k2)
        {
            c=0;
        }
        if(c==3)
        {
            c=0;
            f=1;
        }
    }
    if(f==1)
    {
        cout<<"Yes"<<endl;
    }
    else if(f==0)
    {
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int n,m,k,ans=1e7,a[100005],b[100005],toa[100005],tob[100005];pii aa[100005],bb[100005];
int main()
{
    scanf("%d%d%d",&n,&m,&k);
    rep(i,1,n) {
        scanf("%d",a+i);
        aa[i] = mpr(a[i], i);
    }
    rep(i,1,m) {
        scanf("%d",b+i);
        bb[i] = mpr(b[i], i);
    }
    sort(aa+1,aa+n+1);
    sort(bb+1,bb+m+1);
    rep(i,1,k) {
        int t1,t2,t3;
        scanf("%d%d%d",&t1,&t2,&t3);
        ans = min(ans, a[t1] + b[t2] - t3);
    }
    ans = min(ans, aa[1].fi + bb[1].fi);
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

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

const ll inf = 1LL << 60;

using namespace std;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N, K;
    cin >> N >> K;
    vector<ll> h(N);
    Rep (i, N) cin >> h[i];

    vector<ll> dp(N, inf);
    dp[0] = 0;
    Rep (i, N) {
        for (ll j = 1; j <= K; j++) {
            if (i+j < N) chmin(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
        } 
    }

    cout << dp[N-1] << "\n";
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll H, N;
    cin >> H >> N;
    vec A(N), B(N);
    Rep (i, N) {
        cin >> A[i] >> B[i];
    }

    mat dp(N+1, vec(H+1, inf));
    dp[0][0] = 0;
    for (ll i = 1; i <= N; i++) {
        Rep (j, H+1) {
            chmin(dp[i][j], min(dp[i-1][j], dp[i][max(ll(0), j-A[i-1])] + B[i-1]));
        }
    }


    cout << dp[N][H] << "\n";
}

Measured memory_bytes: 80640
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseBigInt(readline())
    if n%2==1
        ans=0
    else
        n÷=10
        ans=BigInt(n)
        while n>0
            n÷=5
            ans+=n
        end
    end
    println(ans)
end
main()

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

double pi = acos(-1.0);

int main() {
	double a, b, x;
	scanf("%lf %lf %lf", &a, &b, &x);
	x = x / a;
	if(a * b / 2.0 >= x) {
		double c = x * 2.0 / b;
		double ans = atan(b / c);
		printf("%.10f\n", ans / pi * 180);
	}
	else {
		double left = x - a * b / 2.0;
		double h = left * 2.0 / a;
		double lh = b - h;
		double ans = atan(lh / a);
		printf("%.10f\n", ans / pi * 180);
	}
	return 0;
}

Measured memory_bytes: 384
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif




#define int long long
#define rng(i,l,r) for(size_t i=(l);i<(r);++i)
#define rep(i,n) rng(i,0,n)
#define gnr(i,l,r) for(size_t i=(r)-1;i>=(l);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()   //1,2,3,...
#define rALL(obj) (obj).rbegin(), (obj).rend()//...,3,2,1

using namespace std;


//constant
const int MOD = 1e9+7;
const int INF = 1e18;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};
const double pi = acos(-1);


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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
//*max_element(ALL(vector))
//count(ALL(vector),num) -> n
//memset(obj,value,sizeof(obj));




void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    int n; cin >> n;
    map<int,int> mp;
    rep(i,n){
        int a; cin >> a;
        if(mp[a]){
            mp[a]--;
        }else{
            mp[a]++;
        }
    }
    
    int ans = 0;
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        ans += (itr->second)?1:0;
    }
    
    cout << ans << endl;
    
    
    
}





signed main() {
    solve();
    return 0;
}




Measured memory_bytes: 6528
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[0]*n
for i in range(n):
  g=[]
  for j in range(1,k+1):
    if 0<=i-j<=n-1:
       g.append(dp[i-j]+abs(h[i]-h[i-j]))
  if g!=[]:
    dp[i]=min(g)
  else:
    dp[i]=0
print(dp[n-1])


Measured memory_bytes: 54640
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

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



int N;
int a[110000];
int b[110000];
map<ll, int> color;

int color_num;
vector<bool> seen;
using Graph = vector<vector<int>>;

void dfs(Graph& G, int v) {
  seen[v] = true;

  vector<bool> used(110000, false);
  for (auto next_v : G[v]) {
    int tmp = max(color[v * 110000 + next_v], color[next_v * 110000 + v]);

    if (tmp != 0) used[tmp] = true;
  } 

  for (auto next_v : G[v]) {
    int tmp = max(color[v * 110000 + next_v], color[next_v * 110000 + v]);

    if (tmp == 0) {
      rep(k, color_num) {
        if (!used[k]) {
          color[v * 110000 + next_v] = k;
          used[k] = true;
          break;
        }
      }
    }
  }

  for (auto next_v : G[v]) {
    if (seen[next_v]) continue;

    dfs(G, next_v);
  }
}

int main () {
  cin >> N;
  Graph G(N+1);

  rep(i, N-1) {
    int s, t;
    cin >> s >> t;
    a[i] = s;
    b[i] = t;

    G[s].push_back(t);
    G[t].push_back(s);
  }

  color_num = 0;
  int point = 1;
  rep(i, N) {
    int l = G[i].size();
    if (l > color_num) {
      color_num = l;
      point = i;
    }
  }

  seen.assign(N+1, false);

  dfs(G, point);

  cout << color_num << "\n";
  rep(i, N-1) {
    cout << max(color[a[i] * 110000 + b[i]], color[b[i] * 110000 + a[i]]) << "\n";
  }
}

Measured memory_bytes: 808576
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        long[] count = new long[n + 1];

        for (int i = 2; i <= n; i++) {
            int x = i;
            for (long j = 2; j <= Math.sqrt(x); j++) {
                if (x % j == 0) { // 最小の因数を求める
                    while (x % j == 0) {
                        x /= j; // 最小の因数で割った数を代入する
                        count[(int)j]++;
                    }
                }
            }
            if (x > 1) {
               count[x]++;
            }
        }

        long ans = 1;

        for (long v: count
             ) {
            v++;
            ans *= v;
            ans %= 1000000007;
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 22996
#include <iostream>
#include <math.h>

using namespace std;

bool isPrime(int x);

int main(){
	int n=0; 
	int a[10000]={};
	int z=0; //output
	
	cin >> n;
	for(int i=0;i<10000;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		if(isPrime(a[i])==true){
			z++;
		}
	}
	cout <<z<<endl;
}
bool isPrime(int x){
	if(x==2) return true;
	if(x<2||x%2==0) return false;
	int i=3;
	while(i<=sqrt(x)){
		 if (x%i==0)return false;
		i= i+2;
	}
	return true;
}

Measured memory_bytes: 1204
import numpy as np

N = int(input())
h = list(map(int, input().split()))
dp = [float("inf")] * N
dp[0] = 0
dp[1] = abs(h[0] - h[1])

for i in range(2, N):
    dp[i] = min(
        dp[i - 1] + abs(h[i] - h[i - 1]),
        dp[i - 2] + abs(h[i] - h[i - 2])
    )
print(dp[-1])

Measured memory_bytes: 22732
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

signed main() {
    Fast();

    int a, b;
    cin >> a >> b;
    cout << (a + b) / 2 + (a + b) % 2 << endl;

    return 0;
}



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

int main(int argc, char const *argv[])
{
	int n,k;
	cin>>n>>k;
	int h[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>h[i];
	}
	sort(h,h+n);
	int ans=2000000000;
	for (int i = 0; i < n-k+1; ++i)
	{
		ans=min(ans,h[i+k-1]-h[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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

int main(){
    int n;
    cin >> n;
    vector<ll> v(n);

    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    bool flg = true;
    for(int i = 0; i < n-1; i++){
        if(v[i] == v[i+1]) flg = false;
    }
    if(flg) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 1792
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	var check bool
	for ;; {
		check = true
		if len(s) == 0 {
			fmt.Println("YES")
			break
		}
		if len(s) < 5 || len(s) == 8 || len(s) == 9{
			fmt.Println("NO")
			break
		}
		if s[0:5] == "dream" {
			if len(s) == 5 || s[5:6] == "d" {
				s = s[5:]
				check = false
			} else if len(s) >= 7 && s[5:7] == "er" {
				if len(s) == 7 || s[7:8] == "d" || s[7:8] == "e" {
					s = s[7:]
					check = false
				} else if len(s) >= 8 && s[7:8] == "a" {
					s = s[5:]
					check = false
				}
			}
		} else if s[0:5] == "erase" {
			check = false
			if len(s) == 5 {
				s = s[5:]
			}
			if len(s) >= 6 {
				if s[5:6] == "r" {
					s = s[6:]
				} else {
					s = s[5:]
				}
			}
		}
		if check {
			fmt.Println("NO")
			break
		}
	}
}


Measured memory_bytes: 1280
n, m, q = map(int, input().split())
a, b, c, d = [0] * q, [0] * q, [0] * q, [0] * q
for i in range(q):
    a[i], b[i], c[i], d[i] = map(int, input().split())

'''
1.数列を生成する。
2.配列ごとに得点を求める。
'''
def judge(L):
    score = 0
    for i in range(q):
        check = L[b[i] - 1] - L[a[i] - 1]
        if check == c[i]:score += d[i]

    return score

def dfs(L):
    global score
    if len(L) == n:
        temp = judge(L)
        if temp > score:score = temp
        return #長さnの時ここより下に行かないようにする

    start = L[-1] if len(L) != 0 else 1
    for v in range(start, m + 1):
        L.append(v)
        dfs(L)
        L.pop()


score = 0
dfs([])
print(score)

Measured memory_bytes: 9240
fun main(args: Array<String>) {
    val n = readString()

    var t = 0L
    n.forEach {
        t += it - '0'
    }
    if (t % 9 == 0L) {
        println("Yes")
    } else {
        println("No")
    }
}

// read
fun readString() = readLine()!!

Measured memory_bytes: 38544
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>
#include<bitset>
#include<cassert>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll n, m, k, a, b, sumB = 0, ans = 0;

int main() {
	cin >> n >> m >> k;
	vector<ll> sumA(n);
	rep(i, n) {
		cin >> a;
		if (i) {
			sumA[i] = sumA[i - 1] + a;
			if (sumA[i] <= k)ans = max(ans, (ll)i + 1);
		}
		else {
			sumA[0] = a;
			if (a <= k)ans = 1;
		}
	}
	sumA.pub(1e10);
	rep(i, m) {
		cin >> b;
		sumB += b;
		if (sumB + sumA[0] > k) {
			if (sumB > k)break;
			ans = max(ans, (ll)i + 1);
			continue;
		}
		ans = max(ans, (ll)i + 1 + UBI(sumA, k - sumB));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6424
N = int(input())
t = [0]
x = [0]
y = [0]
for i in range(N):
    txy = input()
    txy = txy.split()
    t.append(int(txy[0]))
    x.append(int(txy[1]))
    y.append(int(txy[2]))

can = True

for i in range(0, N):
    dt = t[i + 1] - t[i]
    dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
    if dt < dist:
        can = False
    elif dt % 2 != dist % 2:
        can = False

if can:
    print("Yes")
else:
    print("No")
    


Measured memory_bytes: 11756
#include<bits/stdc++.h>
using namespace std;
int b[102],f[102];
int main(){
    int n;
    cin>>n;
    for(int i=1;i<n;i++){
        cin>>b[i];
    }
    /*f[1]=b[1];
    f[2]=2*b[1];
    for(int i=2;i<n;i++){
        if(b[i]>=b[i-1]){
            f[i+1]=f[i]+b[i];
        }
        else
            f[i+1]=f[i-1]+2*b[i];
        cout<<f[i+1]<<endl;

    }
    cout<<f[n]<<endl;*/
    b[0]=b[1];
    int ans=b[n-1];
    for(int i=n-1;i>=1;i--){
        ans+=min(b[i],b[i-1]);
    }
    cout<<ans;
}


Measured memory_bytes: 256