akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdlib>
using namespace std;
int main(){

  int n,m,c[1001]={},flag[1001]={},r0=0,r1=0;
  cin>>n>>m;
  for(int i=1,a,b;i<=m;i++){
    cin>>a>>b;
    if(!c[a]&&!c[b]){
      c[a]=i;
      c[b]=i;
    }
    if(c[a]&&!c[b]) c[b]=c[a];
    if(c[b]&&!c[a]) c[a]=c[b];
    if(c[a]&&c[b]){
      int tmp=c[b];
      for(int j=1;j<=n;j++) if(c[j]==tmp) c[j]=c[a];
    }
  }
  for(int i=1;i<=n;i++){
    if(!c[i]) r1++;
    else if(!flag[c[i]]){
      flag[c[i]]=1;
      r0++;
    }
  }
  cout<<abs(r0-r1)<<endl;
  return 0;
}

Measured memory_bytes: 3092
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int longSide = Math.max(sc.nextInt(),sc.nextInt());
    int N = sc.nextInt();
    System.out.println(N%longSide == 0 ? N/longSide : N/longSide + 1);
  }
}

Measured memory_bytes: 25172
#include <iostream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cmath>
#include <iomanip>
using namespace std;

#define PI 3.14159265358979323846264338327950L

int A, B, H, M;
long double res;

int main()
{
    //cin >> A >> B >> H >> M;

    //res = sqrt(((long double)A * A + B * B) - (long double)(2 * A * B * cos(abs((H * 30.0 + M * 0.5) - (M * 6.0)) * PI / 180.0)));
    //cout << fixed << setprecision(20) << res << endl;

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    double a, b, h, m;
    cin >> a >> b >> h >> m;

    double ang_a = (30 * h) + (m / 2);
    double ang_b = 6 * m;

    double ang = abs(ang_a - ang_b);
    if (ang > 180)
    {
        ang = 360 - ang;
    }

    double rad = (ang / 180) * M_PI;

    double length = sqrt(a * a + b * b - 2 * a * b * cos(rad));

    cout << fixed << setprecision(12);
    cout << length << endl;
    return 0;
}

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

using namespace std;

template<typename T>
ostream& operator<<(ostream& os, vector<T> v) {
  os << "[";
  for (T &i: v) os << i << ",";
  os << "]";
  return os;
}

template<class TH> void _dbg(const char *sdbg, TH h){ cout<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cout<<*sdbg++;
  cout<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef __DJKIM613
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#endif

const int MAXN = 2e5 + 10;

int H, W, N;
int SX, SY;
char S1[MAXN], S2[MAXN];
int l, r, u, d;
int main(void){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);

  cin >> H >> W >> N;
  cin >> SX >> SY;

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

  l = 1;  r = W;
  u = 1;  d = H;


  debug(l, r, u, d);
  for(int i = N ;  i >= 1 ; i--){
    if(i != N){
      if(S2[i] == 'L') r = min(W, r + 1);
      else if(S2[i] == 'R') l = max(1, l - 1);
      else if(S2[i] == 'D') u = max(1, u - 1);
      else d = min(H, d + 1);
    }
    
    if(S1[i] == 'L') l++;
    else if(S1[i] == 'R') r--;
    else if(S1[i] == 'D') d--;
    else u++;
  
    if(r < l || d < u) return cout << "NO\n", 0;

    debug(l, r, u, d);
  }

  if(l <= SY && SY <= r && u <= SX  && SX <= d) cout << "YES\n";
  else cout << "NO\n";
  return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define vi vector<ll>
#define vvi vector<vi>
#define llINF 1e18
#define ll long long
using namespace std;
bool vis[2510];
struct Edge{
  ll to,cost;
};
const ll MAX_V=2510;
vector<vector<Edge>> E(MAX_V);
vi dist(MAX_V,llINF);
bool bellman_ford(ll s){
  queue<ll>que;
  que.push(s);
  dist[s]=0;
  for(int i = 0;i < MAX_V;i++){
    ll n = que.size();
    bool used[MAX_V] = {};
    for(int j = 0;j < n;j++){
      ll now=que.front();
      que.pop();
      for(int k = 0;k < E[now].size();k++){
	Edge e = E[now][k];
	if(dist[e.to] > dist[now] + e.cost){
	  dist[e.to] = dist[now] + e.cost;
	  if(i == MAX_V-1)
	    if(vis[e.to])
	      return true;
	  if(used[e.to] == false)
	    que.push(e.to);
	  used[e.to]=true;
	}
      }
    }
  }
  return false;
}
vvi E2(MAX_V);
int main(){
  ll n,m,p;
  cin>>n>>m>>p;
  for(int i=0;i<m;i++){
    ll a,b,c;cin>>a>>b>>c;
    E[--a].push_back({--b,-(c-p)});
    E2[b].push_back(a);
  }
  queue<ll>que;
  que.push(n-1);
  vis[n-1]=true;
  while(que.size()){
    ll hoge=que.front();que.pop();
    for(auto a:E2[hoge])
      if(vis[a]==false){
	que.push(a);
	vis[a]=true;
      }
  }
  if(bellman_ford(0)==false){
    cout<<max(0LL,-dist[n-1])<<endl;
  }else cout<<-1<<endl;
}


Measured memory_bytes: 640
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

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

    int res;
    if (a > b) res = 2 * a - 1;
    else if (b > a) res = 2 * b - 1;
    else res = 2 * a;

    cout << res << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int t,h,m,s;
	
	scanf("%d",&t);
	h = t/60/60;
	m = (t/60)%60;
	s = (t%60)%60;
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
}

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

struct cell{
	double x,y,z,r;
	cell(double a, double b, double c, double d):x(a),y(b),z(c),r(d){}
	double dist(const cell &c2){
		double d = sqrt((x-c2.x)*(x-c2.x)+(y-c2.y)*(y-c2.y)+(z-c2.z)*(z-c2.z));
		return max<double>(d-r-c2.r, 0);
	}
};
struct Edge{
	int s,g;
	double d;
	Edge(int a, int b, double c) : s(a), g(b), d(c) {}
	
	bool operator<(const Edge &b){
		if(d!=b.d) return d<b.d;
		if(s!=b.s) return s<b.s;
		return g < b.g;
	}
};

struct Unionfind {
	vector< int > par;
	Unionfind(int N) : par(N,-1){
	}
	bool unite(int x, int y) {
		x = root(x), y = root(y);
		if(x == y) return 0;
		if(par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return 1;
	}
	int root(int k) {
		if(par[k] < 0) return (k);
		return (par[k] = root(par[k]));
	}
	bool same(int x, int y){
		x = root(x);
		y = root(y);
		return x==y;
	}
	int size(int k) {
		return (-par[root(k)]);
	}
};

int main() {
	
	while(1){
		int n;
		cin >> n;
		if(n==0) break;
		
		vector<cell> ce;
		for(int i=0; i<n; i++){
			double a, b, c,r;
			cin >> a >> b >> c>>r;
			ce.push_back({a,b,c,r});
		}
		vector<Edge> g;
		for(int i=0; i<n-1; i++){
			for(int j=i+1; j<n; j++){
				auto d = ce.at(i).dist(ce.at(j));
				g.push_back({i,j,d});
				g.push_back({j,i,d});
			}
		}
		sort(g.begin(),g.end());
		double sum{};
		Unionfind uf(n);
		for(auto i:g){
			if(!uf.same(i.s,i.g)){
				uf.unite(i.s,i.g);
				sum += i.d;
			}
		}
		cout << fixed << setprecision(3);
		cout << sum << endl;
	}
}


Measured memory_bytes: 3572
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (int argc, char const *argv[])
{
    int64_t N;
    int64_t ans = 0;

    scanf("%"PRId64, &N);

    ans = 180 * (N - 2);

    printf("%"PRId64"\n", ans);
}


Measured memory_bytes: 128
#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 h,w,k; cin >> h >> w >> k;
  vector<string> c(h); rep(i,h) cin >> c[i];

  int black = 0;
  rep(i,h){
    rep(j,w){
      if(c[i][j]=='#') black++;
    }
  }
  
  int ans = 0;
  
  for(int bit_h = 0;bit_h<(1<<h);bit_h++){
    for(int bit_w = 0;bit_w<(1<<w);bit_w++){
      int tmp = 0;
      vector<string> now(h,"");
      rep(i,h){
	now[i] = c[i];
      }

      for(int i = 0;i<=h;i++){
	if(bit_h & (1<<i)){
	  rep(j,w){
	    now[i][j] = 'R';
	  }
	}
      }
      /*cout << "i fin: " << bit_h << endl;
	rep(i,h) cout << now[i] << endl;*/

      for(int j = 0;j<=w;j++){
	if(bit_w & (1<<j)){
	  rep(s,h){
	    now[s][j] = 'R';
	  }
	}
      }
      
      /*cout << endl << "j fin: " << bit_w << endl;
	rep(i,h) cout << now[i] << endl;*/

      rep(i,h){
	rep(j,w){
	  if(now[i][j]=='#') tmp++;
	}
      }      
      if(tmp == k) ans++;
      /*cout << "tmp: " << tmp << endl;
	cout << "ans: " << ans << endl;*/
    }
  }

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


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
bool chmin(ll& a, ll b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
bool chmax(ll& a, ll b) {
    if (b > a) {
        a = b;
        return 1;
    }
    return 0;
}
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
template <class Abel>
struct UnionFind {
    vector<ll> par;
    vector<ll> rank;
    vector<Abel> diff_weight;

    UnionFind(ll n = 1, Abel SUM_UNITY = 0) { init(n, SUM_UNITY); }

    void init(ll n = 1, Abel SUM_UNITY = 0) {
        par.resize(n);
        rank.resize(n);
        diff_weight.resize(n);
        for (ll i = 0; i < n; ++i)
            par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    ll root(ll x) {
        if (par[x] == x) {
            return x;
        } else {
            ll r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(ll x) {
        root(x);
        return diff_weight[x];
    }

    bool same(ll x, ll y) { return root(x) == root(y); }

    bool merge(ll x, ll y, Abel w) {
        w += weight(x);
        w -= weight(y);
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(ll x, ll y) { return weight(y) - weight(x); }
};
int main() {
    cin >> n;
    cin >> q;
    UnionFind<ll> U(n,0);

    while (q--) {
        cin >> x;
        if (x == 0) {
            cin >> a >> b >> c;
            U.merge(a, b, c);
        }
        else{
          cin>>a>>b;
          if(!U.same(a,b))cout<<"?"<<endl;
          else cout << U.diff(a, b) << endl;
        }
    }
}


Measured memory_bytes: 5228
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

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

int main() {
    ll N, M;
    cin >> N >> M;
    Graph G(N);
    rep(i,M){
        ll a, b;
        cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    vector<ll> dist(N, -1);
    queue<ll> que;
    dist[0] = 0;
    que.push(0);
    ll out[N];
    while (!que.empty()) {
        ll v = que.front();
        que.pop();
        for (ll nv : G[v]) {
            if (dist[nv] != -1) continue;
            dist[nv] = dist[v] + 1;
            out[nv] = v+1;
            que.push(nv);
        }
    }
    rep(i,N){
        if(i==0) cout << "Yes" << endl;
        else cout << out[i] << endl;
    }
    return 0;
}


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

int main(){
  int a,b,c,d,e,k;
  cin >> a >> b >> c >> d >> e >> k;
  string ans = ":(";
  
  if(e-a <= k){
    ans = "Yay!";
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>

typedef long long ll;
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  char s[200000];
  cin >> s;
  int len = strlen(s);
  int cur = 0;
  char last = '_';
  int count = 0;
  while(cur < len) {
    if(last == s[cur]) {
      last = '_';
      cur += 2;
    } else {
      last = s[cur];
      cur += 1;
    }
    count += 1;
  }
  if(cur == len + 1) count--;
  cout << count << "\n";
  return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string.h>
#include<queue>
using namespace std;
const long long N = 4e6 + 7;
struct node {
	long long to, cost;
}r;
struct que {
	long long x, y;
	bool friend operator < (que a, que b) {
		return a.x > b.x;
	}
}w;
long long vis[N];
long long dis[N];
vector<node>v[N];
long long n, m, x, y, z;
void push(long long x, long long y, long long z) {
	r.to = y; r.cost = z;
	v[x].push_back(r);
}
long long inf = 214722121483647;
priority_queue<que> q;
long long slove(long long x) {
	fill(dis, dis + N, inf);
	w.x = 0; w.y = 1;
	dis[1] = 0;
	q.push(w);
	while (!q.empty()) {
		w = q.top(); q.pop();
		long long pos = w.y;
		for (long long i = 0; i < v[pos].size(); i++) {
			node e = v[pos][i];
			if (dis[e.to] > dis[pos] + e.cost) {
				dis[e.to] = dis[pos] + e.cost;
				w.x = dis[e.to]; w.y = e.to;
				q.push(w);
			}
		}
		
	}
	return dis[n];
}
int main() {
	cin >> n >> m;
	for (long long i = 1; i <= n; i++) {
		push(i, i - 1, 0);
	}
	while (m--) {
		cin >> x >> y >> z;
		push(x, y, z);
	}
	if (slove(1) == inf) cout << "-1\n";
	else cout << dis[n] << '\n';
	return 0;
}


Measured memory_bytes: 132600
# D - Sum of Large Numbers
# https://atcoder.jp/contests/abc163/tasks/abc163_d

MOD = 10 ** 9 + 7

n, k = map(int, input().split())

ans = 0
for i in range(k, n + 2):
  minn = i * (i - 1) // 2
  maxn = i * (2 * n - i + 1) // 2
  ans += (maxn - minn + 1) % MOD
print(ans % MOD)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define modulo 1000000007
typedef long long int ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int main() {
	ll l,r;
	cin >> l >> r;

	ll ans(0);

	if(r-l < 2019){
		vector<ll> list(r-l+1);
		for(int i=0; i<list.size(); i++){
			list[i] = ((ll)i+l) % 2019;
		}

		ans = 2019 * 2919;
		for(int i=0;i<list.size();i++){
			for(int j=i+1;j<list.size();j++){
				int mod = (list[i]*list[j]) % 2019;
				if(ans > mod) ans = mod;
			}
		}
	}

	cout << ans % 2019 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int N = 2e5 + 9;
vector<int> adj[N];

int ans[N], vis[N], depth[N];

void bfs(int node, int d = 0) {
	vis[node] = 1;
	queue<int> q;
	q.push(node);
	while(!q.empty()) {
		int tp = q.front();
		q.pop();
		for(auto it: adj[tp]) {
			if(vis[it]) continue;
			vis[it] = 1;
			ans[it] = tp;
			q.push(it);
		}
	}
}

int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rt", stdin);
#endif
	int n, m, u, v;
	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	bfs(1);
	for (int i = 1; i <= n; ++i) {
		if(vis[i]) continue;
		cout << "No\n";
		return 0;
	}
	cout << "Yes\n";
	for (int i = 2; i <= n; ++i) {
		cout << ans[i] << '\n';
	}
	return 0;
}


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

#define fr first
#define se second

using namespace std;

const long long N = 5e1 + 7;
const long long inf = 1e9 + 7;
const long long mod = 1e9 + 7;

int n;
int m;
int x;
int c[N];
int a[N][N];
int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n >> m >> x;
    for(int i = 0; i < n; i ++){
        cin >> c[i];
        for(int j = 0; j < m; j ++){
            cin >> a[i][j];
        }
    }
    int res = inf;
    for(int i = 0; i < (1 << n); i ++){
        int ans = 0;
        vector<int> b(m + 1, 0);
        for(int j = 0; j < n; j ++){
            if(i & (1 << j)){
                ans += c[j];
                for(int k = 0; k < m; k ++){
                    b[k] += a[j][k];
                }
            }
        }
        int good = 1;
        for(int j = 0; j < m; j ++){
            good &= (b[j] >= x);
        }
        if(good == 1){
            res = min(res, ans);
        }
    }
    if(res == inf){
        cout << "-1\n";
    }
    else{
        cout << res << "\n";
    }
}



Measured memory_bytes: 3700
using System;
using System.Collections.Generic;

class Program
{
    public static void Main(string[] args)
    {
        string[] inputstr = Console.ReadLine().Split(' ');
        int ans = 0;
        foreach (string item in inputstr)
        {
            ans++;
            if(string.Compare(item,"0") == 0)
            {
                break;
            }
        }

        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 26248
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
#include <queue>
using namespace std;


int main(){
    string s;
    cin >> s;
    vector<int> a(2019);
    long long now = 0, k = 1;
    a[0] = 1;
    for(int i = s.size() - 1; i >= 0; --i){
        long long c = s[i] - '0';
        long long n = (c * k + now) % 2019;
        a[n]++;
        k *= 10;
        k %= 2019;
        now = n;
    }
    long long ans = 0;
    for(int i = 0; i < 2019; ++i){
        ans += a[i] * (a[i] - 1) / 2;
    }
    cout << ans;
}

Measured memory_bytes: 3724
#include <iostream>
using namespace std;
int main(void){
    int a;
    cin>>a;
        if(a==19||a==29||a==39||a==49||a==59||a==69||a==79||a==89||a==99||a==91||a==92||a==93||a==94||a==95||a==96||a==97||a==98||a==90){
            cout<<"Yes"<<endl;
        }else{
            cout<<"No"<<endl;
        }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> k(M);
    vector<vector<int>> s(M, vector<int>());
    vector<int> p(M);
    rep(i, M){
        cin >> k[i];
        rep(j, k[i]){
            int S;
            cin >> S;
            s[i].push_back(S);
        }
    }
    rep(i, M) cin >> p[i];

    int ans = 0; //すべての電球が点灯するような組み合わせ
    int bit = 0; //ビット全探索用の変数
    //スイッチの状態のforループ
    for(; bit < (1<<N); bit++){
        int cnt = 0; //電球がすべて点灯しているか
        rep(i, M){
            int count = 0; //onになっているスイッチの個数
            rep(j, k[i]){
                int shift = s[i][j] - 1;
                if(bit & (1 << shift)) count++;
            }
            if(count % 2 == p[i]) cnt++;
        }
        if(cnt == M) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  ll a, b, x; cin >> a >> b >> x;
  ll s, e;
  if (a % x == 0) {
    s = a / x;
  }
  else {
    s = a / x + 1;
  }
  e = b / x;
  ll ans = e - s + 1;
  cout << ans << endl;
}

Measured memory_bytes: 256
#[allow(dead_code)]
fn main() {
    let (n, u, v) = i::u3();
    let ab = i::uv2(n - 1);

    let mut map = vec![HashSet::new(); n + 1];
    for (a, b) in ab {
        map[a].insert(b);
        map[b].insert(a);
    }

    let mut ud = vec![0; n + 1];
    let mut vd = vec![0; n + 1];

    let mut memo = HashSet::new();
    let mut q = VecDeque::new();
    memo.insert(u);
    q.push_front(u);
    while q.len() > 0 {
        let cur = q.pop_front().unwrap();
        for &c in &map[cur] {
            if memo.contains(&c) {
                continue;
            }
            memo.insert(c);
            q.push_back(c);
            ud[c] = ud[cur] + 1;
        }
    }
    let mut memo = HashSet::new();
    let mut q = VecDeque::new();
    memo.insert(v);
    q.push_front(v);
    while q.len() > 0 {
        let cur = q.pop_front().unwrap();
        for &c in &map[cur] {
            if memo.contains(&c) {
                continue;
            }
            memo.insert(c);
            q.push_back(c);
            vd[c] = vd[cur] + 1;
        }
    }

    let mut ans = 0;
    for i in 1..(n + 1) {
        if ud[i] >= vd[i] {
            continue;
        }
        ans = max(ans, vd[i] - 1);
    }
    println!("{}", ans);
  //  dbg!(ud, vd);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 67836
#include <stdio.h>
int main(void){
  int h,w,i,j;
  while(scanf("%d %d",&h,&w),h+w){
    for(i=0;i<h;i++){
      for(j=0;j<w;j++)
        printf("#");
      printf("\n");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 572
#include<stdio.h>

int main(){
   int x,y;
   scanf("%d%d",&x,&y);
   if(x==2 || y==2){
    printf("No\n");
    return 0;
   }
  else if(x==1 || x==3 ||x==5 ||x==7 ||x==8 || x==10|| x==12){
    if(y==1 || y==3 ||y==5 ||y==7 ||y==8 || y==10|| y==12){
        printf("Yes\n");
        return 0;
    }
    else{
        printf("No\n");
        return 0;
    }
   }
   else if(x==4 ||x==6 ||x==9 || x==11){
    if(y==4 ||y==6 ||y==9 || y==11){
        printf("Yes\n");
        return 0;
    }
    else{
        printf("No\n");
        return 0;
    }
   }
   else return 0;


}


Measured memory_bytes: 128
import java.io.*;

public class Main {
	public static void main(String[] args)throws IOException{
		//System.out.println("Hello world");
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br =new  BufferedReader(is);

		String c = br.readLine();
		int n1 = Integer.parseInt(c);
		int[] n = new int[3];

		for(int j = 0; j <n1; j++){
			String str = br.readLine();
			int space1 = str.indexOf(" ");
			int space2 = str.indexOf(" ", space1+1);
			String str1 = str.substring(0, space1);
			String str2 = str.substring(space1+1, space2);
			String str3 = str.substring(space2+1, str.length());
			n[0] = Integer.parseInt(str1);
			n[1] = Integer.parseInt(str2);
			n[2] = Integer.parseInt(str3);

			int[] max = new int[3];
			max[2] = n[0];
			for(int i = 0; i <3; i++){
				if(max[2] <= n[i]){
					max[2] = n[i];
					if(max[2] >= max[1]){
						int re = max[1];
						max[1] = max[2];
						max[2] = re;
						if(max[1] >= max[0]){
							int re2 = max[0];
							max[0] = max[1];
							max[1] = re2;
						}
					}
				}

			}
			if(max[0]*max[0] == max[1]*max[1] + max[2]*max[2])
				System.out.println("YES");
			else
				System.out.println("NO");

		}




	}

}

Measured memory_bytes: 9684
#pragma once
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif
#include <map>
using namespace std;
int main() {
  int N;
  int tmp;
  cin >> N;
  vector<pair<int, int> > pairs(N);
  for (int i = 0; i < N; i++) {
    cin >> tmp;
    pairs[i] = make_pair(tmp,i);
  }
  sort(all(pairs));
  rep(i, N) {
    cout << pairs[i].second+1 << " ";
  }
  return 0;
}
/*
//よく使うやつ
int N;
cin >> N;
vector<int> list(N);
for (int i = 0; i < N; i++) {
  cin >> list[i];
}
// for文
for (int i = 0; i < N; i++) {
}
//配列
vector<int> vec;
vec.at(i)
vector<vector<int>> vec(10, vector<int>(10));
sort(all(vec));
sort(all(vec), greater<int>());
    //配列の内容表示
dout << "====vecの内容====\n";
for (int i = 0; i < N; i++) dout << vec[i] << endl;
dout << "====ここまで====\n";
*/

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
main()
{
	int n,i,j,r=0,g=0,b=0;
	unsigned int x;
	string s;
	cin>>n;
	cin>>s;
	for(i=0;i<n;i++){
		if(s[i]=='R') r++;
		else if(s[i]=='G') g++;
		else if(s[i]=='B') b++;
	}
	x=r*b*g;
	for(i=0;i<=n/2;i++){
		for(j=0;j+2*i<n;j++){
			if(s[j]!=s[i+j] && s[j]!=s[2*i+j] && s[i+j]!=s[2*i+j]) x--;
		}
	}
	cout<<x<<'\n';
}

Measured memory_bytes: 3504
n = int(input())
R = []

for i in range(n): R.append(int(input()))

maxv = R[1] - R[0]
minv = R[0]
for j in range(1, n):
    maxv = max(maxv, R[j]-minv)
    minv = min(minv, R[j])

print(maxv)


Measured memory_bytes: 13592
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////


int main() {

	ll N;
	cin >> N;

	vector<vector<edge>> g(N+1);

	repn(i, N - 1) {
		ll a, b, c;
		cin >> a >> b >> c;

		g[a].push_back({ i,b,c });
		g[b].push_back({ i,a,c });
	}

	ll Q, K;
	cin >> Q >> K;

	vector<ll> d(N + 1,-1);
	queue<ll> q;

	d[K] = 0;
	q.push(K);

	while (!q.empty()) {
		ll v = q.front();
		q.pop();

		for (edge e : g[v]) {
			ll w = e.to;
			if (d[w] != -1) { continue; }
			d[w] = d[v] + e.d;
			q.push(w);

		}
	}

	repn(i, Q) {
		ll x, y;
		cin >> x >> y;
		cout << d[x] + d[y] << endl;
	}


	system("PAUSE");

	

}


Measured memory_bytes: 11648
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  string s;
  cin >> s;
  if(s[0]==s[1]&&s[0]==s[2]){
    cout << "No" << endl;
    return 0;
  }
  if(s[1]==s[0]&&s[2]==s[3]){
    cout << "Yes" << endl;
    return 0;
  }
  if(s[0]==s[2]&&s[1]==s[3]){
    cout << "Yes" << endl;
    return 0;
  }
  if(s[0]==s[3]&&s[1]==s[2]){
    cout << "Yes" << endl;
    return 0;
  }
  else cout << "No" << endl;
}  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, k;
int main() {
    cin >> n;
    string s;
    while(n > 0){
        if(n % 26 == 0){
            s.push_back('z');
            n /= 26;
            n--;
            continue;
        }
        s.push_back(n % 26 - 1 + 'a');
        n /= 26;
    }
    reverse(ALL(s));
    cout<<s<<endl;
}


Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

type point struct {
	x, y, h int
}

func main() {
	n := getInt()

	points := make([]point, n)
	k := -1
	for i := range points {
		points[i].x = getInt()
		points[i].y = getInt()
		points[i].h = getInt()
		if points[i].h > 0 {
			k = i
		}
	}

	for X := 0; X <= 100; X++ {
		for Y := 0; Y <= 100; Y++ {
			top := points[k].h + abs(X-points[k].x) + abs(Y-points[k].y)
			flag := true
			for _, p := range points {
				if p.h == 0 && top > abs(X-p.x)+abs(Y-p.y) {
					flag = false
					break
				}
				if p.h != 0 && top != p.h+abs(X-p.x)+abs(Y-p.y) {
					flag = false
					break
				}
			}
			if flag == true {
				fmt.Println(X, Y, top)
				return
			}
		}
	}
}

// H - abs(X - cx) - abs(Y - cy) = ch
// H = ch + abs(X - cx) + abs(Y - cy)

// -----------------------------------------

var scanner = wordScanner()

func wordScanner() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}

func getInt() int {
	scanner.Scan()
	i, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getString() string {
	scanner.Scan()
	s := scanner.Text()
	return s
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}


Measured memory_bytes: 640
#include <cstdio>

int main(void){
  int n=0;
  int l=0;
  int i=0;
    scanf("%d",&n);
    scanf("%d",&l);
  int nl=0;
  int ml=0;
  int maxt=0;
  int last=0;
  int udf=1;/*1 is inclease.2 is declease*/
  for(i=0;i<n;i++){
    scanf("%d",&nl);
    if(nl>ml){
      if(udf==1){
	last+=l-nl;
      }
      else{
	last=2*l-ml-nl;
	udf=1;
      }
    }
    else{
      if(udf==2){
	last+=l-nl;
      }
      else{
	last=2*l-ml-nl;
	udf=2;
      }
    }
    if(maxt<last){maxt=last;}
    ml=nl;
  }
  printf("%d\n",maxt);
  return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
#define double long double
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 2000010;

int main(){
    int c, n, m;
    scanf("%d%d%d", &c, &n, &m);
    int s[n], p[n];
    rep(i, n) scanf("%d%d", &s[i], &p[i]);

    int dp[2][c+1];
    rep(i, 2)rep(j, c+1) dp[i][j] = -1;
    dp[0][0] = 0;
    rep(i, n){
        rep(j, c+1)if(dp[0][j] >= 0){
            chmax(dp[1][j], dp[0][j]);
            if(j+s[i] <= c) chmax(dp[1][j+s[i]], dp[0][j] + p[i]);
        }

        rep(j, c+1){
            dp[0][j] = dp[1][j];
            dp[1][j] = -1;
        }
    }

    rep(j, c) chmax(dp[0][j+1], dp[0][j]);
    For(i, 1, m+1) printf("%lld\n", (lint)dp[0][c/i] * i);
}


Measured memory_bytes: 3376
import numpy as np

N = int(input())
h_ls = list(map(int,input().split(" ")))

h_ls = np.array(h_ls)
n = 0
h_len = len(h_ls)
while max(h_ls)!=0:
    max_ind = h_ls.argmax()
    d = 0
    while max_ind+d < h_len -1 and h_ls[max_ind+d+1]==h_ls[max_ind]:
        d+=1
    h_ls[max_ind:max_ind+d+1] =h_ls[max_ind:max_ind+d+1]-1
    n+=1

print(n)


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

int main()
{
	while(true){
		string s1;
		cin >> s1;

		if(s1==".")
			break;

		string s2;
		cin >> s2;

		if(s1==s2){
			cout << "IDENTICAL" << endl;
			continue;
		}

		string t1 = s1;
		string t2 = s2;

		while(true){
			size_t d1b = t1.find('\"');
			if(d1b==string::npos)
				break;
			t1.replace(d1b, 1, "@");

			size_t d1e = t1.find('\"');
			t1.replace(d1e, 1, "@");

			size_t d2b = t2.find('\"');
			if(d2b==string::npos)
				break;
			t2.replace(d2b, 1, "@");

			size_t d2e = t2.find('\"');
			t2.replace(d2e, 1, "@");

			string u1 = s1;
			u1.replace(d1b+1, d1e-d1b-1, "");
			string u2 = s2;
			u2.replace(d2b+1, d2e-d2b-1, "");

			if(u1==u2){
				t1 = u1;
				t2 = u2;
				break;
			}
		}

		if(t1==t2){
			cout << "CLOSE" << endl;
		}
		else{
			cout << "DIFFERENT" << endl;
		}
	}

	return 0;
}


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

int main(){
    long long N, K;
    cin >> N >> K;

    vector<long long> H(N);
    for(int i = 0; i < N; ++i) cin >> H.at(i);

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

    long long cnt = 0;

    for(int i = 0; i < N - K; ++i) {
        cnt += H.at(i);
    }

    cout << cnt << endl;
}


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

int main() 
{
    int n,i,j;
    vector<int>v;
    cin>>n;
    int ar[n];
    for(i=0;i<n;++i)
    cin>>ar[i];
    sort(ar,ar+n);
    
    int x=0,y=0;
    
    for(i=n-2;i>=0;--i)
    {
        if(ar[i]==ar[i+1])
        {
            if(x==0)
            x=ar[i];
            else
            {
                y=ar[i];
                break;
            }
            i=i-1;
        }
    }
    
    cout<<1LL*x*y<<endl;
    
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#define MAX_NUM 1000000

int main(void){
  int i,j;
  int n,a;
  int d[MAX_NUM];
  while(scanf("%d",&n) != EOF){
    a = 0;
    for(i=0;i<MAX_NUM;i++) d[i]=1;
    d[0] = 0;
    d[1] = 0;
    for(i=2;i<n+1;i++){
      if(d[i]==1){
        for(j=i*2;j<n+1;j+=i){
          d[j] = 0;
        }
      }
    }
    for(i=0;i<n+1;i++)  a += d[i];
    printf("%d\n",a);
  }
  return 0;
}

Measured memory_bytes: 4500
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x)  upper_bound(all(a), x) - lower_bound(all(a), x)
#define MCOUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0)
#define scan(x) scanf("%lld",&x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 2222222222222222222;
const ll mod = 1000000007;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111

bool y[MAX];
vll edge[MAX], x;
void dfs(ll now) {
  x.pb(now);
  y[now] = true;
  rep(i, edge[now].size()) {
	ll k = edge[now][i];
	if (!y[k]) {
	  dfs(k);
	  break;
	}
  }
}

int main(void) {
  cin >> n >> m;
  priority_queue<pll, vpll, greater<pll>> pq;
  rep(i, m) {
	ll a, b;
	cin >> a >> b;
	edge[a].pb(b);
	edge[b].pb(a);
  }
  FOR(i, 1, n + 1) {
	tmp = edge[i].size();
	pll p(tmp, i);
	pq.push(p);
  }

  while (1) {
	FOR(i, 1, n + 1) y[i] = false;
	x.clear();
	pll p = pq.top();
	pq.pop();
	dfs(p.second);

	ll st = x[0], ls = x[x.size() - 1];
	ok = true;
	rep(i, edge[st].size()) if (!y[edge[st][i]]) ok = false;
	rep(i, edge[ls].size()) if (!y[edge[ls][i]]) ok = false;

	if (ok) {
	  cout << x.size() << endl;
	  rep(i, x.size()) cout << x[i] << " ";
	  cout << endl;
	  return 0;
	}
  }

  return 0;
}

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

int n, m, k;
int main()
{
	int i, j;
	cin >> n >> m >> k;
	for (i = 0; i <= n; i++) {
		for (j = 0; j <= m; j++) {
			if (i * m + j * n - 2 * i * j == k) {cout << "Yes"; return 0;}
		}
	}
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn._
import scala.annotation.tailrec

object Main {

  case class Rotation(run: Dice => Dice){
    def apply(d: Dice): Dice = run(d)
    def compose(other: Rotation): Rotation = Rotation(run compose other.run)
  }

  object Rotation {
    def id = Rotation(d => d)
    def north = Rotation(d => Dice(List(1,5,2,3,0,4).map(d.pip)))
    def east = Rotation(d => Dice(List(3,1,0,5,4,2).map(d.pip)))
    def ccw = Rotation(d => Dice(List(0,3,1,4,2,5).map(d.pip)))

    final def axial(rotation: Rotation): Seq[Rotation] =
      for(i <- 0 to 3) yield List.fill(i)(rotation).fold(id)(_ compose _)

    def enumerateTop: Seq[Rotation] =
      for(i <- 1 to 6) yield ((0 to i).map(j => if(j % 2 == 0) north else east)).fold(id)(_ compose _)

    def enumerate: Seq[Rotation] = {
      val ax = axial(ccw)
      enumerateTop.flatMap(e => ax.map(e compose _))
    }
  }

  case class Dice(pip: List[Int]){
    lazy val all: Seq[Dice] = Rotation.enumerate.map(_.run(Dice(pip)))
    def ===(that: Dice): Boolean = pip.corresponds(that.pip)(_ == _)
    def ==(that: Dice): Boolean = all.exists(_ === that)
  }

  def main(args: Array[String]): Unit = {
    val pip = readLine.split(" ").map(_.toInt).toList
    val all: Seq[Dice] = Rotation.enumerate.map(_.run(Dice(pip)))
    val Array(n,_*) = readLine.split(" ").map(_.toInt)

    for(i <- 1 to n){
      val Array(a,b,_*) = readLine.split(" ").map(_.toInt)
      println(all.filter(d => d.pip(0)==a && d.pip(1)==b)(0).pip(2))
    }
  }

}

Measured memory_bytes: 44488
n = int(input())
ans = 0

if n == 1:
    print(0)
    quit()


def fac(n):
    arr = []
    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.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


li = fac(n)
kaijo = [0, 1, 3, 6, 10, 15, 21, 28, 36, 45]

for i in range(len(li)):
    for j in range(len(kaijo)):
        if kaijo[j] <= li[i][1] < kaijo[j + 1]:
            ans += j

print(ans)


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

#define ll long long
#define mxx 10000000

ll ara[mxx+5];
ll ara2[mxx+5];
ll cnt[mxx+5];
ll cnt2[mxx+5];

void solve()
{
    ll i,j,mx = 10000000;
    ara[1] = 1;
    for(i=2;i<=mx;i++)
    {
        ara[i]++;
        for(j=i;j<=mx;j+=i)
        {
            ara[j]++;
        }
    }
    ara2[0] = 0;
    for(i=1;i<=mx;i++)
    {
        ara2[i] = ara2[i-1]+i*ara[i];
    }


}
int main()
{
    solve();

    ll n;

    while(scanf("%lld",&n)==1)
    {
        printf("%lld\n",ara2[n]);
    }












return 0;
}


Measured memory_bytes: 160052
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    R = [False] * (N + 1)
    D = []

    p = 1

    while True:
        if R[p]:
            break
        D.append(p)
        R[p] = True
        p = A[p - 1]

    m = D.index(p)
    c = len(D) - m

    if K <= m:
        print(D[K])
    else:
        print(D[m + (K - m) % c])


if __name__ == "__main__":
    main()


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

int N;

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

  cin >> N;
  vector< ll > a(N);
  REP(i, N) {
    cin >> a[i];
  }

  if (a[0] != 0) {
    cout << -1 << endl;
    return 0;
  }
  
  RREP(i, N - 1) {
    if (a[i + 1] - a[i] >= 2) {
      cout << -1 <<  endl;
      return 0;
    }
  }

  ll ans = 0ll;

  RREP(i, N - 1) {
    if (a[i + 1] - a[i] > 0) {
      ans++;
    } else {
      ans += a[i + 1];
    }
    // ans += max(a[i + 1] - a[i], 0ll);
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 1792
A,B,C = [int(i) for i in input().split()]
K = int(input())
c = 0
while B <= A:
    B *= 2
    c += 1
i = 1
while C <= B:
    C *= 2
    c += 1
if c <= K:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9028
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char) 
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let n: usize = read();
  let mut p: Vec<usize> = Vec::new();
  for _ in 0..n { p.push(read()); }
  
  let mut x = 0;
  for i in 1..n-1 {
    if 
      (p[i - 1] > p[i] && p[i] > p[i + 1]) || 
      (p[i - 1] < p[i] && p[i] < p[i + 1]) {
      x += 1;
    }
  }
  
  println!("{}", x);
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>

using namespace std;

int main()
{
    char a,b;
    cin >> a >> b;
    if(a<b){
        cout << '<';
    }else if(a>b){
        cout << '>';
    }else{
        cout << '=';
    }
    
    return 0;
}

Measured memory_bytes: 888
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))
import math
N = ii()

print(math.pi*2*N)

Measured memory_bytes: 9212
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ll long long
#define all(a) a.begin(),a.end()
#define endl '\n'
#define y1 y123123
#define int ll

using namespace std;

const int N = 3e5 + 3;
const int inf = 1e9 + 3;
const int md = 998244353;

int n, k;
int cnt[1 << 4];
int nxt[N][3];
int ans;
string s;
int a[N];
vector<int> b;
int cntt(int x){
    int res = 0;
    while(x)
    {
        if(x & 1)res++;
        x /= 2;
    }
    return res;
}
bool cmd(int a, int b){
    return cntt(a) < cntt(b);
}

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

    for(int i = 0; i < 8; ++i)b.pb(i);
    sort(all(b), cmd);

    cin >> n;
    cnt[0] = n;
    cin >> s;
    for(int i = 0; i < n * 3; ++i){
        if(s[i] == 'G')a[i] = 2;
        else if(s[i] == 'B')a[i] = 1;
        else a[i] = 0;
    }
    ans = 1;
    for(int i = 0; i < n * 3; ++i){
        for(int k = 7; k >= 0; k--){
            int j = b[k];
            if(!(j & (1 << a[i])) && cnt[j] > 0){
                ans *= cnt[j];
                ans %= md;
                cnt[j]--;
                cnt[j ^ (1 << a[i])]++;
                break;
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 4756
//07-6 ????????????
#include<iostream>
#include<stdio.h>
using namespace std;

int map[17][17] = {};

int michi(int x, int y){//x,y??????????????????????????????????±???????
    int ret = 0;

    //?????´
    if(map[x][y+1] == 0){
        ret += michi(x,y+1);
    }
    else if(map[x][y+1] == 1){
        ret += 1;
    }

    //??±??´
    if(map[x+1][y] == 0){
        ret += michi(x+1,y);
    }
    else if(map[x+1][y] == 1){
        ret += 1;
    }

    return ret;
}

int main(){
    bool flg = true;
    while(flg){
        int a,b;
        cin >> a >> b;
        if(a==0 && b==0){
            flg = false;
        }
        else{
            for(int i=0; i<17; i++){
                for(int l=0; l<17; l++){
                    map[i][l] = -1;
                }
            }

            for(int i=0; i<a; i++){
                for(int l=0; l<b; l++){
                    map[i][l] = 0;
                }
            }
            
            int n;
            cin >> n;
            for(int i=0; i<n; i++){
                int x,y;
                cin >> x >> y;
                map[x-1][y-1] = -1;
            }

            map[a-1][b-1] = 1;

            cout << michi(0,0) << endl;
        }
    }
    return 0;
}


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

namespace ITP1_10_D
{
	class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int[] y = Console.ReadLine().Split().Select(int.Parse).ToArray();
			for (double z = 1; z <= 3; z++)
			{
				double sum = 0;
				for (int i = 0; i < n; i++)
				{
					sum += Math.Pow(Math.Abs(x[i] - y[i]), z);
				}
				Console.WriteLine(Math.Pow(sum, 1 / z));
			}
			double max = 0;
			for (int i = 0; i < n; i++) max = Math.Max(max, Math.Abs(x[i] - y[i]));
			Console.WriteLine(max);
		}
	}
}


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

int main() {
  int N, K, total = 0; // ボールの数、ロボットBの位置、総移動距離
  cin >> N >> K;

  for (int i = 0; i < N; i++) {
      int x; // i個目のボールの位置
      cin >> x;
      int a = x * 2;
      int b = abs(K - x) * 2;
      total += (a > b ? b : a);
  }
  cout << total << endl;
}


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

int main(){
  int n, m;
  cin >> n >> m;
  int min = 0,
      max = n;
  int l, r;
  for (int i=0;i<m;i++){
    cin >> l >> r;
    if (l>min)min=l;
    if (r<max)max=r;
  }
  int ans;
  if (max<min)ans = 0;
  else ans = max - min + 1;
  cout << ans << endl;
}

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

int main()
{
    string s,k;
    cin>>s>>k;
    int arr[30]={0};
    int frr[30]={0};
    for(int i=0;i<s.size();i++)
    {
        char a=s[i]-'a';
        arr[a]++;
    }
     for(int i=0;i<k.size();i++)
    {
        char a=k[i]-'a';
        frr[a]++;
    }
  //  for(int i=0;i<30;i++)cout<<arr[i]<<" ";
  vector<int>v1;
  vector<int>v2;

  for(int i=0;i<30;i++)v1.push_back(arr[i]);
  for(int i=0;i<30;i++)v2.push_back(frr[i]);

  sort(arr,arr+30);
  sort(frr,frr+30);

  for(int i=0;i<30;i++)
  {
      if(arr[i]!=frr[i])
      {
          cout<<"No"<<endl;
          return 0;
      }
  }
  cout<<"Yes"<<endl;

}


Measured memory_bytes: 776