akhauriyash/Code-Regression huggingface dataset:
// AGC 040B
// DeP
#include <cstdio>
#include <climits>
#include <algorithm>
using namespace std;

const int MAXN = 1e5 + 5;

struct Item {
  int x, y;
  Item(int _x = 0, int _y = 0): x(_x), y(_y) { }
  bool operator < (const Item& rhs) const {
    return x > rhs.x || (x == rhs.x && y > rhs.y);
  }
} seg[MAXN], s[MAXN];

int n;
int pre[MAXN], suf[MAXN];

int main() {
  scanf("%d", &n);
  for (int L, R, i = 1; i <= n; ++i)
    scanf("%d%d", &L, &R), seg[i] = Item(L, R);

  int mxL = -1, mnR = INT_MAX, mxlgt = 0;
  for (int i = 1; i <= n; ++i) {
    mxlgt = max(mxlgt, seg[i].y - seg[i].x + 1);
    mxL = max(mxL, seg[i].x), mnR = min(mnR, seg[i].y);
  }

  int ans = mxlgt + max(0, mnR - mxL + 1);
  for (int i = 1; i <= n; ++i)
    s[i] = Item(max(0, seg[i].y - mxL + 1), max(0, mnR - seg[i].x + 1));
  sort(s + 1, s + 1 + n);
  suf[n] = s[n].y;
  for (int i = n - 1; i; --i)
    suf[i] = min(suf[i + 1], s[i].y);
  for (int i = 1; i < n; ++i)
    ans = max(ans, s[i].x + suf[i + 1]);

  printf("%d\n", ans);
  return 0;
}

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

int n,m,k,i,j;

//Union find(start)
//copy
struct UnionFind {
    vector<int> size, parents;
    UnionFind() {}
    UnionFind(int n) {  // make n trees.
        size.resize(n, 0);
        parents.resize(n, 0);
        for (int i = 0; i < n; i++) {
            makeTree(i);
        }
    }
    void makeTree(int x) {
        parents[x] = x;  // the parent of x is x
        size[x] = 1;
    }
    bool isSame(int x, int y) { return findRoot(x) == findRoot(y); }
    bool unite(int x, int y) {
        x = findRoot(x);
        y = findRoot(y);
        if (x == y) return false;
        if (size[x] > size[y]) {
            parents[y] = x;
            size[x] += size[y];
        } else {
            parents[x] = y;
            size[y] += size[x];
        }
        return true;
    }
    int findRoot(int x) {
        if (x != parents[x]) {
            parents[x] = findRoot(parents[x]);
        }
        return parents[x];
    }
    int treeSize(int x) { return size[findRoot(x)]; }
};
//Union find(end)

int main(){
    cin>>n>>m>>k;
    UnionFind uf(n);
    vector<int> edgenum(n,0);//自身に隣接する辺の数
    vector<int> A(m),B(m);
    vector<int> ans(n);
    for(i=0;i<m;i++){//友達同士の木
        cin>>A[i]>>B[i];
        A[i]--;B[i]--;
        edgenum[A[i]]++;edgenum[B[i]]++;
        uf.unite(A[i],B[i]);
    }

    vector<int> C(k),D(k);
    for(i=0;i<k;i++){//ブロック関係
        cin>>C[i]>>D[i];
        C[i]--;D[i]--;
    }
    for(i=0;i<n;i++){//友達と自分は候補から外す
        ans[i]=uf.treeSize(i)-1-edgenum[i];//sizeは自分を含めたつながっている頂点数
    }
    for(i=0;i<k;i++){//同じ木の中にブロック関係があったら、友達候補から外す
        if(uf.isSame(C[i],D[i])){
            ans[C[i]]--;
            ans[D[i]]--;
        }
    }
    for(i=0;i<n;i++){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define ll long long
#define maxn 100005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second
using namespace std;
int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	if ((b - a) % 2 == 0) cout << (b - a) / 2 << endl;
	else {
		ll res1 = a + (b - a) / 2, res2 = (b - a) / 2 + (n - b + 1);
		cout << min(res1, res2) << endl;
	}
	 
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace	std;
int main(){
  int a[2000];
  int N,Y;
  cin>>N>>Y;
  int s10000=-1;
  int s5000=-1;
    int s1000=-1;


  for(int m=0;m<=N;m++)
    for(int n=0;n+m<=N;n++){
      int s=N-(m+n);


  if(m*10000+5000*n+s*1000==Y)
    {
      s10000=m;
      s5000=n;
      s1000=s;



    }
    }
  cout<<s10000<<" "<<s5000<<" "<<s1000;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A =sc.nextInt();
		int B = sc.nextInt();
		int C =sc.nextInt();
		if(A+B>=C){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		
		sc.close();
	}
}


Measured memory_bytes: 22356
/*input
3 8
3 30
4 50
5 60
*/
#include<bits/stdc++.h>
using namespace std;

#define int long long 
#define double long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define RE(i,n) for (int i = 1; i <= n; i++)
#define RED(i,n) for (int i = n; i > 0; i--)
#define REPS(i,n) for(int i = 1; (i*i) <= n; i++)
#define REP(i,n) for (int i = 0; i < n; i++)
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REPD(i,n) for (int i = n-1; i >= 0; i--)
#define FORD(i,a,b) for (int i = a; i >= b; i--)
#define remax(a,b) a = max(a,b)
#define remin(a,b) a = min(a,b)
#define all(v) v.begin(),v.end()
#define pii pair<int,int>
#define mii map<int,int>
#define vi vector<int>
#define vvi vector<vi>
#define WL(t) while(t --)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << " "; cout << endl;
#define debug(x) cout << x << endl;
#define debug2(x,y) cout << x << " " << y << endl;
#define debug3(x,y,z) cout << x << " " << y << " " << z << endl;
const int INF = 1e18+1;
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int fast_ex(int a,int n,int m){
  if(n == 0)return 1;
  if(n == 1)return a;
  int x = 1;
    x *= fast_ex(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}

const int N = 101;
int dp[N][100001];
int n;
int v[N],w[N];
int W;

void solve(){
     REP(i,101){
     	RE(j,100001){dp[i][j] = INF;}}
     cin >> n >> W;
     RE(i,n)cin >> w[i] >> v[i];
     dp[0][0] = 0;
     //cout << dp[n][100000];
     RE(i,n){
     	REP(j,100001){
           if(dp[i-1][j] < INF)dp[i][j] = dp[i-1][j];
           //if(j == v[i])dp[i][j] = min(dp[i][j],w[i]);
           if(j >= v[i] && (dp[i-1][j-v[i]] < INF) )dp[i][j] = min(dp[i][j],dp[i-1][j-v[i]]+w[i]);
        }
     }
     int ans;
     REP(i,100001){
     	if(dp[n][i] <= W)ans = i;
     }
     //cout << dp[n][ans];
     cout << ans;
}

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

Measured memory_bytes: 79232
#include<stdio.h>
#include<string.h>
int main(){
    int n, t, h;
    char a[101],b[101];
    scanf("%d",&n);
    t=0;
    h=0;
    for (int i=0;i<n;i++){
        scanf("%s %s",a,b);
        if(strcmp(a,b)>0){
            t=t+3;
        }else if(strcmp(a,b)<0){
            h=h+3;
        }else{
            t=t+1;
            h=h+1;
        }
    }
    printf("%d %d\n",t,h);
}


Measured memory_bytes: 2036
a = [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=int(input())
print(a[k-1])


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <set>

using namespace std;

int main(){
    int s;
    set<int> a;
    cin >> s;

    a.insert(s);
    int count = 1;
    
    while(true){
        if(s % 2 == 1) s = 3*s+1;
        else s /= 2;

        auto result = a.insert(s);
        count++;

        if(result.second == false) break;
    }

    cout << count << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

int main() {
    ll N; cin >> N;
    ll A, B; cin >> A >> B;
    cout << (N/(A+B) * A + min(A, N%(A+B))) << endl;

}


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

using namespace std;

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

#define ll long long

int main()
{
	ll n, p;
	map<ll, ll> mp;
	cin >> n >> p;
	if (n == 1) {
		cout << p << endl;
		return 0;
	}
	int ans = 1;
	for (int i = 1; pow(i, n) <= p; i++) {
		if (p % (ll)pow(i, n) == 0)
			ans = i;
	}
	cout << ans << endl;
}



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

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef pair<ll,ll> pll;

const int INF=1<<30;
const ll LINF = 1e18+5;

bool pairCompare(const pll& Fir, const pll& Sec)
{
    return Fir.first < Sec.first; // 1番目について昇順
}

int main() {
    ll N, X, D;
    cin >> N >> X >> D;
    if(D == 0) {
        if(X == 0) {
            cout << 1 << endl;
            return 0;
        } else {
            cout << N+1 << endl;
            return 0;
        }
    }
    if (D < 0) {
        D *= -1;
        X *= -1;
    }
    map<ll, vector<pll>> cat;
    rep(b, N+1) {
        ll l = 1LL * b * (b-1) / 2 + 1LL * b * X / D;
        ll r = 1LL * b * (2 * N - b - 1) / 2 + 1LL * b * X / D;
        cat[((1LL*b*X)%D+D)%D].push_back(make_pair(l, r+1));
    }
    ll ans = 0;
    for(auto& ca : cat){
        vector<pll> timetable;
        for(auto& c : ca.second) {
            timetable.push_back(make_pair(c.first, 1));
            timetable.push_back(make_pair(c.second, -1));
        }
        // sortできる
        sort(timetable.begin(), timetable.end(), pairCompare);
        ll res = 0;
        ll before = 0; // なんでもいい
        for(auto& t : timetable) {
            if(res > 0) ans += t.first - before;
            before = t.first;
            res += t.second;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 22144
#include <stdio.h>

int N;
int h[101];

int main(int argc, char const *argv[]) {

	scanf("%d", &N);
	for (size_t i = 1; i <= N; i++) {
		scanf("%d", &h[i]);
	}

	int l, r;
	int i, j;

	for (i = 0; ; i++) {
		for (l = 0;  l <= N && h[l] == 0; l++) ;
		if (l > N) break;

		for (r = l; h[r] != 0; r++) ;
		r--;

		for (j = l; j <= r; j++) {
			h[j]--;
		}
	}

	printf("%d\n", i);

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k , n , m;
	cin >> k >> n >> m;
	for(int i = 0;; i ++)
	{
		if(i * k >= n && k * i <= m)
		{
			cout << "OK" << endl;
			return 0;
		}
		if(k * i > m)
		break;
	}
	cout << "NG" << endl;
	return 0;
 } 

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

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

		for (; sc.hasNext();) {

			int n = sc.nextInt();
			int x = sc.nextInt();

			//	          int n = Integer.parseInt(args[in]);
			//	          int x = Integer.parseInt(args[in+1]);

			if (n == 0 && x == 0) {
				break;
			}
			int count = 0;

			for (int i = 1; i <= n; i++) {
				for (int j = i + 1; j <= n; j++) {
					for (int k = j + 1; k <= n; k++) {
						if (i + j + k == x) { //異なる3種類の数字が入力値を満たしたらカウント
							count++;
						}
					}
				}
			}
			System.out.println(count);
		}

	}

}



Measured memory_bytes: 26668
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		List<Integer> l = new ArrayList<Integer>();
		int n = sc.nextInt();
		int k = sc.nextInt();
		while (sc.hasNext()) {
			int a = sc.nextInt();
			l.add(a);
		}
		Collections.sort(l);
		int min = 1000000000;
		for (int i=0 ; i < l.size() - k + 1; i++ ) {
			int sabun = l.get(i+k-1) - l.get(i);
			if (sabun < min) min = sabun;
		}
		// 出力
		System.out.println(min);
	}
}


Measured memory_bytes: 64580
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix
N, M = map(int, input().split())
a, b, c = [], [], []
for i in range(M):
    ai, bi, ci = map(int, input().split())
    a.append(ai-1)
    b.append(bi-1)
    c.append(ci)

G = csr_matrix((c, (a, b)), shape=(N, N), dtype=int)
D, P = floyd_warshall(G, directed=False, return_predecessors=True)
edges = []
for i in range(N):
    for j in range(N):
        if P[j][i] < 0 or i == P[j][i]:
            continue
        edges.append((min(i, P[j][i]), max(i, P[j][i])))
edges = list(set(edges))
print(M - len(edges))


Measured memory_bytes: 14928
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	set<string> st;
	for(ll i=0;i<n;i++){
		string s;
		cin>>s;
		st.insert(s);
	}
	cout<<st.size();
	
	return 0;
}

Measured memory_bytes: 19148
#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
long long int modpow(long long N, long long P, long long M) {//Nのp乗modM;
    long long count_prs = 0;
    ++count_prs;
    if (P == 0) return 1;
    if (P % 2 == 0) {
        long long t = modpow(N, P / 2, M);
        return t * t % M;
    }
    return N * modpow(N, P - 1, M);
}
int main() {
    string S;
    cin >> S;
    long long ans=0;
    vector<int>A(S.size() + 1);
    for (size_t i = 0; i < S.size(); i++)
    {
        if (S.at(i) == '<') { 
            A.at(i + 1)=A.at(i)+1;
        }
        else if(i==S.size()-1||S.at(i+1)=='<'){
            A.at(i + 1) = 0;
            for (int j = i+1; j >= 1; j--)
            {
                if (j-1<S.size()&&S.at(j - 1) == '<')break;
                A.at(j-1) = max(A.at(j) + 1,A.at(j-1));
            }
        }
    }
    for (size_t i = 0; i < A.size(); i++)
    {
        //cout << A.at(i)<<endl;
    }
    for (size_t i = 0; i < S.size()+1; i++)
    {
        ans += A.at(i);
    }
    cout << ans;
}


Measured memory_bytes: 2820
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int main() {
	
	string s, t;
	cin >> s >> t;
	if (s.length() + 1 != t.length()) {
		PRIN;
		return 0;
	}
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] != t[i]) {
			PRIN;
			return 0;
		}
	}
	PRIY;
	
	return 0;
}

Measured memory_bytes: 3572
a=[input() for i in range(6)]
for i in range(6):
    a[i]=int(a[i])
if a[0]>=a[1] and a[0]>=a[2] and a[0]>=a[3]:
    x=a[0]
    a.pop(0)
elif a[1]>=a[2] and a[1]>=a[3] and a[1]>=a[0]:
    x=a[1]
    a.pop(1)
elif a[2]>=a[3] and a[2]>=a[0] and a[2]>=a[1]:
    x=a[2]
    a.pop(2)
else:
    x=a[3]
    a.pop(3)

if a[0]>=a[1] and a[0]>=a[2]:
    y=a[0]
    a.pop(0)
elif a[1]>=a[2] and a[1]>=a[0]:
    y=a[1]
    a.pop(1)
else:
    y=a[2]
    a.pop(2)

if a[0]>=a[1]:
    z=a[0]
    a.pop(0)
else:
    z=a[1]
    a.pop(1)

if a[1]>=a[2]:
    w=a[1]
else:
    w=a[2]
print(x+y+z+w)


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */


int main(){
    string s; cin >> s; int n = s.size(); string ans = "";
    rep(i, n) ans += "x";
    out(ans);
}

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

using namespace std;
const int MOD(1000000000 + 7);
const int Max_N(25);
const int Max_M(405);

constexpr int Add(int a, int b)
{
	return a + b >= MOD ? a + b - MOD : a + b;
}

constexpr int Sub(int a, int b)
{
	return a - b < 0 ? a - b + MOD : a - b;
}

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

void exgcd(int a, 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(int a)
{
	int invx, invy;
	exgcd(a, MOD, invx, invy);
	return (invx % MOD + MOD) % MOD;
}

inline void upd(int &a, int b)
{
	a = Add(a, b);
}

int N, M, Head[Max_N], Total, To[Max_N << 1], Next[Max_N << 1], Weight[Max_N << 1], Can[1 << 19];

inline void Add_Edge(int s, int t, int w)
{
	++Total, To[Total] = t, Next[Total] = Head[s], Head[s] = Total, Weight[Total] = w;
}

bool done[Max_N];
void dfs(int u, int T, stack<int> S)
{
	if (u == T)
	{
		int All(0);
		while (S.empty() == false)
			All |= (1 << S.top()), S.pop();
		++Can[All];
		return;
	}
	done[u] = true;
	for (int i = Head[u], v;i;i = Next[i])
		if (!done[v = To[i]])
			S.push(Weight[i]), dfs(v, T, S), S.pop();
	done[u] = false;
}

void FMT(int F[1 << 19])
{
	for (int i = 0;i <= N - 2;++i)
		for (int S = 0;S < (1 << (N - 1));++S)
			if ((S & (1 << i)) == 0)
				upd(F[S + (1 << i)], F[S]);
}

int F0[1 << 19], F1[1 << 19], Fac[Max_M], Inv[Max_M];

int main()
{
	scanf("%d%d", &N, &M);
	Fac[0] = 1;
	for (int i = 1;i <= M;++i)
		Fac[i] = Mult(Fac[i - 1], i);
	Inv[M] = inverse(Fac[M]);
	for (int i = M - 1;i >= 0;--i)
		Inv[i] = Mult(Inv[i + 1], i + 1);
	for (int i = 0, a, b;i <= M - 1;++i)
	{
		scanf("%d%d", &a, &b);
		if (i <= N - 2)
			Add_Edge(a, b, i), Add_Edge(b, a, i);
		else
			dfs(a, b, stack<int>());
	}
	FMT(Can);
	F0[0] = 1, F1[0] = 0;
	for (int S = 0, have, _S;S < (1 << (N - 1));++S)
	{
		have = M - (N - 1) - Can[(1 << (N - 1)) - 1 - S], _S = 0;
		for (int i = 0;i <= N - 2;++i)
			have += ((S & (1 << i)) != 0), _S += ((S & (1 << i)) != 0);
		for (int i = 0, cnt, xs;i <= N - 2;++i)
			if ((S & (1 << i)) == 0)
			{
				cnt = Can[(1 << (N - 1)) - 1 - S] - Can[(1 << (N - 1)) - 1 - (S + (1 << i))];
				xs = Mult(Fac[have + cnt], Inv[have]);
				upd(F0[S + (1 << i)], Mult(F0[S], xs));
				upd(F1[S + (1 << i)], Mult(_S + 1, Mult(F0[S], xs)));
				upd(F1[S + (1 << i)], Mult(F1[S], xs));
				if (cnt)
					upd(F1[S + (1 << i)], Mult(cnt, Mult(F1[S], Mult(Fac[have + cnt], Inv[have + 1]))));
			}
	}
	printf("%d", F1[(1 << (N - 1)) - 1]);
	return 0;
}

Measured memory_bytes: 6400
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
typedef long long ll;
using namespace std;
int main()
{
  string a;
  cin >> a;
  int ans = 0;
  if(a == "SUN"){ans = 7;}
  else if(a == "MON"){ans = 6;}
  else if(a == "TUE"){ans = 5;}
  else if(a == "WED"){ans = 4;}
  else if(a == "THU"){ans = 3;}
  else if(a == "FRI"){ans = 2;}
  else if(a == "SAT"){ans = 1;}

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int main(void) {
	int num, i, j, k, r, c, a, b, v;
	ll ans = 0;
	cin >> r >> c >> num;
	vector<vector<vector<ll>>> dp(r + 1, vector<vector<ll>>(c + 1, vector<ll>(4, 0)));
	vector<vector<ll>> d(r + 1, vector<ll>(c + 1, 0));
	rep(i, num) {
		cin >> a >> b;
		cin >> d[a][b];
	}
	for (i = 1; i <= r; i++) {
		for (j = 1; j <= c; j++) {
			rep(k, 4)
				dp[i][j][k] = max(dp[i][j - 1][k], dp[i - 1][j][3]);
			for (k = 3; k > 0; k--)
				chmax(dp[i][j][k], dp[i][j][k - 1] + d[i][j]);
		}
	}
	cout << dp[r][c][3] << "\n";
	return 0;
}

Measured memory_bytes: 706972
N=int(input())
L=list(map(int, input().split()))
count=0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            L2=[L[i],L[j],L[k]]
            L2.sort()
            if L2[0]+L2[1]>L2[2] and L2[0] != L2[1] and L2[1] != L2[2] and L2[2] != L2[0]:
                count+=1
                
print(count)


Measured memory_bytes: 9112
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

enum P = 1000000007L;

long pow(long x, long n) {
    long y = 1;
    while (n) {
        if (n%2 == 1) y = (y * x) % P;
        x = x^^2 % P;
        n /= 2;
    }
    return y;
}

alias Iw = Tuple!(long, "a", long, "b");
alias Pair = Tuple!(long, "x", long, "y");

void main()
{
    auto N = readln.chomp.to!int;
    long[Iw] iws;
    long zz;
    foreach (_; 0..N) {
        auto ab = readln.split.to!(long[]);
        auto A = ab[0];
        auto B = ab[1];
        if (A < 0) {
            A = -A;
            B = -B;
        }
        if (A == 0 && B == 0) {
            ++zz;
            continue;
        } else if (A == 0) {
            B = 1;
        } else if (B == 0) {
            A = 1;
        } else if (A != 0 && B != 0) {
            auto d = gcd(abs(A), abs(B));
            A /= d;
            B /= d;
        }
        auto iw = Iw(A, B);
        if (iw !in iws) iws[iw] = 0;
        ++iws[iw];
    }

    Pair[] ps;
    foreach (k, n; iws) {
        if (n == 0) continue;
        auto r = k.b < 0 ? Iw(-k.b, k.a) : Iw(k.b, -k.a);
        if (r.a == 0) r.b = abs(r.b);
        if (r in iws && iws[r] > 0) {
            ps ~= Pair(n, iws[r]);
            iws[r] = 0;
        } else {
            ps ~= Pair(n, 0);
        }
    }

    long r = 1;
    foreach (p; ps) {
        if (p.y == 0) {
            (r *= pow(2, p.x)) %= P;
        } else {
            long z = (pow(2, p.x) + pow(2, p.y)) % P;
            z = (z - 1 + P) % P;
            (r *= z) %= P;
        }
    }
    writeln((r - 1 + zz + P) % P);
}

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

int x[100010],y[100010],num[410],n,m;
bool bo[410][410],bb[410];

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

int main()
{
	n=rd();m=rd();
	for (int i=1;i<=n;i++) bb[i]=bo[i][i]=true;
	for (int i=1;i<=m;i++) x[i]=rd(),y[i]=rd();
	for (int i=m;i;i--)
	{
		for (int j=1;j<=n;j++)
		{
			if (!bb[j]) continue;
			if (bo[j][x[i]]&&bo[j][y[i]]) { bb[j]=false;continue; }
			if (bo[j][x[i]]) bo[j][y[i]]=true;
			else if (bo[j][y[i]]) bo[j][x[i]]=true;
		}
	}
	int ans=0;
	for (int i=1;i<n;i++)
	{
		if (!bb[i]) continue;
		for (int j=i+1;j<=n;j++)
		{
			if (!bb[j]) continue;
			for (int k=1;k<=n;k++) num[k]=0;
			for (int k=1;k<=n;k++) num[k]+=bo[i][k]+bo[j][k];
			bool flag=true;
			for (int k=1;k<=n;k++) if (num[k]>1) flag=false;
			if (flag) ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    if(a<b){
        cout << "a < b" << endl;
    }else if(a>b){
        cout << "a > b" << endl;
    }else{
        cout << "a == b" << endl;
    }
}


Measured memory_bytes: 3092
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

h = ii()
count = 0
ans = 1
while h >= 2:
    h = h//2
    ans += 2*count
    count += 1
#print(ans,count)
if count == 0:
    print(1)
else:
    print(2**(count+1)-1)


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){

  for(;;){
    int n;
    cin>>n;
    if(!n) break;
    int a[26]={},r=0;
    string s,s0[2000];
    for(int i=0;i<n;i++) cin>>s0[i];
    for(int i=0;i<n;i++){
      s=s0[i];
      a[s[0]-'A']++;
      pair<int,int> b[26];
      for(int j=0;j<26;j++) b[j]=make_pair(a[j],j);
      sort(b,b+26,greater<pair<int,int> >());
      if(b[0].first>b[1].first+n-(i+1)||b[0].first>n/2){
        char tmp=b[0].second+'A';
        cout<<tmp<<" "<<i+1<<endl;
        r=1;
      }
      if(r) break;
    }
    if(!r) cout<<"TIE"<<endl;
  }


  return 0;

}

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

int main()
{
	string str;
	string answer = "";
	cin >> str;

	for (int i = 0; i < str.length(); i++)
	{
		if (str[i] == '1' || str[i] == '0') 
		{
			answer.push_back(str[i]);
		}
		else if (str[i] == 'B' && !answer.empty())
		{
			answer.pop_back();
		}
	}

	cout << answer <<endl;
	return 0;
}

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

using namespace std;
#define PI              3.1415926536

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod 1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define REP(i,n) for(i=0;i<n;i++)
#define RREP(i,n) for(i=n-1;i>=0;i--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void c_p_c()
{
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
bool isLucky(int n)
{
	if (n == 7 || n == 4)
		return true;
	else
		return false;
}
bool f(int x, int y)
{
	return x > y;
}
int32_t main()
{



	int  x;
	cin >> x;
	if (x >= 30)
		cout << "Yes";
	else
		cout << "No";


}




















Measured memory_bytes: 3624
import java.util.*;
import java.io.*;

public class Main {

    private final static int MOD = 998244353; // (int)1e9 + 7;
    private static final int INF = (int)1e9;

    public Main(FastScanner in, PrintWriter out) {
        int a = in.nextInt();
        int b = in.nextInt();
        int a0 = (a * 25 + 1) / 2;
        int a1 = (a * 25 + 26) / 2 - 1;
        int b0 = b * 10;
        int b1 = b * 10 + 9;
        if (b1 < a0 || a1 < b0)
            out.println(-1);
        else if (a0 >= b0)
            out.println(a0);
        else if (b0 > a0)
            out.println(b0);
    }

    private int gcd(int a, int b) {
        while (true) {
            if (b == 0) return a;
            int tmp = a;
            a = b;
            b = tmp % b;
        }
    }

    private long powm(long x, long p) {
        long res = 1;
        while (p > 0) {
            if (p % 2 == 1)
                res = res * x % MOD;
            x = x * x % MOD;
            p /= 2;
        }
        return res;
    }


    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        // Scanner in = new Scanner(
                // new BufferedReader(new InputStreamReader(System.in)));
        FastScanner in = new FastScanner(System.in);

        Main sol = new Main(in, out);

        out.close();
    }
}


class FastScanner{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public FastScanner(InputStream stream)
    {
        this.stream = stream;
    }

    int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars){
            curChar = 0;
            try{
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    boolean isSpaceChar(int c)
    {
        return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
    }

    boolean isEndline(int c)
    {
        return c=='\n'||c=='\r'||c==-1;
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String next(){
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isSpaceChar(c));
        return res.toString();
    }

    String nextLine(){
        int c = read();
        while (isEndline(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isEndline(c));
        return res.toString();
    }
}


Measured memory_bytes: 32232
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(a, b) for(a = 0; a < b; a++)
#define repp(a, b, c) for(a = b; a < c; a++)


int SaiYaku(int a, int b){
  
  int r;
  while((r = a % b) != 0 ){
    r = a % b;
    a = b;
    b = r;
  }
  return b;
}

int main(){
  
  //cout << SaiYaku(SaiYaku(12, 6), 8) << endl;
  int i, j, k, K, a, c;
  cin >> K;
  int Sum = 0;
  
  /*rep(i, K){
    repp(j, i, K){
      repp(k, j, K){
        
        if(i != j && j != k && k != i){
          a = 6;
        }else{
          a = 3;
        }
        Sum += a * SaiYaku(SaiYaku(i + 1, j + 1), k + 1);
      }
    }
  }*/
  rep(i, K){
    rep(j, K){
      rep(k, K){
        
        Sum += SaiYaku(SaiYaku(i + 1, j + 1), k + 1);
      }
    }
  }
  cout << Sum << endl;
}



Measured memory_bytes: 3636
// https://codeforces.com/contest/1213/problem/G

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define mod 1000000007
#define gcd __gcd
#define inf INT_MAX
#define minf INT_MIN
#define pb push_back
#define all(v) v.begin(),v.end()
#define print(v) for(auto x:v) cout<<x<<" "; cout<<"\n";
#define printn(v) for(auto x:v) cout<<x<<"\n";
#define F first
#define S second
#define mp make_pair

string s, t;
int dp[3000][3000];

int len_lcs(int i, int j, int n, int m) {
	if (i >= n || j >= m) return 0;
	if (dp[i][j] != -1) return dp[i][j];

	if (s[i] == t[j]) return dp[i][j] = 1 + len_lcs(i + 1, j + 1, n, m);
	else return dp[i][j] = max(len_lcs(i + 1, j, n, m), len_lcs(i, j + 1, n, m));
}

string get_lcs(int len) {
	int i = 0, j = 0;
	string lcs;
	while (len > 0) {
		if (s[i] == t[j]) {
			lcs.pb(s[i]);
			i++;
			j++;
			len--;
		}
		else if (dp[i + 1][j] > dp[i][j + 1]) i++;
		else j++;
	}
	return lcs;
}

int32_t main() {
	fastio;
	cin >> s >> t;
	int n = s.length();
	int m = t.length();
	memset(dp, -1, sizeof dp);
	int len = len_lcs(0, 0, n, m);
	cout << get_lcs(len) << endl;
}

Measured memory_bytes: 39252
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 + 10;
const int INF = 1e9;
int h, w, ans;
char s[maxn][maxn];
int a[maxn][maxn], v[maxn], l[maxn], r[maxn];
stack<int> S;
int main()
{
	scanf("%d%d", &h, &w);
	ans = w;
	v[0] = v[h] = -INF;
	for(int i = 1; i <= h; ++i) scanf("%s", s[i] + 1);
	for(int j = 1; j <= w; ++j)
	{
		for(int i = 1; i < h; ++i)
		{
			a[i][j] = (s[i][j] == s[i + 1][j] ? 0 : 1);
			v[i] = ((j > 1 && a[i][j] == a[i][j - 1]) ? v[i] + 1 : 1);
		}
		stack<int>().swap(S);
		S.push(0);
		for(int i = 1; i < h; ++i) 
		{
			while(v[S.top()] >= v[i]) S.pop();
			l[i] = S.top();
			S.push(i);
		}
		stack<int>().swap(S);
		S.push(h);
		for(int i = h - 1; i; --i)
		{
			while(v[S.top()] >= v[i]) S.pop();
			r[i] = S.top(); 
			S.push(i);
		}
		for(int i = 1; i <= h - 1; ++i) ans = max(ans, v[i] * (r[i] - l[i]));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 23404
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using ll = long long;
using P = pair<ll,ll>;

int main(){
ios::sync_with_stdio(false);
std::cin.tie(nullptr);
ll n;
cin >> n;
vector<ll> a(n);
vector<int> isprime(1000001,1);
vector<ll> mp(1000001);
for(ll i = 0; i < n; i++){
    cin >> a[i];
    mp[a[i]]++;
}
for(ll i = 2; i <= 1000000; i++){
    if(!isprime[i])continue;
    for(ll j = 2 * i; j <= 1000000; j += i){
        isprime[j] = 0;
    }
    for(ll j = 1; i * j <= 1000000; j++){
        mp[i * j] += mp[j];
    }
}
ll ans = 0;
for(ll i = 0; i < n; i++){
    if(mp[a[i]] == 1)
        ans++;
}
cout << ans << endl;
}

Measured memory_bytes: 16312
#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()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n) {
        cin >> c[i];
        rep(j, m) {
            cin >> a[i][j];
        }
    }

    int ans = numeric_limits<int>::max();
    for (int i = 0; i < (1<<n); i++) {
        int t = 0;
        int b = i;
        int j = 0;
        vector<int> aa(m, 0);
        while (b >> j) {
            if (b & (1 << j)) {
                t += c[j];
                bool f = true;
                for (int k = 0; k < m; k++) {
                    aa[k] += a[j][k];
                    if (aa[k] < x) f = false;
                }
                if (f) {
                    ans = min(ans, t);
                    break;
                }
            }
            j++;
        }
    }
    if (ans == numeric_limits<int>::max()) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<array>
#include<cstdlib>
#include<ctime>
#include<climits>
using namespace std;

int main(){
	int n;
	cin >> n;
	int l[101] = {0};//
	int max = 0;
	for(int i = 0; i < n; i++){
		cin >> l[i];
		if(max < l[i]) max = l[i];
	}


	int cnt = 0;
	while(max > 0){
		for(int i = 0; i < n; i++){
			if(l[i] >= max && !(l[i + 1] >= max)){
				cnt++;
			}
		}
		max--;
	}


	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define ll long long

using namespace std;

int main() {
  ll n;
  cin >> n;
  ll ans;
  ans = (n-1)*n/2;
  cout << ans;
  }



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define sz(v) (int)v.size()
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
const char EOL = '\n';
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

class Combination {
    vector<ll> factorial;
    vector<ll> fact_inverse;
    vector<ll> inverse;
    int mod;

    void init(int size) {
        factorial[0] = 1;
        factorial[1] = 1;
        fact_inverse[0] = 1;
        fact_inverse[1] = 1;
        inverse[1] = 1;

        for (int i = 2; i < size; i++) {
            factorial[i] = factorial[i - 1] * i % mod;
            inverse[i] = mod - inverse[mod % i] * (mod / i) % mod;
            fact_inverse[i] = fact_inverse[i - 1] * inverse[i] % mod;
        }
    }

    public:
        Combination(int size, int m) {
           factorial = vector<ll>(size);
           fact_inverse = vector<ll>(size);
           inverse = vector<ll>(size);
           mod = m;
           init(size);
        }
    
        ll calc(int n, int k) {
            if (n < k) {
                return 0;
            }
            if (n < 0 || k < 0) {
                return 0;
            }
            return factorial[n] * (fact_inverse[k] * fact_inverse[n - k] % mod) % mod;
        }

        ll with_repetition(int n, int k) {
            return calc(n + k - 1, k);
        }
};

void solve() {
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n) cin >> a[i];
    sort(ALL(a));

    Combination c(n * 2, MOD);

    ll ans = 0;
    REP(i, n - k + 1) {
        // cout << n - 1 - i << " C " << k - 1 << EOL;
        ans -= (a[i] * c.calc(n - 1 - i, k - 1)) % MOD;
        ans %= MOD;
    }
    REP(i, n - k + 1) {
        // cout << i + k - 1 << " C " << k - 1 << EOL;
        ans += (a[i + k - 1] * c.calc(i + k - 1, k - 1)) % MOD;
        ans %= MOD;
    }

    cout << ans << EOL;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int dist[100500][3];
int N, M;
vector<int> pathes[100500];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 1; i <= M; i++) {
        int u, v;
        cin >> u >> v;
        pathes[u].push_back(v);
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 0; j <= 2; j++) dist[i][j] = INF;
    }
    int S, T;
    cin >> S >> T;
    queue<i_i> que;
    que.push({S, 0});
    dist[S][0] = 0;
    while(!que.empty()) {
        i_i now = que.front();
        que.pop();
        for(int i = 0; i < pathes[now.first].size(); i++) {
            int to = pathes[now.first][i];
            int index = (now.second + 1) % 3;
            int newcost = dist[now.first][now.second] + 1;
            if(dist[to][index] <= newcost) continue;
            dist[to][index] = newcost;
            que.push({to, index});
        }
    }
    cerr << dist[T][0] << endl;
    if(dist[T][0] == INF) dist[T][0] = -3;
    cout << dist[T][0] / 3 << endl;
    return 0;
}


Measured memory_bytes: 6912
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    if (n == m) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

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

int main() {
    int N; cin >> N;
    string S; cin >> S;
    int ans = 0;
    rep(i, 1, N) {
        int cnt = 0;
        rep(j, 0, N - i) {
            if(S[j] == S[j + i]) cnt++;
            else cnt = 0;
            ans = max(ans, min(cnt, i));
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

const int N = 200100;

vector <int> adj[N];
int dist[N];


void dfs(int a, int l) {
	for (int i = 0; i < adj[a].size(); ++i) {
		int nx = adj[a][i];
		if(dist[nx] == 0x3f3f3f3f) {
			dist[nx] = dist[a] + 1;
			dfs(nx, a);
		}
	}
}

int main() {
	int n;
	scanf("%d", &n);

	for (int i = 0; i < n-1; ++i) {
		int a, b;
		scanf("%d%d", &a, &b);
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	memset(dist, 0x3f3f3f3f, sizeof dist);
	dist[1] = 0;
	dfs(1, -1);
	int id, mx = 0;
	for (int i = 1; i <= n; ++i) {
		if(dist[i] > mx) {
			mx = dist[i];
			id = i;
		}
	}

	memset(dist, 0x3f3f3f3f, sizeof dist);
	dist[id] = 0;
	dfs(id, -1);

	mx = 0;
	for (int i = 1; i <= n; ++i) {
		if(dist[i] > mx) {
			mx = dist[i];
			id = i;
		}
	}

	if((dist[id]+2)%3==0) {
		puts("Second");
	} else {
		puts("First");
	}


}

Measured memory_bytes: 21376
#include "bits/stdc++.h"
using namespace std;

int a,b,h,m;

int main()
{
	cout<<fixed<<setprecision(12);
	cin>>a>>b>>h>>m;

	double ha=h*30+m/2.,ma=6*m,ang=abs(ha-ma);
	ang=min(ang,360-ang);
	cout<<sqrtl(a*a+b*b-2*a*b*cos(ang*M_PI/180));
}

Measured memory_bytes: 4232
#!/usr/bin/env python3
# %%
stdin = open(0)
import numpy as np

# %%
data = np.fromstring(stdin.read(), np.int64, sep=' ')

# %%
X = data[1:]
costs = []
for p in range(101):
    costs.append(np.sum((X-p)**2))

# %%
answer = min(costs)
print(answer)

# %%


Measured memory_bytes: 12452
-- same-integers.hs --- Same Integers

-- author: Seong Yong-ju <sei40kr@gmail.com>

solve :: Int -> Int -> Int -> Int
solve a b c =
  if mod m 2 == mod s 2
    then quot (3 * m - s) 2
    else quot (3 * (m + 1) - s) 2
  where
    s = a + b + c
    m = max a $ max b c
main :: IO ()
main = do
  [a, b, c] <- map (read :: String -> Int) . words <$> getLine
  print $ solve a b c


Measured memory_bytes: 508
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#define rep( i, a, n ) for( int i = a; i < n; i++ )
#define per( i, a, n ) for( int i = n - 1; i >= a; i-- )
#define mem( f, x ) memset( f, x, sizeof( f ) )
#define ll long long
#define pii pair<int, int>
#define fi first
#define se second
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define e 2.71828
using namespace std;
const int N = 105;
const int M = 1e6+5;
const int MAX = 5;
const ll inv = 500000004;
const double g = 9.80;
const double PI = acos( -1.0 );

ll gcd( ll x, ll y ){
    return y == 0 ? x : gcd( y, x%y );
}

int main(){
    ll n, m;
    while( scanf( "%lld %lld", &n, &m ) != EOF ){
        ll x;
        scanf( "%lld", &x );
        if( n == 1 ){
            printf( "%lld\n", abs( x - m ) );
            continue;
        }
        ll tmp = abs( x - m );
        ll ans = tmp;
        for( ll i = 1; i < n; i++ ){
            scanf( "%lld", &x );
            ans = min( ans, gcd( tmp, abs( x - m ) ) );
        }
        printf( "%lld\n", ans );
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
int gcd(int x,int y)
	{
	return y==0?x:gcd(y,x%y);
	}
int main()
{
int n,x;
int ans;
cin >>n>>x;
cin >>ans;
ans-=x;
for(int i=2;i<=n;i++)
	{
	int tmp;
	scanf("%d",&tmp);
	ans=gcd(ans,tmp-x);
	}
cout <<abs(ans);
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <limits>
#include <algorithm>
#include <cassert>
#include <vector>
#include <utility>
#include <string>
#include <iostream>

int main()
{
	using namespace std;
    int N,A;
	cin >> N >> A;
    if ((N%500)<=A) cout << "Yes" << endl;
    else cout << "No" << endl;
	return 0;
}


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

int main() {
	int n, q;
    cin >> n >> q;
    dsu uf(n);
    while(q--) {
        int t, u, v;
        cin >> t >> u >> v;
        if(t) {
            cout << int(uf.same(u, v)) << endl;
        } else {
            uf.merge(u, v);
        }
    }
}


Measured memory_bytes: 4016
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        String longestWord = "";
        HashMap<String, Integer> map = new HashMap<String, Integer>();

        String[] input = br.readLine().split(" ");
        for (String word : input) {
            if (map.containsKey(word)) {
                map.put(word, map.get(word) + 1);
            } else {
                map.put(word, 1);
            }

            if(longestWord.length() < word.length()){
                longestWord = word;
            }
        }

        int mode = 0;
        String maxmodeWord = "";

        for(String x : map.keySet()){
            if(map.get(x) > mode){
                mode = map.get(x);
                maxmodeWord = x;
            }
        }

        System.out.println(maxmodeWord + " " + longestWord);
    }
}


Measured memory_bytes: 24304
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }


int solve()
{
    ll L, R;

    cin >> L >> R;

    ll res = (L + R) / 2;

    if (res * 2 != L + R)
        cout << "IMPOSSIBLE" << endl;
    else
        cout << res << endl;

    return 0;
}

int main()
{
    solve();

    return 0;
}

Measured memory_bytes: 256