akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x) do{rep(__i,(x).size()) pri(x,__i);}while(0)
#define pran(x,n) do{rep(__i,n) pri(x,__i);}while(0)
#define pral(x) do{cerr << (#x) << " =";rep(__i,(x).size()) cerr<<" "<<(x[__i]);cerr<<endl;}while(0)
#define prar(x,b,e) do{repr(__i,b,e) pri(x,__i);}while(0)

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;

ll MOD = 1000000007;

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

vint grun(100010);

ll rmb(ll x) {
	return x & -x;
}

ll L;
struct Trie {
	Trie *ch[2];
	int value;
	bool terminal;
	int depth;
	Trie() {
		ch[0] = ch[1] = 0;
		terminal = false;
	}
	void add(int d, int v, const char *s) {
		value = v;
		depth = d;
		if (s[0] == 0) {
			terminal = true;
			return;
		}
		int chval = s[0] - '0';
		// pr(chval);
		if (ch[chval] == 0) ch[chval] = new Trie;
		ch[chval]->add(d + 1, chval, s + 1);
	}
	ll solve() {
		pr(value);
		pr(depth);
		if (terminal) return 0;
		ll ret;
		if (ch[0] == 0 && ch[1] == 0) {
			int *p = 0;
			*p = 42;
		}
		else if (ch[1] == 0) {
			ret = ch[0]->solve() ^ rmb(L - depth);
		}
		else if (ch[0] == 0) {
			ret = ch[1]->solve() ^ rmb(L - depth);
		}
		else {
			ret = ch[0]->solve() ^ ch[1]->solve();
		}
		pr(ret);
		return ret;
	}
} root;

int main() {
	// grun[0] = 0;
	// grun[1] = 1;
	// repr(i, 2, 100) {
	// 	vint app(102);
	// 	int t = 0;
	// 	for (int k = i - 1; k >= 0; k--) {
	// 		t ^= grun[k];
	// 		app[t] = 1;
	// 	}
	// 	int g = 1;
	// 	while (app[g]) g++;
	// 	grun[i] = g;
	// }
	// pran(grun, 100);
	// return 0;
	int N = in();
	scanf("%lld ", &L);
	vector<string> data(N);
	rep(i, N) {
		string s;
		cin >> s;
		data[i] = s;
	}
	// sort(data.begin(), data.end());
	rep(i, N) root.add(0, -1, data[i].c_str());
	ll ans = root.solve();
	pr(ans);
	cout << (ans == 0 ? "Bob" : "Alice") << endl;
	return 0;
}


Measured memory_bytes: 10112
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

int main() {
    int n, counter = 0;
    vector<ll> nums;
    cin >> n;

    while (n--) {
        int temp;
        cin >> temp;
        nums.emplace_back(temp);
    }

    for (int i = 0; i < nums.size(); ++i)
        for (int j = i + 1; j < nums.size(); ++j)
            for (int k = j + 1; k < nums.size(); ++k)
                if (nums[i] + nums[j] > nums[k] && nums[i] + nums[k] > nums[j] && nums[j] + nums[k] > nums[i] && nums[i] != nums[j] && nums[j] != nums[k] && nums[i] != nums[k])
                    ++counter;

    cout << counter;
    return 0;
}


Measured memory_bytes: 3624
// Created by Kshitij Anand NSIT
#include <bits/stdc++.h>


using namespace std;


#define int long long
#define pb push_back
#define P pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define vc vector<char>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mp(a, b) make_pair(a, b)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define fill(arr,val) memset(arr,val,sizeof(arr))
#define db(x)  cout<<#x<<" : "<<x<<endl


const int N = 1000000007;

int func(int arr[][3] , int n){

	int dp[n][3] = {};

	dp[0][0] = arr[0][0];
	dp[0][1] = arr[0][1];
	dp[0][2] = arr[0][2];

	int prev = -1;


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

		dp[i][0] = max3( arr[i][0] + dp[i-1][1] , dp[i][0] ,arr[i][0] + dp[i-1][2] );
		dp[i][1] = max3( arr[i][1] + dp[i-1][0] , dp[i][1] ,arr[i][1] + dp[i-1][2] );
		dp[i][2] = max3( arr[i][2] + dp[i-1][1] , dp[i][2] ,arr[i][2] + dp[i-1][0] );
	}

	int ans = max3(dp[n-1][0] , dp[n-1][1] , dp[n-1][2]);
	return ans;
}

void solve(){

    int n,a,b,c, ans=0, count=0, sum=0;
    cin>>n;
    int arr[n][3];
    for(int i=0;i<n;i++){

    	for(int j=0; j<3; j++) {
	      cin>>arr[i][j];
    	}
    }

    ans = func(arr , n);
    cout<<ans<<endl;


}

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

  return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	vector<int> x(5);
	for (int i = 0; i < 5; i++) {
		cin >> x[i];
		if (x[i] == 0)cout << i+1;
	}
}

Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll N, W;
	std::cin >> N >> W;
	vll w(N), v(N);
	rep(i, 0, N) {
		std::cin >> w[i] >> v[i];
	}

	vector<vll> dp(N + 1, vll(100011, 99999999999));
	repeq(i, 0, N) {
		dp[i][0] = 0;
	}


	rep(i, 0, N) {
		repeq(j, 1, 100010) {
			if (j < v[i]) {
				dp[i+1][j] = dp[i][j];
			}
			else {
				dp[i+1][j] = min(dp[i][j - v[i]] + w[i], dp[i][j]);
			}
		}
	}

	for (int i = 100010; i >= 0; i--) {
		if (dp[N][i] <= W) {
			std::cout << i << endl;
			return 0;
		}
	}

	std::cout << 0 << endl;
	return 0;

}


Measured memory_bytes: 80256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long min = 1000000, max = -1000000, sum = 0;
        for(int i = 0; i < n; i++){
            long buf = sc.nextInt();
            if(buf < min) min = buf;
            if(buf > max) max = buf;
            sum += buf;
        }
        System.out.println(String.format("%d %d %d", min, max, sum));
    }
}



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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;

struct Combination {
  int mod;
  vector< int64_t > mfact, rfact;

  Combination(int sz, int mod) : mfact(sz + 1), rfact(sz + 1), mod(mod) {
    mfact[0] = 1;
    for(int i = 1; i < mfact.size(); i++) {
      mfact[i] = mfact[i - 1] * i % mod;
    }
    rfact[sz] = inv(mfact[sz]);
    for(int i = sz - 1; i >= 0; i--) {
      rfact[i] = rfact[i + 1] * (i + 1) % mod;
    }
  }

  int64_t fact(int k) const {
    return (mfact[k]);
  }

  int64_t pow(int64_t x, int64_t n) const {
    int64_t ret = 1;
    while(n > 0) {
      if(n & 1) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return (ret);
  }

  int64_t inv(int64_t x) const {
    return (pow(x, mod - 2));
  }

  int64_t P(int n, int r) const {
    if(r < 0 || n < r) return (0);
    return (mfact[n] * rfact[n - r] % mod);
  }

  int64_t C(int p, int q) const {
    if(q < 0 || p < q) return (0);
    return (mfact[p] * rfact[q] % mod * rfact[p - q] % mod);
  }

  int64_t H(int n, int r) const {
    if(n < 0 || r < 0) return (0);
    return (r == 0 ? 1 : C(n + r - 1, r));
  }
};

map< int, int > dp[32];

int rec(int x, int rest) {
  if(x == 1) return rest == 0;
  if(rest <= 0) return 0;
  if(dp[rest].count(x)) return dp[rest][x];
  int ret = 0;

  vector< int > divisor;
  for(int i = 1; i * i <= x; i++) {
    if(x % i == 0) {
      divisor.emplace_back(i);
      if(i * i != x) divisor.emplace_back(x / i);
    }
  }
  for(auto &p : divisor) {
    if(x != p) (ret += rec(p, rest - 1)) %= mod;
  }
  return dp[rest][x] = ret;
}

int main() {
  int N, M;
  cin >> N >> M;
  Combination beet(N + 1, mod);
  int ret = 0;
  for(int i = 0; i <= min(31, N); i++) { // 2以上の個数
    int rest = N - i;
    auto add = beet.C(N, i);
    (add *= rec(M, i)) %= mod;
    (ret += add) %= mod;
  }
  cout << ret << endl;
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
#define LL long long
int n,m,x,y,L,R,M,T,fl;
int f[100005],vis[100005],a[100005],b[100005],rt[100005];
vector <int> e[100005];
int g[500005],lc[500005],rc[500005];
LL sum,w[100005];
int find(int x){
	return f[x]==x?x:f[x]=find(f[x]);
}
int he(int u,int v){
	if (!u||!v) return u+v;
	if (a[g[u]]-b[g[u]]>a[g[v]]-b[g[v]]) swap(u,v);
	lc[u]=he(lc[u],v);
	swap(lc[u],rc[u]);
	return u;
}
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i) scanf("%d%d",&a[i],&b[i]),sum+=b[i];
	for (int i=1;i<=m;++i){
		scanf("%d%d",&x,&y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	L=0; R=1000000000;
	while (L<R){
		M=(L+R)/2; T=0; fl=0;
		for (int i=1;i<=n;++i)
			{f[i]=i; w[i]=M; vis[i]=0;}
		for (int i=1;i<=n;++i)
		if (a[i]<=b[i]+M&&!vis[i]){
			g[++T]=i; lc[T]=rc[T]=0; rt[i]=T;
			while (rt[i]){
				x=g[rt[i]];
				if (a[x]-b[x]>w[i]) break;
				rt[i]=he(lc[rt[i]],rc[rt[i]]);
				if (vis[x]) continue;
				w[i]+=b[x]; f[x]=i; vis[x]=1;
				for (unsigned j=0;j<e[x].size();++j){
					y=find(e[x][j]);
					if (y==i) continue;
					if (!vis[y]){
						g[++T]=y; lc[T]=rc[T]=0;
						rt[i]=he(rt[i],T);
					}else{
						rt[i]=he(rt[i],rt[y]);
						f[y]=i; w[i]+=w[y]-M;
					}
				}
				if (w[i]==sum+M) {fl=1; break;}
			}
			if (fl) break;
		}
		if (fl) R=M; else L=M+1;
	}
	printf("%lld\n",sum+L);
	return 0;
}


Measured memory_bytes: 13692
#include <stdio.h>
int prime(int a)
{
    int i=2;
    while(1)
    {
        if(i * i > a){
            return 1;
            break;
        } else  if(a % i == 0){
            return 0;
            break;
        } else {
            i++;
        }
    }
}

int main()
{
    int j, n, c, a[10000]={0}, cnt=0;
    scanf("%d", &n);
    for(j=0; j<n; j++){
        scanf("%d", &a[j]);
    }
    for(j=0; j<n; j++){
        c = prime(a[j]);
        cnt += c;
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 644
def mainFunc():
    N = int(input())
    matrix = [[0 for i in range(10)] for i in range(10)]
    for i in range(1, N + 1):
        start = int(str(i)[0])
        end = int(str(i)[-1])
        matrix[start - 1][end - 1] += 1
    
    ans = 0
    for i in range(10):
        for j in range(10):
            ans += matrix[i][j] * matrix[j][i]

    print(ans)


mainFunc()

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>

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



int main(){
    int N;
    int i;
    char S[N];
    char dammy;
    scanf("%d", &N);
    //printf("%d\n", N);
    scanf("%c", &dammy);
    for(i=0;i<N;i++){
        scanf("%s", &S[i]);
    }

    int ans = 1;
    int hoge = N/2;
    if(N%2==1){
        printf("No\n");
        return 0;
    }else{
        //char T[N/2];
        
        for(i=0;i<hoge;i++){
            if(S[i]==S[i+hoge]){
                ans*=1;
            }else{
                ans*=0;
            }
        }
    if(ans==1){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
   
    return 0;    

    }
    
    

}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<bitset>
#include<cstdio>

#define PII pair<int,int>
#define LLI long long int

using namespace std;

int main(){
	int N,K,Q;cin>>N>>K>>Q;
	vector<int>R(N+1,0);
	for(int i=0;i<Q;i++){
		int tmp;cin>>tmp;
		R[tmp]++;
	}
	for(int i=1;i<=N;i++){
		string ans;
		if(Q-R[i]>=K)ans="No";
		else ans="Yes";
		cout<<ans<<endl;
	}

	return 0;
}



Measured memory_bytes: 1024
n, m = map(int,input().split())

ac = [0]*n
wa = [0]*n
for _ in range(m):
    p, s = input().split()
    p = int(p) -1
    if s == 'AC':
        ac[p] = 1
    elif ac[p] == 0:
        wa[p] += 1

ans = 0
for i in range(n):
    if ac[i] == 1:
        ans += wa[i]

res = ac.count(1)

print(res, ans)

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    string S; cin >> S;
    int N = S.length();
    int ans = 0;
    for (int i = 0, j = N-1; i < j; ++i, --j) {
        if (S[i] != S[j]) ++ans;
    }
    cout << ans;
}



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

using namespace std;

int main()
{
    string a, b, c;
    cin>>a>>b>>c;
    //cout<<a[a.size()-1]<<" "<<
    if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0]){
        cout<<"YES";
    }
    else{
        cout<<"NO";
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define test int t; cin >> t; while (t--)
#define fast ios::sync_with_stdio(NULL); cin.tie(NULL)
#define mod 1000000007
#define endl "\n"
#define gcd(m,n) __gcd(m,n)
#define lcm(m,n) m*(n/GCD(m,n))
#define all(v) v.begin(),v.end()
#define ll long long
typedef vector<ll> vecll;
typedef vector<int> veci;
typedef vector<char> vecc;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
#define pb push_back
#define mp make_pair
#define time 1.0 * clock() / CLOCKS_PER_SEC


int main(){
    fast;
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static const int INFTY = (1 << 29);

int main()
{
    vector<int> v;
    int i = 1;
    int sum = i*(i+1)*(i+2) / 6;
    v.push_back(0);
    while(sum <= 10000000) {
        v.push_back(sum);
        i++;
        sum = i*(i+1)*(i+2) / 6;
    }

    int N, m, resa, resb;

    for(; ;) {
        scanf("%d", &N);
        if (N == 0) break;
        resa = resb = INFTY;
        m = upper_bound(v.begin(), v.end(), N)-v.begin()-1;
        if (v[m] == N) resa = 1;
        if (v[m] == N && v[m] % 2 != 0) resb = 1;

        int T[N+1];
        if (resa == INFTY) {
            for(i = 0; i <= N; i++) T[i] = INFTY;
            T[0] = 0;
            for (i = 1; i <= m; i++) {
                for (int j = 0; j + v[i] <= N; j++) {
                    T[j+v[i]] = min(T[j+v[i]], T[j]+1);
                }
            }
            resa = T[N];
        }
        if (resb == INFTY) {
            for(i = 0; i <= N; i++) T[i] = INFTY;
            T[0] = 0;

            for (i = 1; i <= m; i++) {
                if (v[i] % 2 == 0) continue;
                for (int j = 0; j + v[i] <= N; j++) {
                    T[j+v[i]] = min(T[j+v[i]], T[j]+1);
                }
            }
            resb = T[N];
        }
        printf("%d %d\n", resa, resb);
    }
    return 0;
}



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

using namespace std;

#define ll long long
#define ull unsigned long long
#define re register
#define il inline
#define inf 0x3f3f3f

bitset<4000020> f; //最多2000个数，每个数最大值为2000
int main(int argc, char const *argv[]) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n;
  std::cin >> n;
  f[0] = 1;
  int s = 0;
  while (n--) {
    int tmp;
    std::cin >> tmp;
    f |= f << tmp;
    s += tmp;
  }

  for (int i = (s + 1) / 2; i <= s; ++i)
    if (f[i]) {
      std::cout << i << '\n';
      break;
    }
  return 0;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void) {
	int64 N;
	int64 a[3];
	cin >> N;
	REP(i, 3) cin >> a[i];
	vector<int64> l(N);
	REP(i, l.size()) cin >> l[i];
	vector<vector<int64>> dp(4, vector<int64>(1<<N, INF));
	dp[0][0] = 0;
	REP(i, 3) {
		REP(j, 1 << N) {
			int64 mask = ((1 << N)-1) ^ j;
			for (int64 k = mask; k > 0; k = (k-1)&mask) {
				int64 num = __builtin_popcountll(k);
				int64 sum = 0;
				REP(x, 8)
					if (k >> x & 1) sum += l[x];
				int64 cost = abs(sum-a[i])+(num-1)*10;
				chmin(dp[i+1][k|j], dp[i][j] + cost);
			}
		}
	}
	cout << *min_element(all(dp[3])) << endl;
}


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

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

    int n = s.size();
    int i;
    vector<int> tile(n);
    for(i=0; i<n; i++) {
        tile.at(i) = s[i] - '0';
    }

    //cnt1 0スタート cnt2 1スタート
    int cnt1 = 0, cnt2 = 0;
    for(i=0; i<n;) {
        if(tile.at(i) == 0) {
            cnt2++;
        }
        else {
            cnt1++;
        }

        if(i + 1 > n - 1) {
            break;
        }
        i++;

        if(tile.at(i) == 0) {
            cnt1++;
        }
        else {
            cnt2++;
        }

            if(i + 1 > n - 1) {
            break;
        }
        i++;
    }

    if(cnt1 < cnt2) {
      cout << cnt1;
    }
    else {
        cout << cnt2;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 896
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    public struct P
    {
        public int index;
        public List<int> ad;
        public P(int index)
        {
            this.index = index;
            ad = new List<int>();
        }
    }
    static void Main(string[] args)
    {
        var ps = new P[4];
        for (var i = 0; i < 4; i++)
            ps[i] = new P(i);
        for(var i = 0; i < 3; i++)
        {
            var inp = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
            ps[inp[0] - 1].ad.Add(inp[1] - 1);
            ps[inp[1] - 1].ad.Add(inp[0] - 1);
        }
        WriteLine(dfs(new HashSet<int>(), 0, ps) ? "YES" : "NO");

    }
    private static bool dfs(HashSet<int> set,int index,P[] ps)
    {
        set.Add(index);
        if (set.Count == 4) return true;
        foreach(var p in ps[index].ad)
        {
            if (!set.Contains(p)) return dfs(set, p, ps);
        }
        set.Remove(index);
        return false;
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if (s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        r: f32,
    }
    println!("{}", r * 2.0 * 3.14159265);
}


Measured memory_bytes: 2204
import java.util.*;


class Main{
	public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
	int B = sc.nextInt();
	int sum = 0;
	for( int i =1; i < N+1 ; ++i){
    	if((sumup(i)>= A)&&(sumup(i)<=B)){
        sum += i;
        }
    }
    System.out.println(sum);
      
    }
  	public static int sumup(int x){
  	int sum = 0;
	while(x>0){
    	sum += x%10;
    	x = x/10;
    }
    return sum;
    }
  
  
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;

void triangle_check(int max, int x, int y);

int main(){
    int n, a, b, c;

    cin >> n;

    while (n-- > 0) {
        cin >> a >> b >> c;

        if (a > b) {
            if (a > c) {
                triangle_check(a, b, c);
            }
            else {
                triangle_check(c, a, b);
            }
        }
        else {
            if (b > c) {
                triangle_check(b, a, c);
            }
            else {
                triangle_check(c, a, b);
            }
        }
    }

    return 0;
}

void triangle_check(int max, int x, int y) {
    if ( max*max == x*x + y*y )
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

Measured memory_bytes: 2980
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)
#define ALL(a) a.begin(), a.end()
#define pii pair<int,int>
#pragma GCC optimize("Ofast")
#define pcnt __builtin_popcount
#define buli(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
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(a>b){a = b; return 1;} return 0; };
inline void IN(void){return;}
template <typename First, typename... Rest> void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
inline void OUT(void){cout << "\n";return;}
template <typename First, typename... Rest> void OUT(First first, Rest... rest){cout << first << " ";OUT(rest...);return;}
const double EPS = 1e-9;
const int mod = 1e9 + 7;
const int INF = 1e9;
const long long LLINF = 1e18;
long long lcm(ll a, ll b){return a * b / __gcd(a,b);}
struct IoSetup { IoSetup() {
    cin.tie(nullptr);ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
} } iosetup;
template< int mod > struct ModInt {
    int x; ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) {if((x += p.x) >= mod) x -= mod;return *this;}
    ModInt &operator-=(const ModInt &p) {if((x += mod - p.x) >= mod) x -= mod;return *this;}
    ModInt &operator*=(const ModInt &p) {x = (int) (1LL * x * p.x % mod);return *this;}
    ModInt &operator/=(const ModInt &p) {*this *= p.inverse();return *this;}
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); }return ModInt(u);}
    ModInt pow(int64_t n) const {ModInt ret(1), mul(x); while(n > 0) {if(n & 1) ret *= mul;mul *= mul;n >>= 1;}return ret;}
    friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x;}
    friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt< mod >(t); return (is); }
    static int get_mod() { return mod; }
}; using modint = ModInt< mod >;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    iosetup;
    int N; cin >> N;
    vector<int> a(N);
    rep(i, 0, N) cin >> a[i];

    sort(ALL(a));

    cout << a[N - 1] - a[0] << endl;
    return 0;
}

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

int main(){
    long double l;
    cin >> l;
    cout << fixed << setprecision(10) << (l/3)*(l/3)*(l/3) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#include<cstdint>


     
#define INF 1e9
#define LINF 1e19
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)
#define pb push_back
#define sz size()
     
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

     
const ll MOD = 1e9 + 7;
const ll ZER = 0;


int main(){
    int n;
    cin >> n;
    ll a[2][n + 1];
    a[0][n] = 0, a[1][n] = 0;
    rep(i, 2)rep(j, n)cin >> a[i][j];
    rep(i, n)a[0][i + 1] += a[0][i];
    rep(i, n)a[1][i + 1] += a[1][i];
    ll res = 0;
    rep(i, n){
        if(i != 0)chmax(res, a[0][i] + a[1][n] - a[1][i - 1]);
        else res = a[0][0] + a[1][n];
    }
    cout << res << endl;
}





Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define v vector<ll>
#define st stack<ll>
#define pq  priority_queue <int>
#define q queue<ll>
#define mod 1000000005
using namespace std;
 char ch[1000000];
int main(){
     string s;
     string s1="ABC";
     cin>>s;
     cout<<s1+s<<endl;
    return 0;
   }

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

using namespace std;

typedef long long ll;
int n,W;
vector<ll> w,v;

ll dp[100][(int)1e5+1] ; 

ll fun(int i , ll cap )
{
	if(i==n) return 0 ;
	
	if(dp[i][cap]==-1)
	{
		if(cap-w[i]<0)
			dp[i][cap] = fun(i+1,cap) ;
		else
			dp[i][cap] = max(fun(i+1,cap),v[i]+fun(i+1,cap-w[i])) ;
	}
	return dp[i][cap] ;
}

int main()
{
	int t=1;
	// cin >> t ;

	while(t--)
	{
		for(int i=0 ; i<100 ; i++) 
			for(int j=0 ; j<=1e5 ; j++) dp[i][j] = -1 ;
		cin>>n>>W ;
		w.resize(n);
		v.resize(n);
		for(int i=0 ; i<n ; i++) cin>>w[i]>>v[i] ;

		cout<<fun(0,W) << endl ;
	}
	return 0;
}

Measured memory_bytes: 78336
import java.util.*;
import java.lang.*;

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

        int[] apple = new int[N+1];
        int A = 0;
        for(int i = 1 ; i <= N ; i++){
            apple[i] = L+i-1;
            A += apple[i];
        }
        sc.close();
        int ans = Integer.MAX_VALUE;
        int ans2 = 0;
        for(int i = 1 ; i <= N ; i++){
            int B = 0;
            for(int j = 1 ; j < i ; j++){
                B += apple[j];
            }
            for(int k = i+1 ; k <= N ; k++){
                B +=apple[k];
            }
            if(ans > Math.abs(A-B)){
                ans = Math.min(ans, Math.abs(A-B));
                ans2 = B;
            }
        }
        System.out.println(ans2);
    }

}

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

int main() {
	int n; scanf("%d", &n);
	unordered_map<ll, vector<int>>mp;
	mp[0].push_back(0);
	ll s = 0;
	rep(i, n) {
		ll a; scanf("%lld", &a);
		s += a;
		mp[s].push_back(i + 1);
	}
	int Max = 0;
	for (auto&p : mp) {
		Max = max(Max, p.second.back() - p.second.front());
	}
	printf("%d\n", Max);
}

Measured memory_bytes: 20340
def f(n):
  if n % 2 == 0:
    return n // 2
  else:
    return 3 * n + 1

s = int(input())
m = s
q = set([s])
r = 1
while True:
  r += 1
  if f(m) in q:
    print(r)
    break
  else:
    q.add(f(m))
    m = f(m)

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

using namespace std;

#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned long long ull;


int main()
{
    //freopen("input.txt", "r", stdin);


    ll x;
    cin >> x;
    ll has = 100;
    int ans = 0;
    for (ll has = 100; has < x; ) {
        has = (has + has * 0.01);
        ++ans;
    }
    cout << ans << '\n';

}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;

ll fact;
ll fact_inv;

const ll MOD = 1e9 + 7;
// 繰り返し二乗法
ll power(ll a, ll b){
  ll res=1;
  while(b>0){
    if(b&1) res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}



int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  ll ans = power(2, n) - 1;
  
  //nCa
  ll nca = 1;
  ll ncb = 1;

  ll x = 1, y = 1;

  for(int i=0; i<a; i++){
    x *= (n - i);
    x %= MOD;
    y *= (i + 1);
    y %= MOD;
  }
  nca = x * power(y, MOD - 2) % MOD;

  x = 1, y = 1;
  for(int i=0; i<b; i++){
    x *= (n - i);
    x %= MOD;
    y *= (i + 1);
    y %= MOD;
  }
  ncb = x * power(y, MOD - 2) % MOD;
  //cout << ans <<"\n" << nca << "\n" << ncb << " ";
  ans -= (nca + ncb);
  while(ans<0){
    ans += MOD;
  }
  cout << ans % MOD << "\n";

  return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <list>
#include <algorithm>
#include <sstream>
#include <set>
#include <math.h>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <numeric>
 
using namespace std;
 
string s;
 
int main(){

 cin>>s;
 
for(int i=0; i<4; i++) cout<<s[i];

cout<<" ";

for(int i=4; i<12; i++) cout<<s[i];

cout<<endl;
 
return 0;
 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int comp(const void *a, const void *b){
	return (*(int*)b) - (*(int*)a);
}
int main(){
	int n, k, v[1003];
	scanf("%d%d", &n, &k);
	for(int i = 0; i < n; ++i)
		scanf("%d", &v[i]);
	qsort(v, n, sizeof(int), comp);
	long long int sum = 0;
	for(int i = 0; i < k; ++i)
		sum += v[i];
	printf("%lld\n", sum);
	return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int[][] A = new int[3][3];
            for (int r = 0; r < 3; r++) {
                for (int c = 0; c < 3; c++) {
                    A[r][c] = sc.nextInt();
                }
            }
            int N = sc.nextInt();
            int[] b = new int[N];
            for (int i = 0; i < N; i++) {
                b[i] = sc.nextInt();
            }

            boolean[][] used = new boolean[3][3];
            for (int i = 0; i < N; i++) {
                for (int r = 0; r < 3; r++) {
                    for (int c = 0; c < 3; c++) {
                        if (A[r][c] == b[i]) {
                            used[r][c] = true;
                        }
                    }
                }
            }

            boolean bingo = false;
            for (int r = 0; r < 3; r++) {
                bingo |= isBingoR(used, r);
            }
            for (int c = 0; c < 3; c++) {
                bingo |= isBingoC(used, c);
            }
            bingo |= isBingoUL(used);
            bingo |= isBingoUR(used);
            System.out.println(bingo ? "Yes" : "No");
        }
    }

    private static boolean isBingoR(boolean[][] used, int r) {
        for (int c = 0; c < 3; c++) {
            if (!used[r][c]) {
                return false;
            }
        }
        return true;
    }

    private static boolean isBingoC(boolean[][] used, int c) {
        for (int r = 0; r < 3; r++) {
            if (!used[r][c]) {
                return false;
            }
        }
        return true;
    }

    private static boolean isBingoUL(boolean[][] used) {
        return used[0][0] && used[1][1] && used[2][2];
    }

    private static boolean isBingoUR(boolean[][] used) {
        return used[0][2] && used[1][1] && used[2][0];
    }
}

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

using namespace std;

int main(void){
    
    vector<int> a(3);
    for(int i = 0;i < 3;i++) cin >> a[i];
    
    sort(a.begin(), a.end());
    
    for(int i = 0;i < 3;i++){
        if(i == 2) cout << a[i] << endl;
        else cout << a[i] << " ";
    }
    return 0;
}


Measured memory_bytes: 3148
n = int(input())
A = [int(input()) for _ in range(n)]

ans = 0
for i in range(n):
    if A[i]%2==0:
        ans+=A[i]//2
    else:
        ans+=A[i]//2
        if i+1<n and A[i+1]!=0:
            A[i+1]-=1
            ans+=1
print(ans)

Measured memory_bytes: 13008
#include <stdio.h>
#include <iostream>
#include <list>
#include <map>
#include <stdlib.h>

using namespace std;

int main(void)
{
	list<string> strList;
	map<string, list<int> > pages;
	char buf[256];
	char word[256];
	int i;
	
	while (fgets(buf, 256, stdin) != NULL){
		for (i = 0; buf[i] != ' '; i++){
			word[i] = buf[i];
		}
		word[i] = '\0';
		i++;
		strList.push_back(word);
		pages[strList.back()].push_back(atoi(&buf[i]));
	}
	
	strList.sort();
	strList.unique();
	list<string>::iterator it;
	for (it = strList.begin(); it != strList.end(); it++){
		pages[*it].sort();
		list<int>::iterator itt;
		printf("%s\n", it->c_str());
		itt = pages[*it].begin();
		printf("%d", *itt);
		itt++;
		for (; itt != pages[*it].end(); itt++){
			printf(" %d", *itt);
		}
		cout << endl;
	}
	
	return (0);
}

Measured memory_bytes: 0
X = int(input())
dp = [0]*(X+1)
dp[0] = 1

for i in range(100, X+1):
    dp[i] = dp[i-100] or dp[i-101] or dp[i-102] or dp[i-103] or dp[i-104] or dp[i-105]

print(dp[X])

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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
#define MOD (ll)(1e9+7)


ll T;
ll N;
ll dp[10101][20][4];
ll mtx[55][55],mtx2[55][55],mtx3[55][55];
ll i, j, k;


void calc(ll n){
    if(n==0)
        return;
    ll i, j, k;
    if(n&1){
        rep(i,0,21){
            rep(j,0,21){
                mtx3[i][j] = mtx[i][j];
                mtx[i][j] = 0;
            }
        }
        rep(i,0,21){
            rep(j,0,21){
                rep(k,0,21){
                    (mtx[i][j] += mtx3[i][k] * mtx2[k][j]) %= MOD;
                }
            }
        }
    }
    rep(i,0,21){
        rep(j,0,21){
            mtx3[i][j] = mtx2[i][j];
            mtx2[i][j] = 0;
        }
    }
    rep(i,0,21){
        rep(j,0,21){
            rep(k,0,21){
                (mtx2[i][j] += mtx3[i][k] * mtx3[k][j]) %= MOD;
            }
        }
    }
    /*
    printf("%lld\n", n);
    rep(i,0,21){
        rep(j,0,21){
            printf("%lld ", mtx2[i][j]);
        }
        printf("\n");
    }*/
    calc(n / 2);
}

void qqq(){

    scanf("%lld", &N);
    if(N<5){
        printf("0\n");
        return;
    }
    rep(i,0,21){
        rep(j,0,21){
            mtx[i][j] = mtx2[i][j] = 0;
            if(i<10){
                if((i^1)==j){
                    mtx2[i][j] = 1;
                }else if(i%2==0&&i<j&&(j%2==1||10<=j)){
                    mtx2[i][j] = 1;
                } 
            }else{
                if(i<=j){
                    mtx2[i][j] = 1;
                }
            }
        }
    }
    /*
    rep(i,0,21){
        rep(j,0,21){
            printf("%lld ", mtx2[i][j]);
        }
        printf("\n");
    }*/
    mtx[0][0] = 1;
    calc(N - 4);

    printf("%lld\n", mtx[0][20]);
}


int main(){
    scanf("%lld", &T);
    
    while(T--){
        qqq();
    }
    
    return 0;
}

Measured memory_bytes: 3868
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
//#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}


inline void solve(){

    int n,x;
    int l[1000];
    int r = 1,sum = 0;
    cin >> n >> x;
    FOR(i,n){
        cin >> l[i];
        sum += l[i];
        if( sum <= x)
            r++;
    }

    cout << r fin;
    
    
}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


Measured memory_bytes: 256
n, m = gets.chomp.split.map(&:to_i)
a = []
b = []

n.times do
  a << gets.chomp.split.map(&:to_i)
end

m.times do
  b << gets.chomp.to_i
end

a.each_with_index do |_, i|
  puts a[i].zip(b).map { |n| n.inject(:*) }.inject(:+)
end

Measured memory_bytes: 6132
import sys
input = sys.stdin.readline

def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def union(x, y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return

    # sizeの大きいほうがx
    if par[x] > par[y]:
        x, y = y, x
    
    par[x] += par[y]
    par[y] = x


def same(x, y):
    return find(x) == find(y)


def size(x):
    return -par[find(x)]


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

par = [-1] * n
friend = [0] * n
for _ in range(m):
    a, b = map(int, input().split())
    union(a-1, b-1)
    friend[a-1] += 1
    friend[b-1] += 1

block = [[] for _ in range(n)]
for _ in range(k):
    c, d = map(int, input().split())
    block[c-1].append(d-1)
    block[d-1].append(c-1)

for i in range(n):
    ans = size(i) - friend[i] - 1
    for j in block[i]:
        if same(i, j):
            ans -= 1
    print(ans, end=' ')

Measured memory_bytes: 102876
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;
const ll MOD = 1000000007;

struct Edge
{
    int to;
};

vector<int> topo_sort(const vector<vector<Edge>> &G)
{
    vector<int> ret;
    int n = G.size();
    vector<int> indegree(n);
    for (int i = 0; i < n; i++)
    {
        for(auto e:G[i])
            indegree[e.to]++;
    }
    queue<int> que;
    for (int i = 0; i < n; i++)
    {
        if(indegree[i] == 0)
            que.push(i);
    }
    while(!que.empty())
    {
        int v = que.front();
        que.pop();
        ret.push_back(v);
        for(auto e:G[v])
        {
            indegree[e.to]--;
            if(indegree[e.to] == 0)
                que.push(e.to);
        }
    }
    return ret;
}


int main()
{
    int n, m;
    cin >> n >> m;
    vector<vector<Edge>> G(n, vector<Edge>(0));
    rep(i,m)
    {
        int x, y;
        cin >> x >> y;
        --x; --y;
        G[x].emplace_back(Edge{y});
    }
    auto g = topo_sort(G);
    V dp(n);
    rep(i,n)
    {
        int v = g[i];
        for(auto e:G[v])
        {
            chmax(dp[e.to], dp[v] + 1);
        }
    }
    int ans = 0;
    rep(i,n) chmax(ans, dp[i]);
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int limit = 100010;
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];
 
void dfs(int v, int p, ll d) {
	depth[v] = d;
	for (auto &e : tree[v]) {
		if (e.to == p) continue;
		dfs(e.to, v, d + e.cost);
	}
}
 
int main(void) {
	int n;
	cin >> n;
 
	for (int i = 0; i < n - 1; ++i) {
		int a, b, c;
		cin >> a >> b >> c;
		a--, b--;
		tree[a].push_back({b, c});
		tree[b].push_back({a, c});
	}
 
	int q, k;
	cin >> q >> k;
	k--;
 
	dfs(k, -1, 0);
	for (int i = 0; i < q; ++i) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		cout << depth[x] + depth[y] << endl;
	}
 
	return 0;
}

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

using namespace std;

typedef long long ll;


int main()
{
  int x = 0;
  fscanf(stdin, "%d", &x);
  int ans = 1;
  for (int i = 2; i * i <= x; ++i) {
    int a = i, b = i;
    while (a * b <= x) {
      a *= b;
      ans = max(ans, a);
    }
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 256
import itertools
n = int(input())
a = [0,0,0,0,0]
for i in range(n):
	s = input()
	if s[0] == 'M':
		a[0] += 1
	elif s[0] == 'A':
		a[1] += 1
	elif s[0] == 'R':
		a[2] += 1
	elif s[0] == 'C':
		a[3] += 1
	elif s[0] == 'H':
		a[4] += 1
seq = (0,1,2,3,4)
b = list(itertools.combinations(seq,3))
ans = 0
for i in range(len(b)):
	ans += a[b[i][0]]*a[b[i][1]]*a[b[i][2]]
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

int d, t, s;

int main () {

    cin >> d >> t >> s;
    if (t >= double (d+0.0)/s) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }
    return 0;

}


Measured memory_bytes: 3652
#include<stdio.h>
#include<string.h>
#include<iostream>
using namespace std;
int prime[1000010];
bool is_prime[1000010];
int sieve(int n)
{
    int p(0);
    for(int i=0;i<=n;i++)
        is_prime[i]=1;
    is_prime[0]=is_prime[1]=0;
    for(int i=2;i<=n;i++)
    {
        if(is_prime[i])
        {
            prime[p++]=i;
            for(int j=2*i;j<=n;j+=i)
                is_prime[j]=0;
        }
    }
    return p;
}
int main()
{
    //freopen("input.txt","r",stdin);
    int n;
    while(cin>>n)
    {
        cout<<sieve(n)<<"\n";
    }




	return 0;
}



Measured memory_bytes: 4352
#include<ctime>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#define file(x)freopen(x".in","r",stdin);freopen(x".out","w",stdout)
#define rt register int
#define l putchar('\n')
#define ll long long
#define r read()
using namespace std;
inline ll read(){
    ll x=0;char zf=1;char ch=getchar();
    while(ch!='-'&&!isdigit(ch))ch=getchar();
    if(ch=='-')zf=-1,ch=getchar();
    while(isdigit(ch))x=x*10+ch-'0',ch=getchar();return x*zf;
}
void write(ll y){if(y<0)putchar('-'),y=-y;if(y>9)write(y/10);putchar(y%10+48);}
void writeln(const ll y){write(y);putchar('\n');}
int k,m,n,x,y,z,cnt,ans;
int main(){
	int a=r,b=r,c=r;
	a=__gcd(a,b);int sum=c;
	for(rt i=a;i>=1;i--)if(a%i==0){
		sum--;
		if(!sum){
			cout<<i;return 0;
		}
		
	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdint>

template <std::uint_fast64_t mod> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 v;

  constexpr modint(const u64 x = 0) noexcept : v(x % mod) {}
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    v += rhs.v;
    if (v >= mod)
      v -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (v < rhs.v)
      v += mod;
    v -= rhs.v;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    v = v * rhs.v % mod;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = mod - 2;
    while (exp != 0) {
      if (exp % 2 != 0)
        *this *= rhs;
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

#include <algorithm>
#include <iostream>
#include <vector>

int main() {
  using mint = modint<1000000007>;

  int n, x;
  std::cin >> n >> x;
  std::vector<int> s(n);
  for (auto &e : s) {
    std::cin >> e;
  }
  std::sort(s.begin(), s.end());

  std::vector<std::vector<mint>> dp(n + 1, std::vector<mint>(x + 1));

  for (int i = 0; i <= x; ++i) {
    dp[0][i] = i;
  }
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j <= x; ++j) {
      dp[i + 1][j] = dp[i][j] * i + dp[i][j % s[i]];
    }
  }

  std::cout << dp[n][x].v << std::endl;
}


Measured memory_bytes: 158592