akhauriyash/Code-Regression huggingface dataset:
/////////////////////////////////
//                             //
//           /(.^.)\           //
//                             //
/////////////////////////////////

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

#define BYTE unsigned char
#define DWORD unsigned int
#define QWORD unsigned long long
#define LL long long

//デバッグプリント
void xxxcoutxxx(int a, int f = 0)
{
    cout << a << " "; if (f) cout << endl;
    return;
}


std::vector<LL> eeee(LL n)
{
	std::vector<LL> ret;
    for(LL i=1 ; i*i<=n ; ++i)
    {
        if(n%i == 0)
        {
            ret.emplace_back(i);
            if(i*i!=n)
            {
                ret.emplace_back(n/i);
            }
        }
    }
    

	return ret;
}


//main
int main()
{
 
    int rtn = 0;
    LL A, B;
    
    cin >> A >> B;

    LL C = 0;
    
    if (A > B)
    {
        C = B;
        B = A;
        A = C;
    }
    //cout << A << B << C;

    std::vector<LL> vvv = eeee(A);
    std::sort(vvv.begin(),vvv.end());

    size_t sss = vvv.size();
    vector<bool> ng(sss,true);
    ng[0] = false;

    vector<LL> yyy;
    yyy.push_back(1);

    // for(auto q : vvv)
    // {
    //     cout << q << " ";
    // }
    // cout << endl;
    
    for (int i = 0; i < sss; ++i)
    {
        if (ng[i]) {
            yyy.push_back(vvv[i]);
            for (int k = i + 1; k < sss; ++k)
            {
                if (vvv[k] % vvv[i] == 0)
                {
                    ng[k] = false;
                }
            }
        }
    }

    // for(auto q : ng)
    // {
    //     cout << q << " ";
    // }
    // cout << endl;

    for(auto yi : yyy)
    {
        if (B % yi == 0)
        {
            ++rtn;
        }
        ///////////////////////
        // cout << yi << " ";
    }
    //////////////////////
    // cout << endl;

    cout << rtn;
    return 0;
    cout << "/(.^.)\\" << endl;
}

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

ll dblng[30][(ll)1e5 + 10];

int main(){
    ll N;
    cin >> N;
    vector<ll> X(N);
    for(ll &x : X) cin >> x;
    ll L;
    cin >> L;
    for(ll i = 0; i < N; i++){
        auto ite = upper_bound(X.begin(), X.end(), X[i] + L);
        ite--;
        dblng[0][i] = (ite - X.begin());
    }
    for(ll dig = 1; dig < 30; dig++){
        for(ll i = 0; i < N; i++){
            ll fst = dblng[dig - 1][i];
            dblng[dig][i] = dblng[dig - 1][fst];
        }
    }
    ll Q;
    cin >> Q;
    for(ll QQ = 0; QQ < Q; QQ++){
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        if(a > b) swap(a, b);
        ll ok = 1e9, ng = 0;
        while(ok - ng > 1){
            ll mid = (ok + ng) / 2;
            ll now = a;
            for(ll i = 0; i < 30; i++){
                if(!(mid & (1 << i))) continue;
                now = dblng[i][now];
            }
            if(now >= b) ok = mid;
            else ng = mid;
        }
        cout << ok << '\n';
    }
    return 0;
}


Measured memory_bytes: 25088
tuple = (1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51)

k = input()
j = int(k)
print(tuple[j - 1])

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

//オーバーフロー
//コーナーケース

typedef long long ll;

int main() {
    int n;
    string s;
    cin >> n >> s;
    for (int i = 0; i < s.size(); i++) {
        int d = s[i] - 'A';
        d += n;
        d %= 26;
        cout << (char)('A' + d);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main {

  static int k, a, b;
  
  public static void main(String[] args) throws Exception {
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    String[] in = br.readLine().split(" ");
    k = Integer.parseInt(in[0]);
    in = br.readLine().split(" ");
    a = Integer.parseInt(in[0]);
    b = Integer.parseInt(in[1]);

    br.close();

    boolean ok = false;

    for(int i = a; i <= b; i++){
      if(i % k == 0) ok = true;
    }

    System.out.println(ok ? "OK" : "NG");
    
    
  }

}

Measured memory_bytes: 32588
N,M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

ans = A.sort.reverse!
tmp = [ans.shift / 2]
(M-1).times do
  if ans.empty?
    ans = tmp
    tmp = [ans.shift / 2]
  elsif ans[0] < tmp[0]
    tmp << tmp.shift / 2
  else
    tmp << ans.shift / 2
  end
end
ans += tmp
puts ans.inject(:+)

Measured memory_bytes: 11000
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e18;
using Graph = vector<vector<int>>;

signed main() {
  int N, K, C;
  cin >> N >> K >> C;
  string S;
  cin >> S;

  //前から順に
  vector<int> mae;
  int cnt = C+1;
  for( int i = 0; i < N; i++ ){
    if( S[i] == 'o' && cnt >= C ){
      mae.push_back(i);
      cnt = 0;
    }else cnt++;
  }
  if( mae.size() > K ){
    return 0;
  }

  //後ろから（＝できるだけ遅く）順に選ぶ
  set<int> ushiro;
  cnt = C+1;
  for( int i = N-1; i >= 0; i-- ){
    if( S[i] == 'o' && cnt >= C ){
      ushiro.insert(i);
      cnt = 0;
    }else cnt++;
    if( ushiro.size() == K ) break;
  }

  for( int i = 0; i < K; i++ ){
    if( ushiro.count(mae[i]) ){
      cout << mae[i]+1 << endl;
    }
  }

}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
#include <iostream>
#include <climits>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define INF 1LL << 60;

int main( ){
  int K,S;
  int count=0;
  cin >> K >> S;
  
  for(int x=0; x <= K; x++){
    for(int y=0; y <= K; y++){
      if(S - K <= x+y && x+y <= S){
        count++;
      }
    }
  }
  cout << count << endl;
}

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

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

  ll N; cin >> N;
  ll M; cin >> M;
  ll ans = N * (N - 1) / 2 + M * (M - 1) / 2;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<vector>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;
ll a,b,c;
int main(){
    cin>>a>>b>>c;
    if(a+b+c>=22){
        cout<<"bust"<<endl;
    }else{
        cout<<"win"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;
typedef long long int LL;
const int MOD(998244353);

inline void update(int &a, const int &b)
{
	((a += b) >= MOD) ? (a -= MOD) : 0;
}

inline int Mult(const int &a, const int &b)
{
	return (a * 1LL) * b % MOD;
}

int power(int a, int n)
{
	int Ret(1);
	while (n)
	{
		if (n & 1)
			Ret = Mult(Ret, a);
		a = Mult(a, a), n >>= 1;
	}
	return Ret;
}

void exgcd(const int &a, const int &b, int &x, int &y)
{
	if (b == 0)
		x = 1, y = 0;
	else
		exgcd(b, a % b, y, x), y -= x * (a / b);
}

inline int inverse(const int &a)
{
	int invx, invy;
	exgcd(a, MOD, invx, invy);
	return (invx % MOD + MOD) % MOD;
}

//F[i][j]表示i行j列的答案，且要求每一行都非空，Ans = Sum{C(N, i) * F[i][M]}
//按照列dp。从第j列转移到第j + 1列的时候，考虑新出现了k行，满足它们在j + 1列第一次出现。这样dp可以保证A不同 
//k = 0时，若第j列为空，方案数为1；若非空，只与第j列最上面一行和最下面一行有关，方案数为C(i + 1, 2)
//k > 0时，方案数即1 <= x0 <= x1 < x2 < ... < xk <= xk+1 <= i + k的解数，差分一下可以求出解数为C(i + k + 2, k + 2)
//NTT优化dp即可

namespace NTT
{
	const int Max_L(16384 + 5);
	int L, A[Max_L], B[Max_L], W[Max_L];
	void clear()
	{
		for (int i = 0;i <= L - 1;++i)
			A[i] = B[i] = 0;
	}
	void DFT(int *P)
	{
		for (int i = 0, j = 0;i <= L - 1;++i)
		{
			if (j > i)
				swap(P[i], P[j]);
			for (int l = (L >> 1);(j ^= l) < l;l >>= 1)
				;
		}
		int z;
		for (int l = 2, m = 1;l <= L;l <<= 1, m <<= 1)
			for (int i = 0;i <= L - 1;i += l)
				for (int k = 0;k <= m - 1;++k)
				{
					z = Mult(P[i + m + k], W[L / l * k]);
					P[i + m + k] = ((P[i + k] - z) % MOD + MOD) % MOD;
					update(P[i + k], z);
				}
	}
	void NTT()
	{
		W[0] = 1, W[1] = power(3, (MOD - 1) / L);
		for (int i = 2;i <= L - 1;++i)
			W[i] = Mult(W[i - 1], W[1]);
		DFT(A), DFT(B);
		for (int i = 0;i <= L - 1;++i)
			A[i] = Mult(A[i], B[i]);
		W[0] = 1, W[1] = inverse(W[1]);
		for (int i = 2;i <= L - 1;++i)
			W[i] = Mult(W[i - 1], W[1]);
		DFT(A);
		int invL = inverse(L);
		for (int i = 0;i <= L - 1;++i)
			A[i] = Mult(A[i], invL);
	}
}

const int Max_N(8050);
const int Max_M(205);

int N, M, F[Max_N][Max_M], Fac[Max_N], Inv[Max_N];

inline int C(const int &n, const int &m)
{
	return (n < m) ? 0 : Mult(Fac[n], Mult(Inv[m], Inv[n - m]));
}

int main()
{
	scanf("%d%d", &N, &M);
	NTT::L = 1;
	while (NTT::L <= N + N)
		NTT::L <<= 1;
	Fac[0] = 1;
	for (int i = 1;i <= max(N, M) + 2;++i)
		Fac[i] = Mult(Fac[i - 1], i);
	Inv[max(N, M) + 2] = inverse(Fac[max(N, M) + 2]);
	for (int i = max(N, M) + 1;i >= 0;--i)
		Inv[i] = Mult(Inv[i + 1], i + 1);
	F[0][0] = 1;
	for (int j = 1;j <= M;++j)
	{
		for (int i = 0;i <= N;++i)
			update(F[i][j], Mult(F[i][j - 1], (1 + C(i + 1, 2)) % MOD));
		NTT::clear();
		for (int i = 0;i <= N;++i)
			NTT::A[i] = Mult(F[i][j - 1], Inv[i]);
		for (int k = 1;k <= N;++k)
			NTT::B[k] = Inv[k + 2];
		NTT::NTT();
		for (int k = 1;k <= N;++k)
			update(F[k][j], Mult(Fac[k + 2], NTT::A[k]));
	}
	int Ans(0);
	for (int i = 0;i <= N;++i)
		update(Ans, Mult(C(N, i), F[i][M]));
	printf("%d", Ans);
	return 0;
}

Measured memory_bytes: 6784
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
typedef long long ll;

int main(){
  
  string s,t;
  cin >> s >> t;
  int n = t.size();
  if(s == t.substr(0,n-1)) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define int long long
#define ios ios_base::sync_with_stdio(0); cin.tie(0);
//#define M 32
using namespace std;
//const int N = 1e5+7;
//const int MOD = 1e9+7;
//int a[N];
void solve() {
    int n;
    cin>>n;
    string in;
    int a,t,w,r;
    a=t=w=r=0;
    while(n--) {
        cin>>in;
        if(in == "AC")
            a++;
        if(in == "TLE")
            t++;
        if(in == "WA")
            w++;
        if(in == "RE")
            r++;
    }
    cout<<"AC x "<<a<<"\n";
    cout<<"WA x "<<w<<"\n";
    cout<<"TLE x "<<t<<"\n";
    cout<<"RE x "<<r<<"\n";
}
int32_t main() {
    ios
    //int t;
    //cin>>t;
        solve();
    return 0;
}


Measured memory_bytes: 3640
N,M = map(int, input().split())
K = [list(map(int,input().split())) for i in range(N)]
cnt = 0
for i in range(1,M+1):
    for j in range(N):
        K_tmp = K[j]
        K_tmp = K_tmp[1:]
        if K_tmp.count(i) == 0:
            break
    else:
        cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define All(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
#define IN(a, b, x) (a<=x&&x<b)
using namespace std;
using ll = long long;
using Pair = pair<int,int>;
using Graph = vector<vector<ll>>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename t, typename u, typename Comp=less<>>
bool chmax(t& xmax, const u& x, Comp comp={}) { if(comp(xmax, x)) { xmax = x; return true; } return false;}
template<typename t, typename u, typename Comp=less<>>
bool chmin(t& xmin, const u& x, Comp comp={}) { if(comp(x, xmin)) { xmin = x; return true;} return false;}
const int INF = 1e9;
const ll infl = ll(1e18)+5;

/*
*ios::sync_with_stdio(false);
*cin.tie(0);
*/
int main(){
  int x,n;cin >> x >> n;
  vector<bool> p(101);
  
  rep(i,n) {
    int a;
    cin >> a;
    p[a] = true; 
  }
  int m_ans = 0;
  int p_ans = 0;
  bool flag = false; 
  rep(i,300){
    if(x-i >= 0){
      if(p[x-i] == false) {
        m_ans = x-i;
        flag = true;
        break;
      }
    }else{
      m_ans = 0;
    }
    if(x+i <= 100){
      if(p[x+i] == false){
      p_ans = x+i;
      flag = true;
      break;
      }
    }else{
      p_ans = 101;
    }
  }
  
    if(abs(x-p_ans) < abs(x-m_ans)){
      cout << p_ans << endl;
    }else{
      cout << m_ans << endl;
    }
  
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}
int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N, M; cin >> N >> M;
    vec<plint> conditions(M);
    range(i, 0, M) {
        lint s, c; cin >> s >> c;
        s--;
        conditions.at(i) = {s, c};
    }

    range(n, 0, 1e3 + 1) {
        string res = to_string(n);
        if (res.size() != N) continue;
        bool okay = true;
        range(i, 0, M) {
            lint s, c; tie(s, c) = conditions.at(i);
            if (res.at(s) - '0' != c) okay = false;
        }
        if (okay) {
            cout << res << "\n";
            return 0;
        }
    }
    cout << -1 << "\n";
}

Measured memory_bytes: 256
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
// true / false
#define BIN_SEARCH(v, a) binary_search(ALL(v), a)
// index
#define BIN_LEFT(v, a) (lower_bound(ALL(v), a) - v.begin())
#define BIN_RIGHT(v, a) (upper_bound(ALL(v), a) - v.begin())
#define BIN_INSERT(v, a) (v.insert(v.begin() + BIN_LEFT(v, a), a))
#define DEL(v, i) v.erase(v.begin() + i)
#define INSERT(v, i, a) v.insert(v.begin() + i, a)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
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; }
// template end

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b, c, num;
    in >> a >> b >> c;
    num = a;
    REP(i, 101){
        if(num%b == c){
            out << "YES" << endl;
            break;
        }
        if(i == 100){
            out << "NO" << endl;
        }
        num += a;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
 
int main()
{
        int a,b,c;
        cin >> a>>b>>c;
        if(a==b)
        {
                if(b!= c)
                {       
                        cout << "Yes" << endl;
                }
                else{
                        cout << "No" <<endl;
                }
        }
        else if(b==c)
        {
                if(a!= b)
                {
                        cout << "Yes" << endl;
                }
                else{
                        cout << "No" <<endl;
                }
        }        
        else if(a==c)
        {
                if(b!= c)
                {
                        cout << "Yes" << endl;
                }
                else{
                        cout << "No" <<endl;
                }
        }
 
        else{
                cout << "No" <<endl;
        }
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int A = in.nextInt();
            int P = in.nextInt();
            out.println((P + A * 3) / 2);
        }

    }
}



Measured memory_bytes: 21844
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  int n; cin >> n;
  vector<P> v;
  rep(i, n) {
    ll a, b; cin >> a >> b;
    v.emplace_back(b, a);
  }
  ll sum = 0;
  sort(v);
  rep(i, n) {
    ll a = v[i].second, b = v[i].first;

    sum += a;
    if (sum > b) {
      No();
      return;
    }
  }

  Yes();
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 6384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

using vi = vector<int>;

struct UnionFind {
	vector<int> parent;
	vector<int> weight;

	UnionFind(int n) {
		parent = vector<int>(n);
		weight = vector<int>(n, 1);

		for (int i = 0; i < n; i++) parent[i] = i;
	}
	
	int root(int i) {
		while (i != parent[i]) {
			parent[i] = parent[parent[i]];
			i = parent[i];
		}
		
		return i;
	}

	bool find(int i, int j) {
		return root(i) == root(j);
	}

	void join(int i, int j) {
		i = root(i);
		j = root(j);

		if (i == j) return;

		if (weight[i] > weight[j]) {
			parent[j] = i;
			weight[i] = weight[j] + weight[i];
		} else {
			parent[i] = j;
			weight[j] = weight[i] + weight[j];
		}
	}
};

int main() {
	int N, M;
	cin >> N >> M;

	UnionFind uf(N);

	for (int i = 0; i < M; i++) {
		int a, b;

		cin >> a >> b;
		a--;
		b--;
		
		uf.join(a, b);
	}

	vector<int> count(N, 0);
	for (int i = 0; i < N; i++) count[uf.root(i)]++;

	sort(count.rbegin(), count.rend());

	cout << count[0] << endl;

	return 0;
}


Measured memory_bytes: 5616
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

std::vector<vector<int> > G;
std::vector<int> flag;
std::vector<int> in;
int N;
typedef pii P;

int main(int argc, char const *argv[]) {
	
	cin >> N;

	for (int i = 0; i < N; ++i) {
		G.push_back(vector<int>());
		flag.push_back(0);
		in.push_back(100000000);
		for (int j = 0; j < N; ++j) {
			G[i].push_back(0);
		}
	}

	for (int i = 0; i < N; ++i) {
		int u, k;
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; ++j) {
			int v;
			cin >> v;
			v--;
			G[u][v] = 1;
		}
	}
	queue<P> q;
	q.push(mp(0, 0));
	while(!q.empty()) {
		P u = q.front(); q.pop();
		int dist = u.second;
		if (dist > in[u.first]) continue;
		in[u.first] = dist;
		flag[u.first] = 1;
		for (int i = 0; i < N; ++i) {
			if (flag[i] == 0 && G[u.first][i] == 1) {
				q.push(mp(i, dist + 1));
			}
		}
	}

	for (int i = 0; i < N; ++i) {
		if (in[i] == 100000000) {
			in[i] = -1;
		}
		cout << i + 1 << " " << in[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

const ll MOD = (ll)1e9 + 7 ;
const int MAXN = 1e5 + 100;

void solve(){
    int x, y, a, b , c;
    cin >> x >> y >> a >> b >> c;
    vector<ll> A(a), B(b), C(c);
    for(auto & x: A)
        cin >> x;
    for(auto & x: B)
        cin >> x;
    for(auto & x: C)
        cin >> x;
    sort(A.rbegin(), A.rend());
    sort(B.rbegin(), B.rend());
    sort(C.rbegin(), C.rend());
    //Take first x , first y 
    vector<ll> fin(x + y);
    int id = 0;

    for(int i = 0; i < x; ++i)
        fin[id++] = A[i];
    for(int i = 0; i < y; ++i)
        fin[id++] = B[i];
    ll sum = 0;
    for(auto & x: fin)
        sum += x;
    sort(fin.rbegin(), fin.rend());
    //Now take until diff C[i] - fin[Lastid] is > 0;
    id = 0;
    bool valid = true;
    int j = fin.size() - 1;
    //cout << sum << '\n';
    while( id < c and valid ){
        ll diff = C[id] - fin[j];
        if( diff > 0){
            sum += diff;
            j--; id++;
        } else {
            valid = false;
            break;
        }
    }
    cout << sum << '\n';
    
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr); 
    //int t; cin >> t;
    //while(t--)
        solve();
    return 0;
}

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

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

struct p{
	int g,m;
	p(){}
	p(int g,int m):g(g),m(m){}
};

int h,w,s,sum[32][32];
p dp[32][32][32][32];

int main(){
	while(cin>>h>>w>>s&&h){
		memset(sum,0,sizeof(sum));
		memset(dp,0,sizeof(dp));
		rep(i,h)rep(j,w){
			int u;
			cin>>u;
			if(j==0){
				if(i==0)sum[0][0]=u;
				else sum[i][0]=sum[i-1][0]+u;
			}
			else{
				if(i==0)sum[0][j]=sum[0][j-1]+u;
				else sum[i][j]=sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1]+u;
			}
		}
		s=sum[h-1][w-1]-s;
		rep(i,h)rep(j,w)rep(k,h)rep(l,w){
			int S;
			if(j==0){
				if(i==0)S=sum[k][l];
				else S=sum[k][l]-sum[i-1][l];
			}
			else{
				if(i==0)S=sum[k][l]-sum[k][j-1];
				else S=sum[k][l]-sum[i-1][l]-sum[k][j-1]+sum[i-1][j-1];
			}
			if(S>=s)dp[i][j][k][l]=p(1,S);
		}
		rep2(H,1,h+1)rep2(W,1,w+1)rep(y,h-H+1)rep(x,w-W+1){
			int g=0,m=0;
			rep(i,H-1){
				p U=dp[y][x][y+i][x+W-1],D=dp[y+i+1][x][y+H-1][x+W-1];
				if(U.g&&D.g&&U.m>=s&&D.m>=s&&(U.g+D.g>g||U.g+D.g==g&&min(U.m,D.m)>m)){g=U.g+D.g,m=min(U.m,D.m);}
			}
			rep(i,W-1){
				p L=dp[y][x][y+H-1][x+i],R=dp[y][x+i+1][y+H-1][x+W-1];
				if(L.g&&R.g&&L.m>=s&&R.m>=s&&(L.g+R.g>g||L.g+R.g==g&&min(L.m,R.m)>m)){g=L.g+R.g,m=min(L.m,R.m);}
			}
			if(g)dp[y][x][y+H-1][x+W-1]=p(g,m);
		}
		cout<<dp[0][0][h-1][w-1].g<<" "<<dp[0][0][h-1][w-1].m-s<<endl;
	}
}

Measured memory_bytes: 9064
X = int(input())
max = [1]
n = int(X**(1/2))
for b in range(2, n+1):
    p = 2
    while b**p < X:
        p += 1
    if b**p == X:
        max.append(b**p)
    else:
        max.append(b**(p-1))
max.sort(reverse = True)
print(max[0])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using pi = pair <int, int>;
using ll = long long;
const ll mod = 1e9 + 7;
const int N = 2e5 + 10;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll a, b;
    cin >> a >> b;
    cout << a * b / __gcd(a, b);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;

int main() {
	int n;
	cin >> n;
	n = 1000-(n%1000);
	if(n==1000) cout << 0 << endl;
	else cout << n << endl;
}


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s, s1, s2, s3;
  cin >> s;
  s1 = s/100;
  s2 = (s-s1*100)/10;
  s3 = s-s1*100-s2*10;
  cout << s1+s2+s3 << endl;
}

Measured memory_bytes: 3556
import java.util.*;	

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

Measured memory_bytes: 23892
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

const int maxm = 100000 + 5;
bool primes[maxm];
void prime_gen(int n)
{
    fill(primes, primes + maxm, true);
    primes[0] = primes[1] = false;
    for(int i = 2; i <= n; i++)
    {
        if(primes[i])
        {
            if(i * 1ll * i <= n)
            {
                for(int j = i * i; j <= n; j += i)
                {
                    primes[j] = false;
                }
            }
        }
    }
}

int cnt[maxm];

void solve()
{
    prime_gen(maxm - 1);
    for(int i = 3; i < maxm; i++)
    {
        cnt[i] = cnt[i - 1];
        if((i & 1) && primes[i] && primes[(i + 1) / 2])
        {
            cnt[i]++;
        }
    }
    
    int q;
    cin >> q;
    for(int i = 0; i < q; i++)
    {
        int l, r;
        cin >> l >> r;
        cout << cnt[r] - cnt[l - 1] << "\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0), cout.tie(0);
    //freopen(FILE ".in", "r", stdin);freopen(FILE ".out", "w", stdout);
    //freopen("file.in", "r", stdin);freopen("file.out", "w", stdout);
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using ll=long long;
const ll MOD=1e9+7;
const int INF=1<<30;

int N,A,B,C;
vector<int> l;
int ans=INF;

void dfs(int a,int aa,int b,int bb,int c,int cc,int d,int i){
  if(i==N){
    if(aa>0&&bb>0&&cc>0){
      int sum=abs(a-A)+abs(b-B)+abs(c-C)+10*(aa-1)+10*(bb-1)+10*(cc-1);
      if(sum<ans)
        ans=sum;
    }
    return;
  }
  dfs(a+l[i],aa+1,b,bb,c,cc,d,i+1);
  dfs(a,aa,b+l[i],bb+1,c,cc,d,i+1);
  dfs(a,aa,b,bb,c+l[i],cc+1,d,i+1);
  dfs(a,aa,b,bb,c,cc,d+l[i],i+1);
  return;
}

int main(){
  cin >> N >> A >> B >> C;
  l.resize(N);
  rep(i,N){
    cin >> l[i];
  }
  dfs(0,0,0,0,0,0,0,0);
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
long long N,A,B,C,D;
bool ok(long long x,long long y)
{
    return min(x*D+y*C,y*D+x*C)<=B&&B<=max(x*D+y*C,y*D+x*C);
}
int main()
{
    cin>>N>>A>>B>>C>>D;
    B-=A;N-=1;
    for(long long x=0;x<=N;x++)
    {
        long long y=N-x;
        if(ok(x,y)){cout<<"YES";return 0;}
        if(ok(x,-y)){cout<<"YES";return 0;}
        if(ok(-x,y)){cout<<"YES";return 0;}
        if(ok(-x,-y)){cout<<"YES";return 0;}
    }
    cout<<"NO";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	ll a;
	string s;
	cin >> a >> s;
	string t = s.substr(0, s.length()-3);
	string x = s.substr(s.length()-2, 2);
	ll b = stoll(t, nullptr, 10);
	ll c = stoll(x, nullptr, 10);
	ll ans = (a*(b*100+c))/100;
	cout << ans << endl;
 	return 0;
}

Measured memory_bytes: 3588
#include<stdio.h>


int main() {
	char herix;
	scanf("%c", &herix);
	switch (herix) {
	case 'A':printf("T\n"); break;
	case 'T':printf("A\n"); break;
	case 'G':printf("C\n"); break;
	case 'C':printf("G\n"); break;
	}
	return 0;
}

Measured memory_bytes: 128
n,m = map(int,input().split())
a = [0]*n
ac,wa = 0,0
for i in range(m):
    p,s = map(str,input().split())
    p = int(p)
    if s == "AC" and a[p-1] != -1:
        ac +=1
        wa += a[p-1]
        a[p-1] = -1
    elif s == "WA" and a[p-1] != -1:
        a[p-1] += 1
print(ac,wa)


Measured memory_bytes: 3828
#include <cstdio>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <time.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <memory.h>
#include <cstdlib>
#include <queue>
#define P pair<int, int>
#define LL long long
#define LD long double
#define PLL pair<LL, LL>
#define mset(a, b) memset(a, b, sizeof(a))
#define PI acos(-1.0)
#define random(x) rand() % x
using namespace std;
const int inf = 0x3f3f3f3f;
const LL __64inf = 0x3f3f3f3f3f3f3f3f;
const int MAX = 2e5;
const int Mod = 1e9 + 7;

int main()
{
    int n;
    cin >> n;
    vector<int> w(n+1), s(n+1);
    for(int i = 1; i <= n; i++){
        cin >> w[i];
    }
    for(int j = 1; j <= n; j++){
        s[j] = s[j-1] + w[j];
    }
    int id1 = lower_bound(s.begin()+1, s.end(), s.back()/2) - s.begin();
    // int id2 = upper_bound(s.begin()+1, s.end(), s.back()/2) - s.begin();
    int id2 = id1-1;
    int d1 = abs(s.back() - 2 * s[id1]);
    int d2 = abs(s.back() - 2*s[id2]);
    if(d1 < d2){
        cout << d1 << endl;
    }
    else cout << d2 << endl;
    return 0;
}

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

int main(){
    int n, m, c;
    cin >> n >> m >> c;
    
    vector<int> b(m);
    rep(i, m){
        cin >> b.at(i);
    }
    
    int sum = c, count = 0;
    vector<vector<int>> a(n, vector<int> (m));
    rep(i, n){
        rep(j, m){
            cin >> a.at(i).at(j);
            sum += a.at(i).at(j)*b.at(j);
        }
        if(sum>0) count++;
        sum = c;
    }
    
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

const ll inf = 2e18;
const int mod = 998244353;
const int N = 2e5 + 10;

int dp[3010][3010];

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

	int n, s;
	cin >> n >> s;
	int a[n + 1];
	dp[0][0] = 1;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		for(int j = 0; j <= s; j++) {
			if(j + a[i] <= s) {
				dp[i][j + a[i]] = (dp[i][j + a[i]] + dp[i - 1][j]) % mod;
			}
			dp[i][j] = (dp[i][j] + (2 * dp[i - 1][j] % mod)) % mod;
		}
	}
	cout << dp[n][s];

	return 0;
}

Measured memory_bytes: 74228
n = int(input())
h = list(map(int, input().split()))

dp = [0]*n
dp[1] = abs(h[1]-h[0])
for i in range(1, n-1):
    dp[i+1] = min(dp[i-1]+abs(h[i+1]-h[i-1]), dp[i]+abs(h[i+1]-h[i]))

print(dp[-1])

Measured memory_bytes: 13980
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, s := scanInt(), scanInt()
	a := scanInts(n)

	dp := make([][]int, n+1)
	for i := 0; i < n+1; i++ {
		dp[i] = make([]int, s+3030)
	}

	dp[0][0] = 1
	for i := 0; i < n; i++ {
		for j := 0; j < s+1; j++ {
			dp[i+1][j] += dp[i][j] * 2
			dp[i+1][j+a[i]] += dp[i][j]
			dp[i+1][j] %= mod
			dp[i+1][j+a[i]] %= mod
		}
	}

	fmt.Fprintln(wr, dp[n][s])
}

const mod = 998244353


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

int main(){
    int h, w;
    
    while(1){
        cin >> h >> w;
        
        if((h == 0) && (w == 0)) break;
        
        for(int i = 0;i < h; i++){
            for(int j = 0;j < w; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main() {
    cin>>N>>K>>L;
    class union_find{
            vector<long> parent, tree_size;
        public:
            union_find(unsigned long _n) : parent(_n), tree_size(_n, 1){
                for(unsigned long i = 0; i < _n; ++i)parent[i] = i;
            }
            ll find(ll x){
                while(parent[x] != x)x = parent[x] = parent[parent[x]];
                return x;
            }
            void merge(ll a, ll b){
                a = find(a);
                b = find(b);
    	    if(a==b) return;
                if(tree_size[a] < tree_size[b])swap(a, b);
                tree_size[a] += tree_size[b];
                parent[b] = a;
                return;
            }
    	bool same(ll a, ll b){
    	    a = find(a);
    	    b = find(b);
    	    return a == b;
    	}
        };
    //uf.mergeのように使う
    //ufはMAX_N+1でとるか、代入時に0-indexedにする
    union_find train(N), way(N);
    rep(i,K) {
        cin>>A>>B;
        --A, --B;
        way.merge(A, B);
    }
    rep(i,L) {
        cin>>A>>B;
        --A, --B;
        train.merge(A, B);
    }
    map<ll,ll> id;
    rep(i,N) {
        ll temp = way.find(i) * N + train.find(i);
        ++id[temp];
    }
    rep(i,N){
        ll temp = way.find(i) * N + train.find(i);
        cout<<id[temp];
        i == N - 1 ? cout<<endl : cout<<' ';
    }
}

Measured memory_bytes: 18048
#include <iostream>

using namespace std;

int x(int n)
{
    return 100*n + 10*n + n;
}

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

    for (int i = 1; i < 10; i++){
        if(x(i) >= N){
            cout << x(i) << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

int N, C[502], S[502], F[502];

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

    cin >> N;
    rep(i, N - 1)cin >> C[i] >> S[i] >> F[i];

    rep(s, N) {
        int t = 0;
        FOR(i, s, N - 1) {
            int x = max((t - S[i] + F[i] - 1) / F[i], 0);
            smax(t, S[i] + F[i] * x);
            t += C[i];
        }
        cout << t << endl;
    }
}


Measured memory_bytes: 256
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

def popcount(n):
    return bin(n).count('1')
ans = False
a = sum(a,[])
abingo = 0
for i in b:
    if i in a:
        abingo |= 256>>(a.index(i))
virtical = 0b100100100
side = 0b111000000
downleft = 0b001010100
downright = 0b100010001
for i in range(3):
    if popcount(abingo & virtical)==3: ans=True
    if popcount(abingo & side)==3: ans=True
    virtical >>= 1
    side >>= 3
if popcount(abingo & downleft)==3: ans=True
if popcount(abingo & downright)==3: ans=True

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

Measured memory_bytes: 3064
# 写経
# https://atcoder.jp/contests/m-solutions2020/submissions/15454214

import sys
import numpy as np
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def resolve(XYP):
	X, Y, P = XYP[::3], XYP[1::3], XYP[2::3]
	N = len(X)
	X_cost = np.empty((1 << N,N), np.int64)
	X_cost[0] = np.abs(X) * P
	for n in range(N):
		B = 1 << n
		X_cost[B:2 * B] = np.minimum(X_cost[:B], np.abs((X-X[n]) * P))
	#print(X_cost)
	Y_cost = np.empty((1 << N,N), np.int64)
	Y_cost[0] = np.abs(Y) * P
	for n in range(N):
		B = 1 << n
		Y_cost[B:2 * B] = np.minimum(Y_cost[:B], np.abs((Y-Y[n]) * P))
	#print(Y_cost)
	popcount = np.zeros(1 << N, np.int64)
	for n in range(N):
		popcount[1 << n:1 << n + 1] = popcount[:1 << n] + 1
	#print(popcount)

	INF = 10**18
	ans = np.full(N + 1, INF, np.int64)
	for s in range(1 << N):
		size = popcount[s]
		t = s
		#print("s" + str(s))
		#print("size" + str(size))
		while True:
			u = s ^ t
			#print("u" + str(u))
			#print("t" + str(t))
			cost = (np.minimum(X_cost[t], Y_cost[u])).sum()
			ans[size] = min(ans[size], cost)
			if t == 0:
				break
			t = (t - 1) & s
	return ans 

if sys.argv[-1] == 'ONLINE_JUDGE':
	import numba
	from numba.pycc import CC
	i8 = numba.int64
	cc = CC('my_module')
 
	def cc_export(f, signature):
		cc.export(f.__name__, signature)(f)
		return numba.njit(f)
 
	resolve = cc_export(resolve, (i8[:], ))
	cc.compile()
 
from my_module import resolve

N = int(readline())
XYP = np.array(read().split(), np.int64)

ans = resolve(XYP)
print('\n'.join(map(str, ans.tolist())))

Measured memory_bytes: 36420
#include <iostream>

using namespace std;
#include <string>
typedef long long int ll;

int main(){
  int N;
  string S;
  cin >> N;
  cin >> S;

  int count = 1;
  char s=S[0];
  for(int i=1;i<N;i++){
    if(s != S[i]){
      count += 1;
      s = S[i];
    }
  }

  cout << count;


  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	string s,t,u; cin>>s>>t;
	int a,b; cin>>a>>b;
	cin>>u;
	(u==s)?a--:b--;
	cout<<a<<" "<<b<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < n; i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    int n, h, w;
    cin >> n >> h >> w;
    cout << (n+1-h) * (n+1-w) << endl;
}

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

#define N 100000+2

#define MOD (1.0e9 + 7)

using namespace std;

int zero;
int a[N];

int main(void)
{
    int n;

    cin>>n;

    for(int i = 0;i < n;i++)
    {
	int temp;
	cin>>temp;
	
	a[temp]++;
	a[temp+1]++;
	if(temp == 0)
	    zero++;
	else
	    a[temp-1]++;
    }
    int max = zero;

    for(int i = 0;i < N;i++)
    {
	max = max > a[i] ? max : a[i];
    }

    cout<<max<<endl;

    return 0;
}



Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main(){
  int YUYUSHIKI,i,j,k;
  char YUKARI[1001],YUZUKO[1001];
  int YUI[1001][1001];
  int MIKAMI,HINATA,NONOMURA;
  scanf("%d",&YUYUSHIKI);
  for(k=0;k<YUYUSHIKI;k++){
    MIKAMI=0;
    scanf("%s%s",YUZUKO,YUKARI);
    HINATA=strlen(YUKARI);
    NONOMURA=strlen(YUZUKO);
    for(i=HINATA;i>0;i--)YUKARI[i]=YUKARI[i-1];
    for(i=NONOMURA;i>0;i--)YUZUKO[i]=YUZUKO[i-1];
    for(i=0;i<=HINATA;i++){
      for(j=0;j<=NONOMURA;j++){
	if(i==0||j==0){
	  YUI[i][j]=0;
	  continue;
	}
	if(YUZUKO[j]==YUKARI[i]){
	  YUI[i][j]=YUI[i-1][j-1]+1;
	  MIKAMI=MIKAMI>YUI[i][j]?MIKAMI:YUI[i][j];
	}else
	  YUI[i][j]=YUI[i][j-1]>YUI[i-1][j]?YUI[i][j-1]:YUI[i-1][j];
      }
    }
    printf("%d\n",MIKAMI);
  }
  
  return 0;
}



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

int main() {
    int N,D;
    cin >> N >> D;

    int X[N+1],Y[N+1],cnt =0;

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

        cin >> X[i] >> Y[i];

    }

    for (int i=1;i<=N;i++) {
        if (
            sqrt(pow(X[i],2) + pow(Y[i],2)) <= D
        ) {
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


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

int main(void){
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    sort(a.rbegin(),a.rend());
    ll ans=a[0];
    ll i=0;
    ll times=n-2;
    for(i=1;i<n;i++){
        for(int j=0;j<2;j++){
            if(times>0){
                ans+=a[i];
                times--;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4804
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

//素数を指数と共に返す関数。pが底でnumが指数
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main(){
  int n; cin >> n;
  map<int,int> mp;
  for(int i = 1; i <= n; i++){
    auto v = prime_factorize(i);
    for(auto v1:v){
      mp[v1.first] += v1.second;
    }
  }
  ll ans = 1;
  for(auto m:mp){
    ans = ans * (m.second+1) % MOD;
    //printf("%d,%d\n",m.first,m.second);
  }
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<P> a(n);
    rep(i, n){
        int x, y;
        cin >> x >> y;
        a[i] = make_pair(x, y);
    }
    sort(a.begin(), a.end());
    ll cnt = 0;
    int ans;
    rep(i, n){
        cnt += a[i].second;
        if(cnt >= k) {
            ans = a[i].first;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024