akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

n,k = l_in()
p = n%k
print(min(p, k-p))


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

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

using Int = long long;
int mo = 1e9+7;
int inf = 1e9;

int N, u, v;
vector<int> G[100010];
vector<int> da, dt;

void calc_d(vector<int> &d, int s)
{
    rep(i, N) d[i] = -1;
    d[s] = 0;

    queue<int> q;
    q.push(s);

    while (not q.empty()) {
        int v = q.front();
        q.pop();

        rep(i, G[v].size()) {
            int j = G[v][i];
            if (d[j] == -1) {
                d[j] = d[v] + 1;
                q.push(j);
            }
        }
    }
}

bool is_leaf(int from)
{
    if (G[from].size() == 1) {
        int to = G[from][0];
        return da[from] > da[to];
    }

    return false;
}

signed main()
{
    cin >> N >> u >> v;
    --u, --v;
    rep(i, N-1) {
        int a, b; cin >> a >> b; --a, --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    da.resize(N);
    dt.resize(N);

    calc_d(dt, u);
    calc_d(da, v);

    int ans = 0;

    rep(i, N) {
        if (not is_leaf(i) and da[i] >= dt[i]) {
            //printf("da[%d] = %d\n", i, da[i]);
            ans = max(ans, da[i]);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a[100000];
    int i,j,k,l,r,c=0,n;
    cin>>n;
  for(i=0;i<n-1;i++){cin>>a[i];}
    
for(j=0;j<n-2;j++){
       if(a[j]<=a[j+1]){c+=a[j];}
        else {c+=a[j+1];}
    }
    c+=a[n-2]+a[0];
    cout<<c<<endl;
   
      

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n, ans;
  cin >> n;
  ans = n/2 + n%2;
  
  cout << ans << endl;
return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)
#define PI 3.14159265358979

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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

mt19937_64 rnd(time(NULL));



int h, w, n, a[303030], b[303030];
int c[303030], d[303030];
P p[303030], pp[303030];
map<P, bool> mp;
void solve(){
	cin >> h >> w >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		mp[{a[i],b[i]}] = 1;
		c[a[i]]++;
		d[b[i]]++;
	}
	
	for(int i = 0; i < h; i++){
		p[i] = {c[i], i};
	}
	for(int i = 0; i < w; i++){
		pp[i] = {d[i], i};
	}
	sort(p,p+n,greater<P>());
	sort(pp,pp+n,greater<P>());
	
	int ma = 0;
	for(int i = 0; i < h; i++){
		int cnt = c[i];
		int j = 0;
		int cc = pp[j].first - 1;
		if(cnt + cc < ma) continue;
		while(cc == pp[j].first-1){
			if(!mp[{i,pp[j].second}]){
				cc++;
				break;
			}
			j++;
		}
		cnt += cc;
		chmax(ma, cnt);
	}
	cout << ma << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 36436
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define ULL unsigned long int
#define MOD (long int)10e9 + 7
#define LD long double


int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int> > v(n + 1);
    vector<int> ans(n + 1,-1);


    for(int i = 0; i < m; ++i){
        int a,b;
        cin >> a >> b;
        v[b].push_back(a);
        v[a].push_back(b);
    }

    ans[1] = 0;

    vector<bool> flag(n + 1,false);

    queue<int> q;
    q.push(1);

    while(!q.empty()){
        int pos = q.front();
        flag[pos] = true;
        q.pop();
        cerr << "a" << pos << endl;
        for(int i = 0; i < v[pos].size(); ++i){
            if(ans[v[pos][i]] != -1) continue;
            if(!flag[v[pos][i]])
                q.push(v[pos][i]);
            ans[v[pos][i]] = pos;
        }
    }

    


    for(int i = 1; i < n; ++i){
        if(ans[i + 1] == -1){
            cout << "No" << endl;
            return 0;
        }
    }


    cout << "Yes" << endl;

    for(int i = 1; i < n; ++i){

        cout << ans[i + 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 10248
N,Q = [int(x) for x in input().split()]
ki = [0]*N
tr = [[] for _ in range(N)]

for i in range(N-1):
    a,b = [int(x)-1 for x in input().split()]
    tr[a].append(b)
    tr[b].append(a)

for i in range(Q):
    position,val = [int(x) for x in input().split()]
    ki[position-1] += val

stack =[0]
visited = set()
visited.add(0)

while stack:
    i = stack.pop()
    for j in tr[i]:
        if j in visited:
            continue
        visited.add(j)
        ki[j] += ki[i]
        stack.append(j)

for i in ki:
    print(i,end=" ")
print()


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

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for(int i=a; i<b; i++)
#define M00(i, a) for(int i=0; i<a; i++)
#define MOOd(i,a,b) for(int i = (b)-1; i >= a; i--)
#define M00d(i,a) for(int i = (a)-1; i>=0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _ << " _ " <<

template<class T> bool ckmin(T& a, const T& b) {return b < a ? a = b, 1 : 0;}
template<class T> bool ckmax(T& a, const T& b) {return a < b ? a = b, 1 : 0;}

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;

int main() { FAST
    int n; cin >> n;
    vector<ll> v(n);
    M00(i, n) cin >> v[i];
    ll mx = 0;
    ll res = 0;
    M00(i, n) {
        ckmax(mx, v[i]);
        res += mx - v[i];
    }
    finish(res);
}



Measured memory_bytes: 4752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順


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

	char a = s[0];
	int  ans=1;
	FOR(i,1,n){
		if(a == s[i]) continue;
		a = s[i];
		ans++;
	}

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

ll gcd(ll x, ll y) {
  if(x > y)
    return gcd(y, x);
  else if(x == 0)
    return y;
  else
    return gcd(y % x, x);
}

struct data {
  ll prime;
  int power;
  data(ll prime, int power) : prime(prime), power(power) {}
};
vector<data> result;
void factorization(ll N) {
  if(N == 1 || N == 0) return;

  bool first = true;
  ll n = N;
  while(n % 2 == 0) {
    if(first) {
      result.push_back(data(2LL, 1));
      first = false;
    } else {
      result[result.size()-1].power++;
    }
    n /= 2;
  }
  first = true;

  for(ll i=3; i<ceil(sqrt(N)); i+=2) {
    while(n % i == 0) {
      if(first) {
	result.push_back(data(i, 1));
	first = false;
      } else {
	result[result.size()-1].power++;
      }
      n /= i;
    }
    first = true;
  }

  if(n != 1) {
    result.push_back(data(n, 1));
  }

  return;
}

int main() {
  ll A, B;
  cin >> A >> B;
  ll g = gcd(A, B);
  factorization(g);
  cout << result.size()+1 << endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
using namespace std;
typedef long long int llint;
#define rep(i,n) for(int i=0;i<n;i++)

bool check(char a, char b) {
	return a > b;
}

int kuraiwa(int n) {
	int ans = 0;
	while (n > 0) {
		ans += n % 10;
		n /= 10;
	}
	return ans;
}

int main() {
	int n;
	cin >> n;
	vector<char>a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	if (a[n - 1] == 'Y') {
		cout << "Four" << endl;
	}
	else {
		cout << "Three" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    string W,T;
    cin>>W;
    
    for(int i=0;i<W.size();i++){
        if('A'<=W[i]&&W[i]<='Z')W[i]=tolower(W[i]);
    }
    
    int n=0;
    while(cin>>T&&T!="END_OF_TEXT"){
        for(int i=0;i<T.size();i++){
            if('A'<=T[i]&&T[i]<='Z')T[i]=tolower(T[i]);
        }
        if(T==W)n++;
    }
    cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 3076
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(){
  ll n;
  cin>>n;
  ll ans = 0;
  ll ab = 0;
  ll a = 0;
  ll b = 0;
  rep(i,0,n){
    string s;
    cin>>s;
    if(s[0]=='B'&&s[s.sz-1]=='A')ab++;
    else if(s[0]=='B')b++;
    else if(s[s.sz-1]=='A')a++;
    rep(j,0,s.sz-1){
      if(s[j]=='A'&&s[j+1]=='B'){
        ans++;
      }
    }
  }
  if(ab==n){
    cout << ans+ab-1 << endl;
  }
  else if(ab==0){
    cout << ans + min(a,b) << endl;
  }
  else{
    ans += ab-1;
    if(a>0){
      ans++;
      a--;
    }
    if(b>0){
      ans++;
      b--;
    }
    cout << ans+min(a,b) << endl;
  }
  return 0;
}

Measured memory_bytes: 384
n = int(input())
heights = [int(x) for x in input().split()]

flag = True
heights[0] -= 1

for i in range(1, n):
    if heights[i] > heights[i - 1]:
        heights[i] -= 1
    elif heights[i] < heights[i - 1]:
        flag = False

print('Yes' if flag else 'No')

Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> void Max(T &m, const T q) { if (m < q) m = q; }
template<typename T> void Min(T &m, const T q) { if (m > q) m = q; }
template<typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

int N, M;

int main()
{
    cin >> N >> M;
    set<int> s{1};
    vector<int> num(N + 1, 1);
    REP(_, M)
    {
        int x, y;
        cin >> x >> y;
        num[x]--;
        num[y]++;
        if (s.count(x)) s.insert(y);
        if (num[x] == 0) s.erase(x);
    }
    cout << s.size() << endl;
}


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

int main(void) {
    
    int A,B,C,D,E,F,a,b,c,d,e,f; 
    cin>>A>>B>>C>>D>>E>>F;
    if(A>B){
        a=B;
        b=A;
    }else{
        a=A;
        b=B;
    }
    if(C>D){
        c=D;
        d=C;
    }else{
        c=C;
        d=D;
    }
    if(E>F){
        e=F;
        f=E;
    }else{
        e=E;
        f=F;
    }
    
    if(a==c){
        if(a==e){
            cout<<"NO"<<endl;
            return 0;   
        }else if(a==f){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    if(a==d){
        if(a==e){
            cout<<"NO"<<endl;
            return 0;   
        }else if(a==f){
            cout<<"NO"<<endl;
            return 0;
        }
    }    
    if(b==c){
        if(b==e){
            cout<<"NO"<<endl;
            return 0;   
        }else if(b==f){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    if(b==d){
        if(b==e){
            cout<<"NO"<<endl;
            return 0;   
        }else if(b==f){
            cout<<"NO"<<endl;
            return 0;
        }
    }    
    
    cout<<"YES"<<endl;

    
    return 0;
} 

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

int main() {
    int n;
    cin >> n;

    int t = n, s = 0;
    while(t != 0) {
        s += t % 10;
        t /= 10;
    }

    if (n % s == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
	int a,b,c;
	int n=0;
	cin>>a>>b>>c;
	for(int i=a ; i<=b ; i++)
	{
		if(c==(c/i)*i)n++;
	}
	cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 3092
#include <cstdio>

int n;
long long ans;

inline int getfirst(int x) {
    while (x > 9) x /= 10;
    return x;
}

inline int cutfirst(int x) {
    int first = getfirst(x), tmp = x;
    while (tmp > 9) tmp /= 10, first *= 10;
    return x - first;
}

inline int BIT(int x) {
    int ans = 0;
    while (x) x /= 10, ++ans;
    return ans;
}

inline int cnt(int bit) {
    if (bit < 0) return 0;
    int ans = 1;
    while (bit--) ++(ans *= 10);
    return ans;
}

int main() {
    scanf("%d", &n);
    if (n < 10) return printf("%d\n", n), 0;
    int first = getfirst(n);
    int middle = cutfirst(n) / 10;
    int last = n % 10;
    int bit = BIT(n);
    int a = cnt(bit - 2);
    int b = cnt(bit - 3);
    for (int i = 1; i <= n; ++i) {
        int f = getfirst(i);
        int l = i % 10;
        if (!l) continue;
        if (f == l) ++ans;
        if (l == first) ans += b + middle + 1 - (f > last);
        else if (l < first) ans += a;
        else ans += b;
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int mod =1e9+7;
const int N = (int)2e5 + 5;

void solve(){
		int n,m;
		cin>>n>>m;
		int sum=0;
		while(m--){
			int x;
			cin>>x;
			sum+=x;
		}
		if(sum>n){
			cout<<-1;
		}
		else cout<<n-sum;

}

int main(){
	Red;
	int t=1;
	// cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 3656
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
#include<algorithm>
#include<math.h>
#include<map>
#include<queue>
#include<string>
#include<iomanip>

int main() {
	int n;
	cin >> n;
	vector<int>a;
	double sum(0);
	rep(i, n) {
		double buffer;
		cin >> buffer;
		sum += 1/buffer;
	}
	sum = 1 / sum;
	cout << fixed<<setprecision(8)<<sum<< endl;
	return 0;
}

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

using namespace std;

int main(){

	string s;
	cin >> s;
	switch(s.at(0)){
		case 'S':
			cout<<"Cloudy"<<endl;
			break;
		case 'R':
			cout<<"Sunny"<<endl;
			break;
		default :
			cout<<"Rainy"<<endl;
			break;
	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int minn,maxx;
map<string,int>a;
string s[8]={"hui","zong","lv","qing","lan","huang","cheng","hong"}; 
int main()
{
	int n;
	bool v=false,v1=false;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		if(x<400)
		{
			a["hui"]++;
			continue;
		}
		if(x<800)
		{
			a["zong"]++;
			continue;
		}
		if(x<1200)
		{
			a["lv"]++;
			continue;
		}
		if(x<1600)
		{
			a["qing"]++;
			continue;
		}
		if(x<2000)
		{
			a["lan"]++;
			continue;
		}
		if(x<2400)
		{
			a["huang"]++;
			continue;
		}
		if(x<2800)
		{
			a["cheng"]++;
			continue;
		}
		if(x<3200)
		{
			a["hong"]++;
			continue;
		}
		if(x>3199)
		{
			a["tql"]++;
			v1=true;
			continue;
		}
	}
	for(int i=0;i<=7;i++)
	{
		if(a[s[i]]!=0) minn++,maxx++;
	}
	if(v1==true&&minn>0)
		maxx+=a["tql"];
	if(v1==true&&minn==0)
		minn=1,maxx=a["tql"];
	cout<<minn<<" "<<maxx<<endl;
	return 0;
}
/*
Rating 1 - 399£º»ÒÃû  
Rating 400 - 799£º×ØÃû  
Rating 800 - 1199£ºÂÌÃû  
Rating 1200 - 1599£ºÇàÃû  
Rating 1600 - 1999£ºÀ¶Ãû  
Rating 2000 - 2399£º»ÆÃû  
Rating 2400 - 2799£º³ÈÃû  
Rating 2800 - 3199£ººìÃû  */

Measured memory_bytes: 256
#line 1 "/workspaces/compro/lib/template.hpp"


#line 1 "/workspaces/compro/lib/io/vector.hpp"
#include <iostream>
#include <vector>

#ifndef IO_VECTOR
#define IO_VECTOR

template <class T> std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
  int size = v.size();
  for (int i = 0; i < size; i++) {
    std::cout << v[i];
    if (i != size - 1)
      std::cout << " ";
  }
  return out;
}

template <class T> std::istream &operator>>(std::istream &in, std::vector<T> &v) {
  for (auto &el : v) {
    std::cin >> el;
  }
  return in;
}

#endif
#line 4 "/workspaces/compro/lib/template.hpp"
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes, T no) { cout << (val ? yes : no) << "\n"; }

void say(bool val, string yes = "Yes", string no = "No") { say<string>(val, yes, no); }

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

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

// C++ 17に完全移行したら消す
// 最大公約数を求める
template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

// 最小公倍数を求める
template <class T> T lcm(T n, T m) {
  int g = gcd(n, m);
  return n * m / g;
}

// 重複を消す。計算量はO(NlogN)
template <class T> void unique(std::vector<T> &v) {
  std::sort(v.begin(), v.end());
  v.erase(std::unique(v.begin(), v.end()), v.end());
}


#line 2 "abc174_b.cpp"

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

  int n;
  ll d;
  cin >> n >> d;
  vl x(n), y(n);
  REP(i, n) { cin >> x[i] >> y[i]; }

  int ans = 0;
  REP(i, n) {
    if (d * d >= x[i] * x[i] + y[i] * y[i])
      ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 6364
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>

int H, W;

int BFS(pii init, string S[]){
  queue<pii> q;
  int to_x[4] = {0,0,1,-1};
  int to_y[4] = {1,-1,0,0};
  vector<vector<int>> dist(H,vector<int>(W,-1));
  q.push(init);
  dist[init.first][init.second] = 0;

  while (!q.empty()){
    auto now = q.front(); q.pop();
    for (int to=0;to<4;to++){
      int y = now.first + to_y[to], x = now.second +  to_x[to];
      // cout << y << " " << x << endl;
      if (y<0 || y>=H || x<0 || x>=W) continue;
      if (S[y][x]=='.' && dist[y][x]==-1) {
        q.push(make_pair(y,x));
        dist[y][x] = dist[now.first][now.second] + 1;
      }
    }

  }
  int max_dist = 0;
  rep(row,H) rep(col,W){
    if (dist[row][col]>max_dist){
      max_dist = dist[row][col];
      init = make_pair(row,col);
    }
  }
  return max_dist;
}

int main(){
  cin >> H >> W;
  string S[H];
  rep(i,H) cin >> S[i];
  
  vector<pii> init;
  rep(row,H) rep(col,W) if (S[row][col]=='.') init.push_back(make_pair(row,col));

  int ans = 0;
  for (auto ini : init){
    int dist = BFS(ini, S);
    ans = max(ans, dist);
  }
  cout << ans << endl;

  

  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	cin >> n;

	int* a;
	a = new int[n + 1];

	unsigned long long k = 0;

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

		if (t < a[i]) {
			k += t;
		}
		else if (t < (a[i] + a[i + 1])) {
			k += t;
			a[i + 1] = a[i] + a[i + 1] - t;
		}
		else {
			k += a[i] + a[i + 1];
			a[i + 1] = 0;
		}
	}

	cout << k;
}


Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int a[100005];
int main()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	int now = 1, cnt = 0;
	for (int i = 1; i <= n; i++)
	{
		now = a[now]; cnt++;
		if (now == 2)break;
	}
	if (now == 2)cout << cnt << endl;
	else cout << -1 << endl;
	return 0;
}

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

int isLeap(int y){
  return y%400==0||(y%4==0&&y%100!=0);
}

int main(void){
  int a,b, isNA;
  bool firstLineFlg=1;
  
  while (cin >> a >> b){
    if (a==0 && b==0) break;
    isNA=1;
    if (firstLineFlg) firstLineFlg = 0;
    else cout << endl;
    for (int i=a; i<=b; i++){
      if (isLeap(i)){
        isNA = 0;
        cout << i << endl;
      }
    }
    if (isNA){
      cout << "NA" << endl;
    }
  }
  
  return 0;
}


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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

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

const long long INF = 1LL<<60;
const int mod = 1000000007;

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



vector<vector<char>> A(1010, vector<char>(1010));
vector<vector<int>> dp(1010, vector<int>(1010, 0));

int H, W;
ll ans;

void add(int &a, int b) {
    a += b;
    if (a >= mod) a -= mod;
}


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

    cin >> H >> W;

    for (int h = 0; h < H; h++) {
        string line; cin >> line;
        for (int w = 0; w < W; w++) {
            A.at(h).at(w) = line.at(w);
        }
    }

    dp.at(0).at(0) = 1;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (i + 1 < H && A.at(i + 1).at(j) == '.') add(dp.at(i + 1).at(j), dp.at(i).at(j));
            if (j + 1 < W && A.at(i).at(j + 1) == '.') add(dp.at(i).at(j + 1), dp.at(i).at(j));
        }
    }

    cout << dp.at(H - 1).at(W - 1) << endl;

    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}
 
int main() {
    string ans = "";
    string s;
    cin >> s;
    int n = s.size();
    rep(i,n) {
        if(s[i] == '0') ans += '0';
        else if(s[i] == '1') ans += '1';
        else if(s[i] == 'B' && !ans.empty()) ans.erase(ans.size() - 1);
        else continue;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <cmath>

struct hist_t {
    std::array<int, 26> d;
};

void generateHistogram(const std::string& str, hist_t& hist) {
    int length = str.length();

    const char* str_c = str.c_str();
    for (int i = 0; i < length; i++) {
        hist.d[str_c[i] - 'a']++;
    }
}

int main(void) {
    int n;
    std::vector<std::string> strs;
    std::vector<hist_t> hists;

    std::cin >> n;

    strs.resize(n);
    hists.resize(n);

    hist_t min;
    std::fill(min.d.begin(), min.d.end(), 0x7fffffff);

    for (int i = 0; i < n; i++) {
        std::cin >> strs[i];

        std::fill(hists[i].d.begin(), hists[i].d.end(), 0);
        generateHistogram(strs[i], hists[i]);

        for (int j = 0; j < 26; j++) {
            min.d[j] = std::min(min.d[j], hists[i].d[j]);
        }
    }

    // for (int j = 0; j < 26; j++) {
    //     std::cout << static_cast<char>('a' + j) << ": " << min.d[j] << std::endl;
    // }

    std::string out = "";
    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < min.d[i]; j++) {
            out += static_cast<char>('a' + i);
        }
    }

    std::cout << out << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 5050

using namespace std;
typedef long long ll;
ll dp[maxn][maxn],a[maxn],n;

int main(){
    cin >> n;
    for (int i=1;i<=n;i++) cin >> a[i];
    for (int len=1;len<=n;len++){
        for (int l=1;l+len-1<=n;l++){
            int r=l+len-1;
            if ((n-len)&1) dp[l][r]=min(dp[l+1][r]-a[l],dp[l][r-1]-a[r]);
            else dp[l][r]=max(dp[l+1][r]+a[l],dp[l][r-1]+a[r]);
        }
    }
    cout << dp[1][n] << endl;
}


Measured memory_bytes: 118400
#include<stdio.h>
int main (void){
	int i = 0;
	int j = 0;
	for(i = 1;i != 10;i++){
		for(j = 1;j != 10;j++){
			printf("%dx%d=%d\n",i,j,i*j);
		}
	}
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,m,p;cin >> n>> m>>p;
  vector<PP> edge(m);
  rep(i,m){
      ll a,b,c;cin >> a >> b >> c;
      a--;b--;
      edge[i] = mp(a,mp(b,p-c));
  }
  vector<ll> d(n);
  fill(all(d),LINF);
  d[0] = 0;
  rep(i,2*n){
      rep(j,m){
          ll from = edge[j].first;
          ll to = edge[j].second.first;
          ll cost  = edge[j].second.second;
          if(d[from]+cost<d[to]){
              d[to] = d[from] + cost;
              if(i>=n-1 && to==n-1){
                  cout << -1 << endl;
                  return 0;
              }
          }
      }
  }
  cout << max(0ll,-d[n-1]) << endl;
}

Measured memory_bytes: 384
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_owned()
}

fn reads<T>() -> Vec<T>
where
    T: std::str::FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    read_line()
        .split_whitespace()
        .map(|w| w.parse().unwrap())
        .collect()
}

fn main() {
    let n = reads()[0];

    let v: Vec<(i64, i64)> = (0..n)
        .map(|_| {
            let t: Vec<i64> = reads();
            (t[0], t[1])
        })
        .collect();

    let mut diff = 0;
    for &(a, b) in v.iter() {
        if a != b {
            diff += 1;
        }
    }
    if diff == 0 {
        println!("0");
        return;
    }

    let mut max_small = 9999999999i64;
    let mut sum = 0;

    for &(a, b) in v.iter() {
        if a > b {
            max_small = std::cmp::min(max_small, b);
        }

        sum += b;
    }

    println!("{}", sum - max_small);
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String S=sc.next();

        char[] str=S.toCharArray();

        if (str[2]==str[3]&&str[4]==str[5]) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include<string>
#include <typeinfo>
using namespace std;
int main(void){
    // Your code here!
    int a;
    int sums=0;
    int& sum=sums;
    cin>>a;
    sum=a;
    int b[3];
    b[0]=(a%10);a=a/10;
    b[1]=(a%10);a=a/10;
    b[2]=(a%10);a=a/10;
    
    string c =to_string(b[0])+to_string(b[1])+to_string(b[2]);
    int conv_c =stoi(c);
    
    if(sum==conv_c) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
a=int(input())
b=[list(map(int,input().split())) for i in range(a)]
from operator import itemgetter
b.sort(key=itemgetter(2),reverse=True)
ans=[0,0,0]
for i in range(101):
  for j in range(101):
    h=abs(i-b[0][0])+abs(j-b[0][1])+b[0][2]      
    n=1
    while n<a:
      if max(h-abs(i-b[n][0])-abs(j-b[n][1]),0)==b[n][2]:
         n+=1
      else:
        break
    if n==a:
      ans=[i,j,h]
      print(*ans)
      exit()
      
      

  

Measured memory_bytes: 3064
N,Y=map(int,input().split())
Y//=1000

F=(-1,-1,-1)
for a in range(0,N+1):
    for b in range(0,N-a+1):
        c=N-(a+b)
        if a+5*b+10*c==Y:
            F=c,b,a

print(" ".join(map(str,F)))
        
        


Measured memory_bytes: 67424
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>> g(100001);
vector<int> c(100001);
int cnt=0;
void dfs(int k){
  c[k]=1;
  cnt++;
  for(auto z:g[k]) if(c[z]==0) dfs(z);
}
int main(){
  int n,m,i,j,a,b,ans=-1;
  cin>>n>>m;
  for(i=0;i<m;i++){
    cin>>a>>b;
    a--;b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  while(cnt<n){
    j=0;
    while(c[j]==1) j++;
    dfs(j);
    ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 9460
#include <stdio.h>

int main(void){
	int y,m,d;
	while(scanf("%d%d%d",&y,&m,&d) != EOF){
		if(y >= 1990 || y == 1989 && (m >= 2 || m == 1 && d >= 8)){
			printf("heisei %d %d %d\n",y-1988,m,d);
		}else if(y >= 1927 || y == 1926 && (m == 12 && d >= 25)){
			printf("showa %d %d %d\n",y-1925,m,d);
		}else if(y >= 1913 || y == 1912 && (m >= 8 || m == 7 && d >= 30)){
			printf("taisho %d %d %d\n",y-1911,m,d);
		}else if(y >= 1869 || y == 1868 && (m >= 10 || m == 9 && d >= 8)){
			printf("meiji %d %d %d\n",y-1867,m,d);
		}else{
			puts("pre-meiji");
		}

	}

	return 0;
}

Measured memory_bytes: 0
//Traveling AtCoDeer Problem
#include <iostream>
using namespace std;
int main(){
	
	int n;
	while (cin>>n){
		int a[n];
		for (int i =0;i<n;i++){
			cin>>a[i];
			
		}
		int max_ = 0;
		int min_ = 33333;
		for (int i =0;i<n;i++){
			if (a[i]<min_){
				min_=a[i];
			}
			
		}
		for (int i =0;i<n;i++){
			if (a[i]>max_){
				max_=a[i];
			}
			
			
		}
		cout<<max_-min_<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

//WA

int main(void){
	int N,L,x,a[100010],last=-1;
	cin>>N>>L;
	reg(i,1,N){
		cin>>x;
		a[i]=x;
	}
	reg(i,1,N-1){
		if(a[i]+a[i+1]>=L)last=i;//結び目iを最後にほどく．他は外から順番に解けば良い．
	}
	if(last==-1){
		printf("Impossible\n");
	}else{
		printf("Possible\n");
		reg(i,1,last-1)printf("%d\n",i);
		ireg(i,last,N-1)printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 1152
#lazy faith
import sys
input=sys.stdin.readline
import bisect
a,b,q=map(int,input().split())
A=[]
lists1=[int(input()) for i in range(a)]
lists2=[int(input())for i in range(b)]
lists1.insert(0,-10**12)
lists1.insert(1,-10**11)
lists2.insert(0,-10**12)
lists2.insert(1,-10**11)                  
lists1.append(10**11)
lists1.append(10**12)
lists2.append(10**11)
lists2.append(10**12)
for i in range(q):
    x=int(input())
    index1=bisect.bisect_right(lists1,x)
    index2=bisect.bisect_right(lists2,x)
    dis1=[]
    dis2=[]
    dis1.append(lists1[index1-2])
    dis1.append(lists1[index1-1])
    dis1.append(lists1[index1])
    dis1.append(lists1[index1+1])
    dis2.append(lists2[index2-2])
    dis2.append(lists2[index2-1])
    dis2.append(lists2[index2])
    dis2.append(lists2[index2+1])
    distance=[]
    x1=abs(x-dis1[1])
    mini1=10**12
    for i in range(4):
        mini1=min(mini1,abs(dis1[1]-dis2[i]))
    x2=abs(x-dis1[2])
    mini2=10**12
    for i in range(4):
        mini2=min(mini2,abs(dis1[2]-dis2[i]))
    x3=abs(x-dis2[1])
    mini3=10**12
    for i in range(4):
        mini3=min(mini3,abs(dis2[1]-dis1[i]))
    x4=abs(x-dis2[2])
    mini4=10**12
    for i in range(4):
        mini4=min(mini4,abs(dis2[2]-dis1[i]))
    A.append(min(x1+mini1,x2+mini2,x3+mini3,x4+mini4))
for k in A:
    print(k)
            

Measured memory_bytes: 16880
n,y = map(int,input().split())

flag = False

yki = min(n,y//10000)
for i in range(yki+1):
    for j in range(n-i+1):
        nogu = n -i - j
        if nogu*1000 + i*10000 + j*5000 == y and nogu >= 0:
            ans = [i,j,nogu]
            flag = True
            break
    if flag:
        break

if flag:
    print(*ans,sep = " ")
else:
    print(-1,-1,-1)

Measured memory_bytes: 3188
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n"
using namespace std;
//-------------------------------------------

int main(void){
  ll N;cin>>N;
  string S,T;cin>>S>>T;
  REP(i,N)cout<<S[i]<<T[i];
  cout<<"\n";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
using namespace std;

typedef pair<int,int> pii;

const int INF = 1010101010;

const char *p;

pii orexpr();
pii andexpr();
pii term();

pii orexpr(){
	pii a = andexpr();
	while(*p == '|'){
		++p;
		pii b = andexpr();
		a = pii(a.first + b.first, min(a.first + b.second, a.second));
	}
	return a;
}

pii andexpr(){
	pii a = term();
	while(*p == '&'){
		++p;
		pii b = term();
		a = pii(min(a.second + b.first, a.first), a.second + b.second);
	}
	return a;
}

pii term(){
	if(*p == '?'){
		++p;
		return pii(1, 1);
	}
	++p;
	pii a = orexpr();
	++p;
	return a;
}

int main(){
	string s;
	cin >> s;
	p = s.c_str();
	pii t = orexpr();
	cout << t.first << ' ' << t.second << '\n';
}



Measured memory_bytes: 3304
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);
ll fast_exp(ll base, ll exp) {
  ll res=1;
  while(exp>0) {
    if(exp%2==1) res=(res*base)%mod;
      base=(base*base)%mod;
      exp/=2;
  }
  return res%mod;
}

ll modadd(ll x, ll y){return (x%mod + y%mod)%mod;}
ll modmul(ll x, ll y){return (x%mod * y%mod)%mod;}
ll modsub(ll x, ll y){return (x%mod - y%mod + mod)%mod;}
ll moddiv(ll x, ll y){return modmul(x, fast_exp(y, mod-2));}
vector<ll> spf(1000010, 0) ;; 
const ll maxx = 1000010;
unordered_map<ll, ll> hv;
void smallest_prime_factor () {
  for(ll i = 2; i < maxx; i++) {
    spf[i] = i;
  }
  for(ll i = 4; i < maxx; i+=2) spf[i] = 2; // spf of an even number is 2.
  for(ll i = 3; i*i < maxx; i++) {
    if(spf[i] == i) {
      for(ll j = i*i; j < maxx; j+=i) {
        if(spf[j] == j) spf[j] = i;
      }
    }
  }
}
void count_primefactors(ll x) {
  ll ct = 0;
  ll prev = 0;
  while(x!= 1) {
    if(spf[x]!= prev) {
      hv[prev] = max(hv[prev], ct);
      ct = 0;
    }
    prev = spf[x];
    x/= spf[x] ;
    ct++ ;
  }
  hv[prev] = max(hv[prev], ct);
}

int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n;
  cin >> n;
  vll a(n);
  smallest_prime_factor();
  for(auto &it: a) cin >> it;
  for(auto it: a) count_primefactors(it);
  vector<pll> arr;
  for(auto it: hv) {
    if(it.ss > 0) arr.pb(mp(it.ff, it.ss));
  }
  ll ans = 0;
  for(auto it: a) {
    ll res = 1;
    for(auto et: arr) {
      ll ct = 0;
      while((it%et.ff) == 0){
        ct++;
        it/=et.ff;
      }
      res = modmul(res, fast_exp(et.ff, et.ss - ct));
    }
    ans = modadd(ans, res);
  }
  cout << ans << endl;
  return 0;
} //good night.

Measured memory_bytes: 8960
#include<stdio.h>
#include<string>
#include <iostream>

using namespace std;

int main(){
  int n, max;
  int price[50000];
  int i, j;

  while(1){
    cin >> n >> max;
    if(n == 0)
      break;
    
    for(i=0; i<n; i++){
      cin >> price[i];
    }

    int max_after=0;

    for(i=0; i<n; i++){
      for(j=i+1; j<n; j++){
	if(price[i]+price[j] <= max && price[i]+price[j] > max_after)
	  max_after = price[i]+price[j];
      }
    }

    if(max_after == 0){
      cout << "NONE" << endl;
    }else  cout << max_after << endl;

  }
}



Measured memory_bytes: 3096
def get_sosuu():
    sosuu_list = [2, 3, 5, 7, 11, 13, 17]

    for i in range(18, 55556):
        for ele in sosuu_list:
            if ele > int(i ** 0.5) + 1:
                sosuu_list.append(i)
                break
            if i % ele == 0:
                break
        else:
            sosuu_list.append(i)
    return sosuu_list


def amari(sosuu_list, num):
    amari1 = []
    for ele in sosuu_list:
        if ele % 5 == 1:
            amari1.append(ele)
            if len(amari1) == num:
                break
    return amari1


def main():
    num = int(input())

    sosuu_list = get_sosuu()
    amari1 = amari(sosuu_list, num)
    print(' '.join(list(map(str, amari1))))






if __name__ == '__main__':
    main()

Measured memory_bytes: 41328
n = int(input())
csf = [list(map(int, input().split())) for _ in range(n-1)]

for i in range(n):
    current = 0
    for j in range(i, n-1):
        if current < csf[j][1]:
            current = csf[j][1]
        if current % csf[j][2] != 0:
            current += csf[j][2] - (current % csf[j][2])
        current += csf[j][0]
    print(current)

Measured memory_bytes: 3188
#include <stdio.h>

int main(){
  int x,y;

  while(1){
    scanf("%d %d",&x,&y);
    if(x==0 && y==0) break;
    if(x<y){
      printf("%d %d\n",x,y);
	}
    else{
      printf("%d %d\n",y,x);
    }
  }
  return 0;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define maxn 100010
const int MOD = 1000000007;

void solve() {
    int n, m;
    cin >> n >> m;

    vector<int> v(n);
    priority_queue<int> pq;
    for (int tp, i = 0; i < n; ++i) {
        cin >> tp;
        pq.push(tp);
    }
    for (int i = 0; i < m; i++) {
        int tp = pq.top();
        pq.pop();
        pq.push(tp / 2);
    }
    int ans = 0;
    while(!pq.empty()){
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int A[N];
  for(int i = 0; i < N; i++) {
    cin >> A[i];
  }
  int Lgcdn[N];
  Lgcdn[0] = A[0];
  for(int i = 1; i < N; i++) {
    Lgcdn[i] = __gcd(Lgcdn[i-1], A[i]);
  }
  int Rgcdn[N];
  Rgcdn[N-1] = A[N-1];
  for(int i = N-2; i >= 0; i--) {
    Rgcdn[i] = __gcd(Rgcdn[i+1], A[i]);
  }
  int ans = 0;
  for(int i = 0; i <= N-3; i++) {
    ans = max(ans, __gcd(Lgcdn[i], Rgcdn[i+2]));
  }
  ans = max(ans, Rgcdn[1]);
  ans = max(ans, Lgcdn[N-2]);
  cout << ans << endl;
}
    

Measured memory_bytes: 1536
import sys
sys.setrecursionlimit(100000)

N = int(input())
adj_list = { i: [] for i in range(N+1) }
for _ in range(N-1):
  u,v,w = map(int, input().split())
  adj_list[u].append([v,w])
  adj_list[v].append([u,w])

res = [None] * N
visited = [False] * (N+1)
def dfs(node, c, w):
  res[node-1] = c
  visited[node] = True

  for nei, nw, in adj_list[node]:
    if not visited[nei]:
      if (w+nw)%2 == 0:
        dfs(nei, 0, w+nw)
      else:
        dfs(nei, 1, w+nw)

dfs(1, 0, 0)
for r in res: print(r)

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

#define SIZE_OF_ARRAY(array) sizeof(array)/sizeof(array[0])
typedef long long ll;

int main() {
    int N;
    cin >> N;
    int n = INT_MAX;
    int c = 0;
    int P;
    for(int i=0; i < N; i++){
        cin >> P;
        if(P <= n){
            n = P;
            c++;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int N,a[200005];
int main(){
	cin >> N ;
	for(int i=0;i<N-1;i++){
		int x;
		cin >> x;
		a[x]++;
	}
	for(int i=1;i<=N;i++){
		cout <<a[i] <<endl;
	}
}

Measured memory_bytes: 4376
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n;
    cin >> n;
    vector <ll> arr(n);
    for (int z=0;z<n;z++){
        cin >> arr[z];
    }
    vector <vector<ii>> dp(n,vector<ii>(n,{0,LLONG_MAX}));
    for (int z=0;z<n;z++){
        dp[z][z].first = arr[z];
        dp[z][z].second = 0;
    }
    for (int x=1;x<n;x++){
        for (int z=0;x+z<n;z++){
            ll a,b;
            a = dp[z][z+x-1].second+arr[z+x];
            b = dp[z][z+x-1].first;
            if (a-b > dp[z][z+x].first-dp[z][z+x].second){
                dp[z][z+x].first = a;
                dp[z][z+x].second = b;
            }
            a = dp[z+1][z+x].second+arr[z];
            b = dp[z+1][z+x].first;
            if (a-b > dp[z][z+x].first-dp[z][z+x].second){
                dp[z][z+x].first = a;
                dp[z][z+x].second = b;
            }

        }
    }
    cout << dp[0][n-1].first-dp[0][n-1].second << endl;
}

Measured memory_bytes: 141056
#include<cstdio>
#include<cstring>
int sum1[100005],sum2[100005],n,m,q;
char c[100005],d[100005];
int main(){
	scanf("%s%s",c,d);n=strlen(c);m=strlen(d);
	for(int i=0;i<n;++i)sum1[i+1]=(c[i]=='A')+1;
	for(int i=0;i<m;++i)sum2[i+1]=(d[i]=='A')+1;
	for(int i=1;i<=n;++i)sum1[i]+=sum1[i-1];
	for(int i=1;i<=m;++i)sum2[i]+=sum2[i-1];
	scanf("%d",&q);
	while(q--){
		int x,y,z,w;
		scanf("%d%d%d%d",&x,&y,&z,&w);
		printf((sum1[y]-sum1[x-1])%3==(sum2[w]-sum2[z-1])%3?"YES\n":"NO\n");
	}
	return 0;
}

Measured memory_bytes: 1408