akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    ll n, C;
    cin >> n >> C;
    vector<ll> x(n), v(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> v[i];
    }
    vector<ll> Mf(n, 0), Mb(n, 0), xf(n, 0), xb(n, 0);
    ll sf = v[0], sb = v[n - 1];

    Mf[0] = max(0ll, sf - x[0]);
    if (Mf[0]) xf[0] = x[0];
    Mb[n - 1] = max(0ll, sb - C + x[n - 1]);
    if (Mb[n - 1]) xb[n - 1] = C - x[n - 1];
    for (int i = 1; i < n; i++) {
        int bi = n - 1 - i;
        sf += v[i];
        sb += v[bi];
        xf[i] = xf[i - 1], Mf[i] = Mf[i - 1];
        xb[bi] = xb[bi + 1], Mb[bi] = Mb[bi + 1];

        if (sf - x[i] > Mf[i - 1]) {
            Mf[i] = sf - x[i];
            xf[i] = x[i];
        }
        if (sb - C + x[bi] > Mb[bi + 1]) {
            Mb[bi] = sb - C + x[bi];
            xb[bi] = C - x[bi];
        }
    }

    ll ans = 0;
    for (int i = 0; i < n - 1; i++) {
        ans = max(Mf[i] + Mb[i + 1] - min(xf[i], xb[i + 1]), ans);
    }
    ans = max({ans, Mf[n - 1], Mb[0]});
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long int ll;
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  string s,t;
  cin >>s>>t;
  if(t.size()==s.size()+1&&s==t.substr(0,s.size())){
    cout <<"Yes";
  }else{
    cout <<"No";
  }
}

Measured memory_bytes: 3524
#include<iostream>
#include<math.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int h[n]={};
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  int ans=0;
  int num=0;
  for(int i=0;i<n;i+=num+1){
    int j=0;
    num=0;
    while(h[i+j]>=h[i+j+1]&&i+j+1<n){
      num++;
      j++;
    }
    ans=max(ans,num);
  }
  cout<<ans<<endl;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll N;
    string S;
    cin >> N;

    vector<ll> x(N),y(N);
    double l[N][N];
    double n = (double)N;

    REP(i,N){
        cin >> x.at(i) >> y.at(i);
    }

    REP(i,N){
        REP(j,N){
            l[i][j] = sqrt((x.at(i) - x.at(j)) * (x.at(i) - x.at(j)) + (y.at(i) - y.at(j)) * (y.at(i) - y.at(j)));
        }
        //cout << l.at(i) << endl;
    }
    double ans = 0;
    REP(i,N){
        REP(j,N){
            ans += l[i][j];
        }
    }
    cout << setprecision(9) <<ans / n << endl;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

char seq[1000000];
int dp[2][2][3][3];

inline bool valid(int l, int r) { return l <= r; }
inline int X(int index) { return (seq[index] - '1') % 3; }

int main() {
  while (fgets(seq, 999999, stdin), seq[0] != '#') {
    int len = strlen(seq) - 1;
    MEMSET(dp, 0x00);
    REP(i, 2) REP(j, 3) REP(k, 3) { if (!valid(j, k)) { dp[0][i][j][k] = 1 << 30; } }
    REP(iter, len) {
      int prev = iter & 1;
      int next = prev ^ 1;
      MEMSET(dp[next], 0x0f);
      int nx = X(iter);
      REP(lx, 3) {
        REP(rx, 3) {
          if (!valid(lx, rx)) { continue; }
          if (valid(nx, rx)) {
            dp[next][0][nx][rx] = min(dp[next][0][nx][rx], dp[prev][0][lx][rx] + 1);
            dp[next][0][nx][rx] = min(dp[next][0][nx][rx], dp[prev][1][lx][rx]);
          }
          if (valid(lx, nx)) {
            dp[next][1][lx][nx] = min(dp[next][1][lx][nx], dp[prev][0][lx][rx]);
            dp[next][1][lx][nx] = min(dp[next][1][lx][nx], dp[prev][1][lx][rx] + 1);
          }
        }
      }
    }
    int ans = 1 << 30;
    REP(i, 2) REP(j, 3) REP(k, 3) { ans = min(ans, dp[len & 1][i][j][k]); }
    cout << ans << endl;
  }
}

Measured memory_bytes: 948
nm = list(map(int, input().split(' ')))
n = nm[0]
m = nm[1]
backet = [0 for _ in range(m)]
for _ in range(n):
    likes = list(map(int, input().split(' ')))[1:]
    for like in likes:
        backet[like - 1] += 1
res = backet.count(n)
print(res)

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
	int n;
	char a[100];
	scanf("%d", &n);
	scanf("%s", a);
	if (n % 2 != 0) {
	printf("No");
	return 0;
	}		
	for (int i = 0; i < (n/2); i++) {
		if (a[i] != a[((n / 2) + i)]) {
			printf("No");
			return 0;
		}
	}
	printf("Yes");
	return 0;
	
}

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

using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"

typedef long long ll;
typedef vector<int> V;
typedef vector<ll> VL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef priority_queue<int> PQ;
typedef priority_queue<int, V, greater<int>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

ll N, K;
VL A;
map<ll, ll> digsum;

int main() {
    cin >> N >> K;
    A.resize(N);
    VECCIN(A);
    int Mdig = -1;
    REPR(i, 63) {
        if(K & 1LL << i) {
            Mdig = i;
            break;
        }
    }
    REP(i, N) {
        REPR(j, Mdig + 1) {
            if(A[i] >> j & 1) {
                digsum[j]++;
            }
        }
    }
    ll ans = 0;
    REPR(i, Mdig + 1) {
        if(digsum[i] <= N - digsum[i] && (ans | 1LL << i) <= K) {
            ans |= 1LL << i;
        }
    }
    ll sum = 0;
    REP(i, N) sum += ans ^ A[i];
    cout << sum << "\n";
    return 0;
}


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

int k, a, b, c;
int ans;

int main() {
  cin >> a >> b >> c >> k;

  if (k <= a) {
    ans = k;
  } else if ((a < k) & (k <= a + b)) {
    ans = a;
  } else if ((a + b < k) & (k <= a + b + c)){
    ans = a + (k - a - b) * (-1);
  }

  printf("%d", ans);

  return 0;
}

Measured memory_bytes: 3764
# coding: utf-8
# Your code here!

N, K = map(int, input().split())
dummy, ans = 0, 0
array, sarray = [], []
for i in range(K):
    dummy = int(input())
    array += list(map(int, input().split()))
sarray = set(array)

for j in range(1, N + 1):
    if j in sarray:
        pass
    else:
        ans += 1
print(ans)

Measured memory_bytes: 9156
S = int(input())
sum_now = 1
before_number = 1
before3 = [1, 1, 1]
for i in range(6, S+1, 1):
    sum_now = sum_now + before3[i % 3]
    before3[i % 3] = sum_now
if S == 1 or S == 2:
    print(0)
else:
    ans = sum_now % (10 ** 9 + 7)
    print(ans)

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

int main(){
  string s;
  std::cin >> s;
  int cnt=0;
  int ans=0;
  rep(i,s.size()){
    if(s[i]=='A' || s[i]== 'C' || s[i]=='G' || s[i]=='T'){
      cnt++;
    }
    else {ans=max(ans,cnt);cnt=0;}
  }
  ans=max(ans,cnt);
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3628
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)

    n, m = map(int, input().split())
    p = list(map(int, input().split()))

    # Union-Find木
    class UnionFind():
        def __init__(self, n):
            self.tree = [i for i in range(n)]

        def root(self, x):
            if(self.tree[x] == x):
                return x
            self.tree[x] = self.root(self.tree[x])
            return self.tree[x]  # 経路圧縮

        def same(self, x, y):  # xとyが同じ木に属するか
            return self.root(x) == self.root(y)

        def unite(self, x, y):
            x = self.root(x)
            y = self.root(y)
            if(x == y):
                return
            self.tree[x] = y

    uf = UnionFind(n)

    for _ in range(m):
        x, y = map(int, input().split())
        uf.unite(x-1, y-1)
    ans = 0
    for i in range(n):
        if uf.same(i, p[i]-1):
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 13876
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define vi vector<int>
#define pb(a) push_back(a)
using namespace std;

typedef long long ll;

typedef pair<ll,ll> P1;
typedef pair<int,P1> P2;
typedef pair<P1,int> Pli;
const int inf=1000000000;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

#define MAX_N 100002

int dp[MAX_N];
vector<int> G[MAX_N];
vector<int> v;
bool d[MAX_N]={};
queue<int> que;
ll x[MAX_N]={};
ll y[MAX_N]={};

int main() {
	int n,m;
	cin>>n>>m;
	int a1,b1;
	rep(i,m){
		cin>>a1>>b1;
		G[a1].push_back(b1);
		G[b1].push_back(a1);
	}
	deque<int> que;
	que.push_back(a1);
	que.push_back(b1);
	d[a1]=true;
	d[b1]=true;
	bool flg=true;
	while(flg){
		flg=false;
		a1=que.front();
		b1=que.back();
		for(auto it:G[a1]){
			if(!d[it]){
				que.push_front(it);
				d[it]=true;
				flg=true;
				break;
			}
		}
		if(flg)continue;
		for(auto it:G[b1]){
			if(!d[it]){
				que.push_back(it);
				d[it]=true;
				flg=true;
				break;
			}
		}
	}
	cout<<que.size()<<endl;
	cout<<que.front();
	que.pop_front();
	while(!que.empty()){
		cout<<" "<<que.front();
		que.pop_front();
	}
	cout<<endl;
	return 0;
}


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

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)
#define repj(i,j,n) for(i=j;i<n;i++)

#define OK(i) cout<<"OK "<<i<<endl
#define Yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define NO cout<<"NO"<<endl

using namespace std;

typedef long long int lli;
typedef long long ll;
typedef vector<int> vi;
typedef vector< vector<int> > Matrix;

int main() {
	lli x, y, z, k, i, j, t;
	lli abi, ci, abnext, cnext;

	cin >> x >> y >> z >> k;

	vector<lli>a(x), b(y), c(z), ab(x*y),abc;

	rep(i, x) {
		cin >> a[i];
	}
	rep(i, y) {
		cin >> b[i];
	}
	rep(i, z) {
		cin >> c[i];
	}

	t = 0;
	rep(i, x) {
		rep(j, y) {
			ab[t++] = a[i] + b[j];
		}
	}
	sort(ab.begin(), ab.end());


	rep(i, min(x*y,k)) {
		rep(j, z) {
			abc.push_back(ab[x*y - i - 1] + c[j]);
		}
	}
	sort(abc.begin(), abc.end());

	j = abc.size();
	rep(i, k) {
		cout << abc[j - i - 1] << endl;
	}

	return 0;
}


Measured memory_bytes: 42856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

int main(){
    double a, b, h, m;
    cin >>  a >> b >> h >> m;

    double t1, t2;
    t1 = h * 30 + m/60 * 30;
    t2 = m * 6;

    // cout << sqrt(a*a + b*b -2 * a * b * cos(abs(t2-t1)/360 *2* M_PI)) << endl;
    printf("%10.20lf\n", sqrt(a*a + b*b -2 * a * b * cos(abs(t2-t1)/360 *2* M_PI)));
    return 0;
}

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

int check(vector<int> p, int goal){
    int count = 0;
    for(int i=p.size()-1; i>=0 && goal > 0;){
        if(p[i] > 0){
            p[i]--;
            goal -= (i+1)*100;
            count++;
        }else{
            i--;
        }
    }
    return count;
}

bool bit(int mask, int pos){
    if((mask & (1 << pos)) != 0){
        return true;
    } else{
        return false;
    }
}

int main(){
    int d,g;
    cin >> d >> g;

    vector<int> p(d);
    vector<int> c(d);

    for(int i=0; i<d; i++){
        cin >> p[i] >> c[i];
    }

    int _min = INT_MAX;
    for(int i=0; i<(1 << d); i++){
        int goal = g;
        int tmp=0;
        vector<int> p2 = p;
        for(int j=0; j<d; j++){
            if(bit(i,j)){
                goal -= ((j+1)*100*p2[j]+c[j]);
                tmp += p2[j];
                p2[j] = 0;
            }
        }
        if(goal > 0){
            tmp += check(p2,goal);
        }
        _min = min(_min,tmp);
    }

    cout << _min << endl;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int X;
  vector<int> T(5);
  for(int i=0;i<5;i++){
    cin>>T.at(i);
  }
  cin>>X;
  int cnt=0;
  for(int i=0;i<5;i++){
    for(int j=0;j<5;j++){
      if(max(T.at(j),T.at(i))-min(T.at(j),T.at(i))>X){
        cnt++;
      }
    }
  }
  if(cnt==0){cout<<"Yay!"<<endl;}
  else{cout<<":("<<endl;}
}


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 = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int answer = a - (2 * b);
        System.out.println(answer >= 0 ? answer : 0);
        sc.close();
    }
}


Measured memory_bytes: 35524
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

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

int main(){
    ll n,x,y; cin >> n >> x >> y;
    x--;y--;
    vector<ll> vec(n+1, 0);
    rep(i,n)rep(j,n){
        if(i >= j)continue;
        ll temp = INF;
        chmin(temp, j - i);
        chmin(temp, abs(x - i) + 1 + abs(y - j));
        chmin(temp, abs(y - i) + 1 + abs(x - j));
        vec[temp]++;
    }
    reps(i,n-1)cout << vec[i] << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<queue>
#include <algorithm>
#include<cmath>
using namespace std;
vector< vector<int> > v;
vector<int> p;

int main(){
	int n,m;
	cin >> n >> m;
	const auto INF =  static_cast<int>(pow(2,n)); 


	for (int i = 0; i < m; i++)
	{
		int k;
		cin >> k;
		auto vv = vector<int>(); 
		for (int j = 0; j < k; j++)
		{
			int num;
			cin >> num;
			vv.push_back(num);
		}
		v.emplace_back(vv);
	}

	for (int i = 0; i < m; i++)
	{
		int pp;
		cin >> pp;
		p.push_back(pp);
	}


	int num = 0;
	for(int i = 0; i < (1<<n);i++){
        bool flag = true;
		for(int j = 0;j<m;j++){
			int c = 0;
			for (auto s : v[j])
				if(i & (1 << (s-1))) c++; 
			
			if(c % 2 != p[j]) flag = false; 	
		}
      	if(flag) num++;
	}

  	cout << num << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int h,w,x,i,k,j,n,r,a=0,m=1e9,d[20][1010],c[20]={};;
  scanf("%d %d %d",&h,&w,&x);
  for(i=0;i<h;i++){
    for(j=0;j<w;j++)scanf("%1d",&d[i][j]);
  }
  n=1<<(h-1);
  for(i=0;i<n;i++){//printf("i%d\n",i);
    a=0;
    for(j=i;j;j/=2)a+=j%2;
    for(j=0;j<h;j++)c[j]=0;
    for(j=0;j<w;j++){
      for(k=r=0;k<h;k++){
	c[r]+=d[k][j];
	if(i&(1<<k))r++;
      }
      //for(k=0;k<=r;k++)printf("%d ",c[k]);printf("\n");
      for(k=0;k<=r;k++){//printf("!%d %d\n",c[k],x);
	if(c[k]>x)break;
      }
      if(k<=r){//printf("pk\n");
	a++;
	for(k=0;k<h;k++)c[k]=0;
	for(k=r=0;k<h;k++){
	  c[r]+=d[k][j];
	  if(i&(1<<k))r++;
	}
	for(k=0;k<=r;k++){
	  if(c[k]>x)goto END;
	}
      }
    }
    if(m>a)m=a;
  END:;//printf("m%d\n",m);
  }
  printf("%d\n",m);
  return 0;
}
  


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

const int mo=1000000007;
int f[305][305];

struct info{
	int l,r,x;
}p[305];

bool cmp(info a,info b){
	return a.r<b.r;
}

int main(){
	int n,m;
	scanf("%d%d\n",&n,&m);
	for (int i=1;i<=m;i++)
		scanf("%d%d%d\n",&p[i].l,&p[i].r,&p[i].x);
	std::sort(p+1,p+m+1,cmp);
	f[0][0]=3;
	for (int i=0,t=1;i<n;i++){
		if (i)
		for (int j=i-1;j>=0;j--)
			for (int k=j?j-1:0;k>=0;k--){
				(f[i][k]+=f[j][k])%=mo;
				(f[i][j]+=f[j][k])%=mo;
			}
		for (;t<=m && p[t].r==i+1;t++)
		if (p[t].x==1){
			for (int j=p[t].l;j<=i;j++)
				for (int k=0;k<=j;k++) f[j][k]=0;
		}
		else if (p[t].x==2){
			for (int j=0;j<=i;j++)
				for (int k=0;k<=j;k++)
				if (!(k<p[t].l && p[t].l<=j)) f[j][k]=0;
		}
		else{
			for (int j=0;j<=i;j++)
				for (int k=0;k<p[t].l;k++) f[j][k]=0;
		}
	}
	int ans=0;
	for (int i=0;i<n;i++)
		for (int j=0;j<=i;j++) (ans+=f[i][j])%=mo;
	printf("%d\n",ans);
}

Measured memory_bytes: 512
<?php

$string = trim(fgets(STDIN));

$parts = explode(" ", $string);

$cats = array(
    0,
    2,
    0,
    1,
    0,
    1,
    0,
    0,
    1,
    0,
    1,
    0,
    1,
    0,
);

if ($cats[$parts[0]-1] == $cats[$parts[1]-1])
{
    echo "Yes\n";
}
else
{
    echo "No\n";
    
}

Measured memory_bytes: 3576
package main
import "fmt"
func main(){
    // Your code here!
    var a int
    var b int
    fmt.Scanf("%v%v", &a, &b)
    if a < b {
        fmt.Println("a < b")
    }else if a == b {
        fmt.Println("a == b")
    }else {
        fmt.Println("a > b")
    }
}



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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int N; cin >> N;
	map<int, int> mp;
	REP(i,N){
		int A; cin >> A;
		mp[A]++;
	}

	int ans = 0;
	for(auto a: mp){
		if(mp[a.first] % 2 == 1) ans++;
	}

	cout << ans << endl;



	return 0;

}


Measured memory_bytes: 4992
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let n = s.len();
    let mut ok = true;
    for i in 0..n {
      if s[i] != s[n-1-i] {
         ok = false;
      }
    }

    let m = (n-1)/2;
    for i in 0..m {
      if s[i] != s[m-1-i] {
         ok = false;
      }
    }

    let l = (n+3)/2-1;
    for i in l..n {
      if s[i] != s[n-1-i] {
         ok = false;
      }
    }

    if ok {
       println!("Yes");
    } else {
       println!("No", );
    }
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
//#include <limits.h>
//#include <math.h>
#include <stdbool.h>

#define N 100000

//グラフ
typedef struct edge{
  int next;
  int length;
} edge;

edge e[N+1];
bool visited[N+1];
int st[N+1];

void init(int n) {
  for (int i=0; i<n+1; i++) {
    e[i].next = 0;
    e[i].length = 0;
    visited[i] = 0;
    st[i] = 0;
  }
}

void uniteGraph(int a, int b, int length) {
  if (e[a].next == 0) {
    e[a].next = b;
    e[a].length = length%2;
  } else if (e[b].next == 0) {
    e[b].next = a;
    e[b].length = length%2;
  } else {
    int nb = e[b].next;
    int lb = e[b].length;
    e[b].next = a;
    e[b].length = length%2;
    uniteGraph(b, nb, lb);
  }
}

int dfs(int n) {
  if (visited[n]) return st[n];
  if (e[n].next == 0) {
    st[n] = 0;
    visited[n] = true;
    return st[n];
  }
  int b = dfs(e[n].next);
  st[n] = (b+e[n].length)%2;//use b
  visited[n] = true;
  return st[n];
} //DepthFirstSearch

int main() {
  int n;
  scanf("%d", &n);
  int u, v, w;
  init(n);
  for (int i=0; i<n-1; i++) {
    scanf("%d%d%d", &u, &v, &w);
    uniteGraph(u, v, w);
  }
  for (int i=0; i<n; i++) {
    printf("%d\n", dfs(i+1));
  }
  return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pi 3.141592653589793116
#define mod 1e9+7
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

vector <pair <int,int > > v[100001];
int ans[100001];
bool vi[100001];
void bfs()
{
    queue <int> q;
    q.push(1);
    vi[1]=1;
    ans[1]=1;
    while(q.size()>0)
    {
        int x=q.front();
        q.pop();
        for(int i=0;i<v[x].size();i++)
            {
                if(vi[v[x][i].first]==0)
                {   q.push(v[x][i].first);
                	vi[v[x][i].first]=1;
                    if(v[x][i].second%2==0)
                    {
                        ans[v[x][i].first]=ans[x];
                    }
                    else
                    {
                        ans[v[x][i].first]=(ans[x]+1)%2;
                    }
                }
            }
    }
}


int main() {
    off;
  	 int t;
    //cin>>t;
    t=1;
    while(t--){    
        memset(vi,0,sizeof(vi));
        int n;
        cin>>n;
        //n-=1;
        int x,y,w;
        for(int i=1;i<n;i++)
            {
                cin>>x>>y>>w;
                v[x].push_back({y,w});
                v[y].push_back({x,w});
            }
        bfs();
        for(int i=1;i<=n;i++)
            {
                cout<<ans[i]<<'\n';
            }    
            
            }
      return 0;
}

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

int main() {
    while(true) {
        long long e; cin >> e;
        if(e == 0) return 0;
        long long x, y, z;
        long long rst_min = 2000000000;
        for(y = 0; y * y <= e; y++) {
            for(z = 0; z * z * z <= e; z++) {
                x = e - y * y - z * z * z;
                if(x < 0) continue;
                if(x + y * y + z * z * z == e) {
                    rst_min = min(rst_min, x + y + z);
                }
            }
        }
        cout << rst_min << endl;
    }
}



Measured memory_bytes: 3068
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
#define M 1000000007
int main(){
  ll n,m,ma=-1,mi=M,c=0;
  cin>>n>>m;
  vector<ll> a(m),b(m);
  for(int i=0;i<m;i++){
    cin>>a[i]>>b[i];
    ma=max(a[i],ma),mi=min(b[i],mi);
  }
  cout<<max(mi-ma+1,0LL);}

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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define trav(i,a) for(auto& (i) : (a))
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)
#define dbg(x) cerr << "STDERR => " << __LINE__ << ": " << #x << " = " << (x) << "  :(\n";
#define pb push_back
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void cpuTime() { cerr << "cpu time : " << double(clock())/CLOCKS_PER_SEC << "\n"; return; }
using ll = long long;
using ull = unsigned long long;
using F = float;
using D = double;
using vi = vector<int>;
using pii = pair<int,int>;



void solve(){

    int n, m, x;
    cin >> n >> m >> x;

    vector<vi> c(n, vi(m+1, 0));
    rep(i,0,n){
        rep(j,0,m+1){
            cin >> c[i][j];
        }
    }


    vector<bool> a(n,0), b(n,0);
    ll cost = 0, ans = LLONG_MAX;
    vi sum(m, 0);

    rep(i,0,n){
        a[n-1-i] = 1;
        b = a;

        do{
            rep(j,0,m) sum[j] = 0;
            cost = 0;
            rep(j,0,n){
                if(b[j]){
                    cost += c[j][0];
                    rep(k,0,m){
                        sum[k] += c[j][k+1];
                    }
                }
            }

            rep(k,0,m){
                if(sum[k] < x) break;
                if(k==(m-1)) ans = min(ans, cost);
            }
        }while(next_permutation(all(b)));
    }

    if(ans==LLONG_MAX) cout << "-1\n";
    else cout << ans << "\n";

    return;
}

/*
 read the question carefully ( what're the exact constraints? )
 look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS
 Check datatypes
*/
int main(){

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

    while(t--){
        solve();
    }

    cpuTime();
return 0;
}


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

using namespace std;

int main(){
  string s;
  cin >> s;
  int n = s.size();
  int a[26]={};
  for(int i=0;i<n;i++){
    a[(unsigned char)s[i]-97]++;
    //cout << s[i] << " " << (unsigned char)s[i]-97 << endl;
  }
  string ans="None";
  for(int i=0;i<26;i++){
    //cout << (char)i+97 << ":" << a[i] << endl;
    if(a[i]==0){
      ans=(char)i+97;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e2 + 5, M = 1e5 + 5;

vector<pair<int, int> > v;

ld dis(int i, int j){
    return sqrtl((v[i].first - v[j].first) * (v[i].first - v[j].first) + (v[i].second - v[j].second) * (v[i].second - v[j].second));
}

int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0 ; i < n ; ++i){
        int x, y;
        scanf("%d%d", &x, &y);
        v.emplace_back(x, y);
    }
    sort(v.begin(), v.end());
    ld ans = 0;
    do{
        ld tmp = 0;
        for(int i = 0 ; i + 1 < n ; ++i)
            tmp += dis(i, i + 1);
        ans += tmp;
    }while(next_permutation(v.begin(), v.end()));
    for(int i = 2 ; i <= n ; ++i)
        ans /= (1.0L * i);
    printf("%0.9Lf\n", ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int x = sc.nextInt();
        
        if(x < 1200){
            System.out.println("ABC");
        }else if(x > 1199 && x < 3001){
            System.out.println("ARC");
        }
    }
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
template<class T,class Y>T LCM(T a,Y b){return (a*b)/GCD(a,b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

using vi=vector<int>;
using vii=vector<vi>;

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()
#define decimal(x) fixed<<setprecision(x)


int main(){
    int N;
    cin>>N;
    vi A(N+1),box(N+1,0);
    rep(i,N)cin>>A[i+1];
    box[N]=A[N];
    for(int i=N-1;i>0;i--){
        int sum=0;
        for(int j=i*2;j<=N;j+=i){
            sum+=box[j];
        }
        if(sum%2==A[i])box[i]=0;
        else box[i]=1;
    }
    int M=0;
    vi ans;
    REP(i,1,N+1){
        M+=box[i];
        if(box[i]){
            ans.pb(i);
        }
    }
    cout<<M<<endl;
    rep(i,ans.size()){
        cout<<ans[i]<<" ";
        if(ans.size()-1==i)cout<<endl;
    }
    return 0;
}

//a=97,z=122

Measured memory_bytes: 3064
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int N,L;
vector<string> t;
int main (){
    cin >> N >> L;
    string s;
    for(int i=0; i<N; i++){
        cin >> s;
        t.push_back(s);
    }
    sort(t.begin(), t.end());
    for(int i=0; i<N; i++){
        cout << t.at(i) ;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const Ld pi = M_PI;
const Int MOD = 999999999999971;
const Int INF = 1LL << 61;

Int Floor(Int a, Int b) {
    return (a - (a % b)) / b;
}

Int Ceil(Int a, Int b) {
    if (a % b == 0) {
        return a / b;
    } else {
        return Floor(a, b) + 1;
    }
}

Int digits(Int n) {
    return (Int)to_string(n).size();
}

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

    Int a, b, c;
    cin >> a >> b >> c;

    Int ans = 0;

    if (a == b && b == c) {
        if ((a % 2 == 0) && (b % 2 == 0) && (c % 2 == 0)) {
            ans = -1;
        } else {
            ans = 0;
        }
    } else {
        bool flag = (a % 2 == 0) && (b % 2 == 0) && (c % 2 == 0);
        while (flag) {
            ans++;
            Int ta, tb, tc;
            ta = a / 2;
            tb = b / 2;
            tc = c / 2;

            a = tb + tc;
            b = ta + tc;
            c = ta + tb;

            flag = (a % 2 == 0) && (b % 2 == 0) && (c % 2 == 0);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3532
#include <stdio.h>

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

  if(a<b) {printf("a < b\n");}
  if(a>b){printf("a > b\n");}
  if(a==b){printf("a == b\n");}


  return 0;

}

Measured memory_bytes: 580
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)

using namespace std;
typedef pair<int, int> ipair;

int main(int argc, char **argv) {
    int N;
    cin >> N;
    int res = (N - 2) * 180;

    cout << res << endl;
}

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

int main() {
  int N;
  cin >> N;
  bool check = true;
  set<string> S; //文字列を入れておく
  queue<char> L; //一個前の最終文字を入れておく(確認したら消す)
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      string w;
      cin >> w;
      S.insert(w);
      L.push(w[w.size()-1]);
    }
    else {
      string w;
      cin >> w;
      if (S.count(w)) {
        check = false;
        break;
      }
      if (L.front() != w[0]) {
        check = false;
        break;
      }
      S.insert(w);
      L.push(w[w.size()-1]);
      L.pop();
    }
  }
  if (check) {
    cout <<"Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n,c,k=map(int,input().split())
t=[0]*n
for i in range(n):
    t[i]=int(input())
t.sort()
s=0
lt=0
ln=0

if c==1:
    print(n)
    exit()
for i in range(n):

    if i==0:
       lt=i
       ln+=1

    else:
        if t[i]-t[lt]>k:
            s+=1
            lt=i
            ln=0

        ln+=1
        if ln==c:
            s+=1
            lt=i+1
            ln=0

        #print(i, s, lt, ln)


    
if ln>0:
    s+=1

print(s)


Measured memory_bytes: 13196
#include<iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1<<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int prim(){
    int u, minv;
    int d[MAX], p[MAX], color[MAX]; 
    // Tに属する頂点とV-Tに属する頂点をつなぐ辺の中で、重みが最小の辺の重みを記録
    // MSTにおける頂点vの親を記録
    // 訪問状態を記録

    for(int i=0; i<n; i++){ // 全ての頂点に関して、colorをwhite、dをinftyに初期化
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }

    d[0] = 0;

    while(1){
        minv = INFTY;
        u = -1;
        for(int i=0; i<n; i++){ // 最小の辺を探索
            if(minv > d[i] && color[i] != BLACK){
                u=i;
                minv = d[i];
            }
        }
        if(u==-1) break;
        color[u] = BLACK;
        for(int v=0; v<n; v++){
            if(color[v] != BLACK && M[u][v] != INFTY){ // 未訪問かつuからvに辺があるとき
                if(d[v] > M[u][v]){
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }

    int sum =0;
    for(int i=0; i<n; i++){
        if(p[i] != -1) sum += M[i][p[i]];
    }

    return sum;
}

int main(int argc, char const *argv[])
{
    cin >> n;
    for(int i=0; i<n;i++){
        for(int j=0;j<n;j++){
            int e;
            cin >> e;
            M[i][j] = (e==-1) ? INFTY : e;

        }
    }

    cout << prim() << endl;

    return 0;
}



Measured memory_bytes: 3132
/**
 * Sergey Kopeliovich (burunduk30@gmail.com)
 */

#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for (int i = 0; i < (int)(n); i++)

const int MOD = 998244353;

typedef long long ll;

inline void add( int &a, int b ) { if ((a += b) >= MOD) a -= MOD; }
inline void sub( int &a, int b ) { if ((a -= b) < 0) a += MOD; }
inline int mul( int a, int b ) { return (ll)a * b % MOD; }

int Pow( int x, ll n ) {
	if (n == 1)	return x;
	int y = Pow(x, n / 2);
	return (n & 1) ? mul(mul(y, y), x) : mul(y, y);
}

int Inv( int a ) { return Pow(a, MOD - 2); }
int Div( int a, int b ) { return mul(a, Inv(b)); }

// int C( int n, int k ) {
// 	int res = 1;
// 	forn(i, k) {
// 		res = mul(res, n - i);
// 		res = mul(res, Inv(i + 1));
// 	}
// 	return res;
// }

const int N = 103;
int f[N][N];

int calc( int a, int b ) {
	if (a < 0 || b < 0) return 0;
	if (a > b) swap(a, b);
	if (!a && !b)
		return 0;
	int &res = f[a][b];
	if (!res) {
		res = mul(Div(a,  a + b), calc(a - 1, b));
		add(res, mul(Div(b, a + b), 1 + calc(a, b - 1)));
	}
	return res;
}

double f2[N][N];
double calc2( int a, int b ) {
	if (a < 0 || b < 0) return 0;
	if (a > b) swap(a, b);
	if (!a && !b)
		return 0;
	double &res = f2[a][b];
	if (res == 0) {
		res = 1. * a / (a + b) * calc2(a - 1, b) +
		  1. * b / (a + b) * (1 + calc2(a, b - 1));
	}
	return res;
}

double calc3( int last, int i, int balance, int n ) {
	double add = 0;
	if (balance == 0 && i < 2 * n)
		add += 0.5;
	// if (balance == 0)
	// 	add += (i - last) / 2, last = i;
	if (i == 2 * n)
		return add;
	if (i + balance < 2 * n) {
		double rest = 2 * n - i, good = (rest + balance) / 2.0;
		add += good / rest * calc3(last, i + 1, balance - 1, n);
		add += (rest - good) / rest * calc3(last, i + 1, balance + 1, n);
	} else {
		add += calc3(last, i + 1, balance - 1, n);
	}
	return add;
}

int main() {
	int n, m;
	cin >> n >> m;
	// assert(n == m);
	if (n < m)
		swap(n, m);
	int res = n, tmp = 0;

	vector<int> fact(2 * n + 1);
	fact[0] = 1;
	forn(i, 2 * n)
		fact[i + 1] = mul(fact[i], i + 1);
	auto C = [&]( int n, int k ) {
		return Div(fact[n], mul(fact[n - k], fact[k]));
	};
	int all = C(n + m, n);

	for (int i = 0; i < m; i++) {
		add(tmp, mul(C(n + m - 2 * (m - i), i), C(2 * (m - i), m - i)));
	}
	add(res, Div(tmp, all * 2 % MOD));
	printf("%d\n", res);
	// printf("%d\n", calc(n, n));
	// printf("%.7f\n", calc2(n, n));
	// printf("%.7f\n", calc3(0, 0, 0, n) + n);
}
 

Measured memory_bytes: 4096
import itertools
import math

n = int(input())
x, y = [], []
for _ in range(n):
    _x, _y = map(int, input().split())
    x.append(_x)
    y.append(_y)

ans = 0
for p in itertools.permutations(list(range(n))):
    for i in range(1, n):
        s, t = p[i-1], p[i]
        ans += ((x[s]-x[t])**2 + (y[s]-y[t])**2)**0.5

print(ans/math.factorial(n))


Measured memory_bytes: 3064
/*#include<bits/stdc++.h>
using namespace std;
const long double PI=3.14159265358979323846;

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int r; cin>>r;
	cout<<fixed<<setprecision(20)<<2*r*PI<<"\n"s;
}*/
/*
#include<bits/stdc++.h>
using namespace std;

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int64_t n,m; cin>>n>>m;
	int64_t sum=0;
	for(int i=0;i<m;++i){
		int64_t a; cin>>a;
		sum+=a;
	}
	cout<<(n-sum<0?-1:n-sum)<<"\n"s;
}*/

#include<bits/stdc++.h>
using namespace std;

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>a(n);
	for(int i=0;i<n-1;++i){
		int A; cin>>A;
		++a.at(A-1);
	}
	for(auto&i:a)cout<<i<<"\n"s;
}

Measured memory_bytes: 3992
#include<iostream>
using namespace std;
int main(){
  int most,a,b;
  char s,MOST;
  while(1){
    cin >> a >> b;
    if(a==0 && b==0){
      break;
    }
    s='A';
    most=a+b;
    MOST=s;
    for(int i=1;i<5;i++){
      cin >> a >> b;
      s++;
      if(a+b>most){
	most=a+b;
	MOST=s;
      }
    }
    cout << MOST << " " << most << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i)
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
#define dis distance
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define pub push_back
#define sec second
#define fir first

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9+7;
const int INF = (1 << 30);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;
	cin >> a >> b;
	if(a+b == 15){
		cout << "+" << endl;
	}else if(a*b == 15){
		cout << "*" << endl;
	}else{
		cout << "x" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.Objects;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int sb = sc.nextInt();
        int tb = sc.nextInt();
        String deleteBall = sc.next();
        if (Objects.equals(s, deleteBall)) {
            sb = sb -1;
        } else if (Objects.equals(t, deleteBall)) {
            tb = tb -1;
        }
        System.out.println(sb + " " + tb);
    }
}

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

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;} 
ll lcm(ll x,ll y) {return x/gcd(x,y)*y;}

int main(){
    ll a,b;
    cin >> a >> b;
    ll ans=0;
    if(b==1){
        cout << 0 << endl;
        return 0;
    }
    while(1){
        ans++;
        if(ans*(a-1)+1>=b){
            cout << ans << endl;
            return 0;
        }
    }
    return 0;
}











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

	int a[3], b[2];
	for(int i=0;i<3;i++) cin>>a[i];
	int mn1 = a[0];
	for(int j=0;j<2;j++) cin>>b[j];
	int mn2 = b[0];
	for(int i=0;i<3;i++){
		mn1 = min(mn1, a[i]);
		mn2 = min(mn2, b[i]);
	}
	cout<<mn1 + mn2 - 50<<endl;
	return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

//using Graph = vector<vector<edge>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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 rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(ll i = m; i < (ll)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define query int qq;std::cin >> qq;rep(qqq,qq)
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout <<"Case #" <<qqq+1<<": "
#define RES(a,i,j) a.resize(i);rep(ii,i)a[ii].resize(j); 
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout<<a<<" "<<b<<" "<<c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define ssum(a) accumulate(a,0ll) 
#define gre(n) greater<n>()

typedef long long ll;
//
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
//typedef long long T;
const int INF = 1000000000;
const double dINF = 1000000000;
const ll INF64 = 922337203685477580ll;
const ll MOD = 1000000007ll;
//const ll MOD = 67280421310721ll;
const dou pi=3.141592653589793;
//メモ
//二次元配列のresizeのしかた
//vv.resize(n);
//for(size_t i=0; i<n; i++){
// vv[i].resize(n);
//}

//メモ
//負の辺を持つ最短経路問題では到達不可経路でも初期化値より小さくなりうるので注意しよう！
int main(){
    ll n,k;
    std::cin >> n>>k;
    VEC(ll,a,n);
    ll c=0,cc=0;
    rep(i,n){
        rrep(j,i+1,n){
            if(a[i]>a[j])c++;
        }
    }
    rep(i,n){
        rep(j,n){
            if(a[i]>a[j])cc++;
        }
    }
    ll ans=(k*c)%MOD;
    ll aans=(k-1)*(2*1+(k-1-1)*1)/2;
    aans%=MOD;
    aans*=(cc%MOD);
    std::cout << (ans+aans)%MOD << std::endl;
}

Measured memory_bytes: 256
n,m = gets.chomp.split.map(&:to_i)
arr = []
n.times.map {arr << gets.split.map(&:to_i)}
counter = 0

arr_all = []
arr.each do |v|
   v[1..v[0].to_i].each do |v2|
    arr_all << v2
   end
end

(1..m).to_a.each do |v|
  if arr_all.count(v) == n
    counter += 1
  end
end

p counter


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    string s, t;
    cin >> s >> t;
    int l = s.size();
    if (t.substr(0,l) == s) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<cstdio>
int num=0;
int n;
void merge(int A[],int left,int mid,int right)
{
    int n1=mid-left;
    int n2=right-mid;
    int M[500010],N[500010];
    for(int i=0;i<n1;i++)
    M[i]=A[left+i];
    for(int i=0;i<n2;i++)
    N[i]=A[mid+i];
    int flag1=0;
    int flag2=0;
    int flag3=0;
    int i;
    for(i=0; i<right-left;i++)
    if(M[flag1]<=N[flag2])
    {
        A[left+i]=M[flag1++];
        num++;
    //    printf("cs1");
    if(flag1==n1) {flag3=1;break;}
    }
    else{
    A[left+i]=N[flag2++];
    num++;
    if(flag2==n2) {flag3=2;break;}
    //printf("cs2");
    }
    for(int k=left+i+1;k<right;k++)
    if(flag3==1)
    {
        A[k]=N[flag2++];
        num++;
    }
    else
    {
        A[k]=M[flag1++];
        num++;
    }
/*        for(int i=0;i<n;i++)
    {
        if(i!=0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");*/
}
void mergeSort(int A[],int left,int right)
{
    if(left<right-1)
    {
      //  printf("sss\n");
        int mid;
        mid=(left+right)/2;
        mergeSort(A,left,mid);
        //printf("mmm\n");
        mergeSort(A,mid,right);
        //printf("kkk\n");
        merge(A,left,mid,right);
        //printf("cs3");
    }
}
int main()
{
  //  int n;
    scanf("%d",&n);
    int A[500010];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }
    //TODO
   // printf("bbb");
    mergeSort(A,0,n);
   // printf("aaa");
    for(int i=0;i<n;i++)
    {
        if(i!=0) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",num);
    return 0;
}



Measured memory_bytes: 6520
#include<stdio.h>
int f(int,int,int);
int x,y;
int f(int n,int kai,int sum){
    if(n>9){
        if(sum==y&&kai==x){
            return 1;
        }
        return 0;
    }
    return f(n+1,kai+1,sum+n)+f(n+1,kai,sum);
}

int main(void){
    while(1){
        scanf("%d %d",&x,&y);
        if(x==0&&y==0)break;
        printf("%d\n",f(0,0,0));
    }
    return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;


public class Main {

	public static void main(String[] args){
		
		int x,a,b;
		
		Scanner sc = new Scanner(System.in);
		
		x = sc.nextInt();
		a = sc.nextInt();
		b = sc.nextInt();
		
		int distanceA = Math.abs(x - a);
		int distanceB = Math.abs(x - b);
		
		if(distanceA > distanceB){
			System.out.println("B");
		}
		else{
			System.out.println("A");
		}
	}

}

Measured memory_bytes: 21204
N = input()
Nl = int(N[-1])

H = [2, 4, 5, 7, 9]
P = [0, 1, 6, 8]
B = [3]

if Nl in H:
    print("hon") 
elif Nl in P:
    print("pon")
elif Nl in B:
    print("bon")

Measured memory_bytes: 9140
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

int main(int argc, char const *argv[]) {
    int N;
    cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    sort(L.begin(), L.end());

    long long int ans = 0LL;
    // a <= b <= c
    for (int i = 0; i < (N - 2); i++) {
        for (int j = (i + 1); j < (N - 1); j++) {
            int a = L[i];
            int b = L[j];
            // b < c < a + b
            int ans_ = 0;

            // includes L[N - 1] == b
            if (L[N - 1] < (a + b)) {
                ans_ = ((N - 1) - j);
            } else {
                // b < c < a + b
                // c >= a + b
                auto it = lower_bound(L.begin(), L.end(), a + b);
                // cout << (it - L.begin()) << endl;
                ans_ = ((it - L.begin()) - j - 1);
            }
            // cout << "(a, b, Lmax) = " << a << ", " << b << ", " << L[N - 1] << endl;
            // cout << ans_ << endl;
            ans += (long long int) ans_;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256