akhauriyash/Code-Regression huggingface dataset:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    n = int(readline())
    #f(x):=x以下の素数を列挙する関数
    #int -> list
    def f(x):
        if x < 2:
            return [] 
        res = [2]
        for i in range(2, x+1):
            f = True
            for j in res:
                if i%j == 0:
                    f = False
            if f:
                res.append(i)
        return res
    primes = f(n)
    numOfPrime = []
    for p in primes:
        #2^10=1024だから10までで十分
        numOfDiv = 0
        for k in range(1, 11):
            numOfDiv += n//(p**k)
        numOfPrime.append((p, numOfDiv))
    P = int(1e9)+7
    ans = 1
    for i, j in numOfPrime: 
        ans *= (j+1)
        ans %= P
    print(ans) 
if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

int main() {
	int A, B;
	cin >> A >> B;
	if (B % A == 0) {
		cout << A + B;
	}
	else {
		cout << B - A;
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int p,q,a,n;
int dfs(int i,int x,int y,int l){
    if(i==n)return 0;
    int res=0;
    for (int k=1;k<=l;k++){
        int xx=x*k+y,yy=y*k;
        if(yy>a)break;
        if(p*yy==q*xx)res++;
        if(p*yy>q*xx)res+=dfs(i+1,xx,yy,k);
    }
    return res;
}
int main(){
    while(cin>>p>>q>>a>>n,n)
        cout<<dfs(0,0,1,a)<<endl;
}

Measured memory_bytes: 2992
#include <iostream>
#include <cmath>
#define MAX 1000001
using namespace std;

int p[MAX];

int main(){
	int counter = 0;
	p[1] = 0;
	for (int i = 2; i < MAX; i++){
		int sqrti = (int)sqrt(i);
		counter++;
		p[i] = counter;
		for (int j = 2; j <= sqrti; j++){
			if (i % j == 0){
				counter--;
				p[i] = counter;
				break;
			}
		}
	}
	int n;
	while (cin >> n){
		cout << p[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 5064
#include<stdio.h>
  char f[100];
  int w[1000];
int main()
{
  int i,j,k,l,m,n,num,p;
  scanf("%s",f);m=0;
  l=strlen(f); for (i=0;i<l;i++)
    w[f[i]]++;
  for (i=50;i<200;i++)
   if (w[i]>1)m=1;
  if (m==1)printf("no");
  else printf("yes");

  return 0;
}


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

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

    vector<int> b(N);
    for (int i = 0; i < N; i++)
    {
        cin >> b[i];
    }

    vector<int> ans(N);
    while (!b.empty())
    {
        bool erased = false;
        for (int i = b.size(); i > 0; i--)
        {
            if (b[i - 1] == i)
            {
                erased = true;
                ans[b.size() - 1] = i;
                b.erase(b.begin() + (i - 1));
                break;
            }
        }
        if (!erased)
        {
            cout << -1 << endl;
            return 0;
        }
    }

    for (auto itr = ans.begin(); itr != ans.end(); itr++)
    {
        cout << *itr << endl;
    }
}


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

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

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 ll MOD = 1000000007;
const int INF = 1<<29;

using Graph = vector<vector<int>>;
int main(){
  int N; cin >> N;
  vector<int> a(N - 1, 0);
  rep(i, N - 1) cin >> a[i];
  Graph G(N);
  for (int i = 0; i < N - 1; ++i){
    //cout << a[i] - 1 << endl;
    G[a[i] - 1].push_back(i);
  }
  rep(i, N) cout << G[i].size() << endl;

}


Measured memory_bytes: 14796
N,Y=map(int,input().split())
Y=Y//1000
if Y-N<0:
  print('-1 -1 -1')
else:
  a=Y-N
  for i in range(a//9+1):
    for j in range(a//4+1):
      if a==9*i+4*j:
        if N-i-j>=0:
          print(str(i)+' '+str(j)+' '+str(N-i-j))
          exit()
  print('-1 -1 -1')

Measured memory_bytes: 9144
#include "stdio.h"

int main(int argc, char const *argv[]) {
  int N;
  scanf("%d", &N);
  long long int A[N];
  for (size_t i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  for (size_t i = 0; i < N; i++) {
    if(A[i]%2==1){
      printf("first");
      return 0;
    }
  }
  printf("second");
  return 0;
}

Measured memory_bytes: 896
package main

import "fmt"

func main() {
	var a, b, k int
	fmt.Scanf("%d %d %d\n", &k, &a, &b)

	if a+2 >= b {
		fmt.Println(k + 1)
		return
	}

	d := b - a

	ke := k - (a - 1)

	res := k + (d-2)*(ke/2)
	if k < res {
		fmt.Println(res + 1)
	} else {
		fmt.Println(k + 1)
	}
}

Measured memory_bytes: 512
#include <stdio.h>
long long quick_pow(long long a,long long b)
{
	long long ret=1,cur=a;
	while (b)
	{
		if (b&1)
			(ret*=cur)%=1000000007;
		(cur*=cur)%=1000000007;
		b>>=1;
	}
	return ret;
}
long long fac[200001],inv[200001];
long long c(int a,int b)
{
	long long ret=fac[a];
	(ret*=inv[b])%=1000000007;
	(ret*=inv[a-b])%=1000000007;
	return ret;
}
int main()
{
	int h,w,a,b;
	scanf("%d%d%d%d",&h,&w,&a,&b);
	fac[0]=inv[0]=1;
	for (int i=1;i<=200000;++i)
	{
		fac[i]=(fac[i-1]*i)%1000000007;
		inv[i]=(inv[i-1]*quick_pow(i,1000000005))%1000000007;
	}
	long long ans=0;
	for (int i=1;i<=h-a;++i)
	{
		long long tmp=c(i-1+b-1,i-1);
		(tmp*=c(w-(b+1)+h-i,w-(b+1)))%=1000000007;
		(ans+=tmp)%=1000000007;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <numeric>
#include <complex>
using namespace std;

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

int main() {
    int N;
    cin >> N;
    long long L[100] = { 2,1 };
    for (int i = 2; i <= N; i++) {
        L[i] = L[i - 1] + L[i - 2];
    }
    cout << L[N] << endl;
}

Measured memory_bytes: 384
using System;
delegate bool fanction(long x);
class MyData
{
    long n,a, b;long[] h;
    public MyData(long _n, long _a, long _b,long[] _h) { n = _n; h = new long[n]; a = _a-_b; b = _b;for (int i = 0; i < n; i++) h[i] = _h[i];}
    public bool check(long t)
    {
        long a_t = t;
	    for(int i=0;i<n;i++){
		    if (h[i] - (b*t) > 0) {
                long temp = (h[i] - b * t) / a;
			    if (((h[i] - b*t) % a) > 0) temp++;
			    a_t -= temp;
			    if (a_t < 0) return false;
		    }
	    }return true;
    }
}
class MyMain
{
    static void Main()
    {
        string[] s = System.Console.ReadLine().Trim().Split(' ');
        long n = long.Parse(s[0]), a = long.Parse(s[1]), b = long.Parse(s[2]);
        long[] ld = new long[n];
        for (int i = 0; i < n; i++) ld[i] = int.Parse(System.Console.ReadLine().Trim());
        
        long res = 0;
        binarySearch(0, 1000000000, new MyData(n, a, b, ld).check, ref res);
        System.Console.WriteLine(res);
        System.Console.ReadLine();
    }
    static void binarySearch(long l, long r,fanction f,ref long res)
    {
        if (l > r) return;
        long mid = (l + r) / 2;
        if(f(mid)){res = mid;binarySearch(l, mid - 1, f, ref res);}
        else binarySearch(mid + 1, r,f,ref res);
    }
}

Measured memory_bytes: 17312
#include <iostream>
#include <set>

using namespace std;

int main() {
  for (;;) {
    int m;
    cin >> m;
    if (!m) return 0;
    int xs, ys;
    cin >> xs >> ys;
    pair<int, int> R[200];
    for (int i = 0, xx = xs, yy = ys; i < m-1; i++) {
      int x, y;
      cin >> x >> y;
      R[i].first = x - xx;
      R[i].second = y - yy;
      xx = x;
      yy = y;
    }
    int n;
    cin >> n;
    set<pair<int, int> > S;
    for (int i = 0; i < n; i++) {
      int x, y;
      cin >> x >> y;
      S.insert(make_pair(x, y));
    }
    for (set<pair<int, int> >::iterator s = S.begin(); s != S.end(); ++s) {
      bool f = true;
      for (int i = 0, x = s->first, y = s->second; f && i < m-1; i++) {
        pair<int, int> p(R[i]);
        p.first += x;
        p.second += y;
        if (!S.count(p))
          f = false;
        x = p.first;
        y = p.second;
      }
      if (f) {
        cout << s->first - xs << ' ' << s->second - ys << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		long n=sc.nextLong();
		long m=sc.nextLong();
		if(n==2||m==2) {
			System.out.println(0);
		}
		else if(n==1&&m==1) {
			System.out.println(1);
		} else {
			if(n==1) {
				System.out.println((m-2));
			} else if(m==1){
				System.out.println((n-2));
			} else {
				System.out.println((n-2)*(m-2));
			}
		}
		sc.close();
	}

}


Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>

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

using namespace std;

// return sum of seq[a,b]
int sum_seq(int a, int b){
    int res = 0;
    for(int k=a; k<=b;k++) res+=k;
    return res;
}

int solve(int n){
    int cnt = 0;
    for(int s=1;s<n;s++){
        for(int e=1;e<n;e++){
            if(e <= s) continue;
            if(sum_seq(s,e) == n) cnt++;
        }
    }
    return cnt;
}

int main(){
    int n;
    while(cin >> n){
        if(n==0) break;
        cout << solve(n) << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N;
    cin >> N;
    vector<int> C(N), S(N), F(N);
    for(int i = 1; i < N; i++){
        cin >> C.at(i) >> S.at(i) >> F.at(i);
    }

    for(int i = 1; i <= N; i++){
        int time = 0;
        for(int j = i; j < N; j++){
            if(time <= S.at(j)) time = S.at(j);
            else {
                int tmp = ( time - S.at(j) + F.at(j) - 1) / F.at(j);
                time = S.at(j) + tmp * F.at(j);
            }
            time += C.at(j);
        }
        cout << time << endl;
    }
}

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

int main() {
  string s;
  cin >> s;
  vector<bool> is_ACGT(s.size(), false);
  rep(i, s.size()) if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T') is_ACGT[i] = true;
  int max_l = 0;
  rep(i, s.size()) for (int j = i; j < s.size(); ++j) {
    bool isOK = true;
    for (int k = i; k <= j; ++k) if (!is_ACGT[k]) isOK = false;
    if (isOK) max_l = max(max_l, j - i + 1);
  }
  cout << max_l << endl;
  return 0;
}

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

using namespace std;

const int N = 365;

int dat[N][16], n;
bool vis[N+1][9][7][7][7][7];

int dfs(int d, int p, int k0, int k1, int k2, int k3){
  static int dy[4] = {-1, 0, 1, 0};
  static int dx[4] = {0, 1, 0, -1};
  if(d == n) return 1;
  int nk0 = k0, nk1 = k1, nk2 = k2, nk3 = k3;
  if(p == 0) nk0 = 0;
  if(p == 2) nk1 = 0;
  if(p == 8) nk2 = 0;
  if(p == 10) nk3 = 0;
  if(nk0 >= 7 || nk1 >= 7 || nk2 >= 7 || nk3 >= 7) return 0;
  if(dat[d][p] == 1 || dat[d][p+1] == 1 || dat[d][p+4] == 1 || dat[d][p+5] == 1) return 0;
  if(vis[d][p][k0][k1][k2][k3]) return 0;
  vis[d][p][k0][k1][k2][k3] = 1;
  for(int j=0;j<3;j++){
    for(int i=0;i<4;i++){
      int ny = p / 4 + dy[i] * j;
      int nx = p % 4 + dx[i] * j;
      if(min(ny, nx) < 0 || max(ny, nx) > 2) continue;
      if(dfs(d + 1, ny*4 + nx, nk0+1, nk1+1, nk2+1, nk3+1)) return 1;
    }
  }
  return 0;
}

main(){
  while(cin >> n && n){
    for(int i=0;i<n;++i) for(int j=0;j<16;++j) cin >> dat[i][j];
    fill(vis[0][0][0][0][0], vis[N+1][0][0][0][0], 0);
    cout << dfs(0, 5, 1, 1, 1, 1) << endl;
  }
}

Measured memory_bytes: 8928
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	double ans=0.0;
	for(int i=1;i<=n;i++){
		if(i>k){
			ans=ans+(1.0)/(double)n;
		}
			//continue;
		else{
			int t=log2(k/i);
			if(i*pow(2,t)!=k)
				t=t+1;
			ans=ans+(1.0)/(double)(n*pow(2,t)); 
		}                             
	}
	printf("%.12lf\n",ans);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------
ll MAX_N=1000;

typedef tuple<long long, long long> Pair;
Pair factor_sub(long long n, long long m){
  long long i=0;
  while(n%m==0){
    i++;
    n/=m;
  }
  return make_tuple(i,n);
}

vector<Pair> factorization(long long n){
  vector<Pair> a;
  long long c,m;
  tie(c, m) = factor_sub(n, 2);
  if(c>0)a.push_back(make_tuple(2, c));
  for(long long i=3;i*i<=m;i+=2){
    tie(c,m)=factor_sub(m, i);
    if(c>0)a.push_back(make_tuple(i,c));
  }
  if(m>1)a.push_back(make_tuple(m,1));
  return a;
}

long long divisor_numbers(long long n){
  long long a=1;
  for(auto& x: factorization(n)){
    a*=get<1>(x)+1;
  }
  return a;
}
ll factor_memo[1001];
int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n;cin>>n;
  for(int i=1;i<=n;i++){
    ll fcs=i;
    for(auto& x:factorization(fcs)){
      factor_memo[get<0>(x)]+=get<1>(x);
    }
  }
  ll psum=1;
  for(int i=0;i<1001;i++){
    psum*=factor_memo[i]+1;
    psum%=MOD;
  }
  P(psum);
  return 0;
}


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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  int mx = -1e9;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    mx = max(mx, a[i]);
  }
  int g = a[0];
  for (int i = 0; i < n; ++i) {
    g = __gcd(g, a[i]);
  }
  if (k % g == 0 && k <= mx) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


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

int main(){
  int m, n;
  cin >> n;
  bool trig=true;
  for(int i=0; i*i<=1+8*n; i++){
    if(i*i==1+8*n){
      m=(1+i)/2;
      trig=false;
      break;
    }
  }
  if(trig){
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
    cout << m << endl;
    vector<vector<int>>ret(m);
    int inc=1;
    for(int i=0; i<m-1; i++){
      for(int j=i+1; j<m; j++){
        ret[i].push_back(inc);
        ret[j].push_back(inc);
        inc++;
      }
    }
    for(int i=0; i<m; i++){
      cout << m-1 << ' ';
      for(int r: ret[i])cout << r << ' ';
      cout << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2304
import bisect

inputLine=input()
N=int(inputLine.split(" ")[0])
M=int(inputLine.split(" ")[1])

inputLine=input()
H=inputLine.split(" ")
for i in range(len(H)):
    H[i]=int(H[i])

root=[]
for i in range(M):
    inputLine=input()
    A=int(inputLine.split(" ")[0])
    B=int(inputLine.split(" ")[1])

    root.append([A,B])
    root.append([B,A])

root.sort()

root2=[]
for i in range(len(root)):
    root2.append(root[i][0])

allObservatoryCheck=[]
for i in range(N):
    allObservatoryCheck.append(True)

for i in range(N):

    startPoint = bisect.bisect_left(root2, i + 1)

    for j in range(startPoint, len(root)):
        
        if root[j][0] == i + 1:
            if H[i] <= H[root[j][1] - 1]:
                allObservatoryCheck[i] = False

        if root[j][0] > i + 1:
            break

result = 0
for i in range(N):
    if allObservatoryCheck[i] == True:
        result += 1

print(result)








Measured memory_bytes: 39312
#include <bits/stdc++.h>
using namespace std;
int N;
vector<string> a;
void f(string s, int p) {
	if (s.length() == N) {
		a.push_back(s);
		return;
	}
	for (int i = 0; i <= p; ++ i) {
		f(s + (char)('a'+i), max(p, i+1));
	}
}
int main() {
	cin >> N;
	f("", 0);
	for (auto x : a) cout << x << endl;
}


Measured memory_bytes: 7796
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <chrono>

using namespace std;
using namespace std::chrono;

using edge_t = pair<int, int>;

int main() {
  auto start = high_resolution_clock::now();

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

  int n, m;
  cin >> n >> m;
  set<edge_t> st;
  for (int i = 0; i < m; ++i) {
    int u, v;
    cin >> u >> v;
    --u;
    --v;
    st.emplace(u, v);
    st.emplace(v, u);
  }

  vector<int> a(n);
  for (int i = 0; i < n; ++i)
    a[i] = i;

  int ans = 0;
  do {
    bool ok = true;
    for (int i = 0; i + 1 < n; ++i)
      if (st.find(edge_t(a[i], a[i + 1])) == st.end())
        ok = false;

    if (ok)
      ++ans;
  } while (next_permutation(a.begin() + 1, a.end()));

  cout << ans << endl;

  cerr << "Total execution time : " << duration_cast<milliseconds>(high_resolution_clock::now() - start).count() << " ms" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Phuong_ ios_base::sync_with_stdio(0); cin.tie(0);
#define REP(i,a,b) for(int i=a; i<=b; ++i)

/// easy access -------------
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
typedef pair<int,int> pi;
typedef tuple<bool, int, int> tp;
typedef vector<vector<int>> vv;
///-------------------------


int main()
{
    Phuong_; /// <3333
    string s;
    cin >> s;
    if (s=="RRR") cout << 3; else
    if (s[0] == s[1] && s[0] == 'R') cout << 2; else
    if (s[1]==s[2] && s[1] =='R') cout << 2; else
    {
        for(int i=0; i<3; ++i) if (s[i]=='R'){
            cout << 1;
            return 0;
        }
        cout << 0;
    }
    return 0;
}


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

using namespace std;

int main() {
    int N;
    string S;
    
    cin >> N;
    cin >> S;
    
    int num[300000] ={0};
    int numL[300000] = {0};
    int numR[300000] = {0};
    int change = -1;
    
    for (int i=0; i< N-1; i++) {
        
        if(S[i] == 'W') numL[i+1] = numL[i] + 1;
        else numL[i+1] = numL[i];
        
        if(S[N-1-i] == 'E') numR[N-2-i] = numR[N-1-i] +1;
        else numR[N-2-i] = numR[N-1-i];
    }
    
    for (int i=0; i< N; i++) {
        num[i]=numL[i]+numR[i];
        
        if(i ==0) change = num[0];
        
        if (num[i]<change) change = num[i];
        
        if (change == 0) break;
    }
    
    cout << change << endl;
    
    
    return 0;
}

Measured memory_bytes: 4228
#include <iostream>
#include <vector>
#include <unordered_map>
#include <string>
#include <algorithm>

using namespace std;

bool isBeauty(string w) {
	unordered_map<char, int> freq;
	for (int i = 0; i < w.length(); i++)
	{
		char c = w[i];
		if (freq[c] == 0)
		{
			freq[c]++;
		}
		else
		{
			freq[c]--;
		}
	}

	for(auto itr = freq.begin(); itr != freq.end(); itr++) {
		if(itr->second != 0) return false;
	}
	return true;
}

int main() {
	string w;
	cin >> w;
	cout << (isBeauty(w) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i;
	long long int ans=0;
     cin>>n;
     for(i=1;i<=n;i++)
     {
     	if(i%3==0||i%5==0)continue;
     	ans+=i;
     }
     cout<<ans;
} 

Measured memory_bytes: 3632
n,p = gets.split.map(&:to_i)
a = Hash.new(0)
for i in 2..10**6
    while p%i == 0
        p /= i
        a[i] += 1
    end
end
if p != 0
    a[p] += 1
end
ans = 1
a.each do |k,v|
    ans *= k**(v/n)
end
puts ans

Measured memory_bytes: 1788
import sys
import numpy as np

N, K = input().split()

N = float(N)
K = float(K)

c = 0.0

if N > K:
    A = K/N
else:
    A = 1.0

for i in range(1,int(N)+1):
    if i > K:
        c += 1/N
    else:
        n = np.ceil(np.log2(K/i))
        c += 1/N*(1.0/2.0)**n

print(c)

Measured memory_bytes: 12392
n = int(input())
w = [input() for i in range(n)]
w_set = set(w)
if len(w) != len(w_set):
    print("No")
    quit()
else:
    for i in range(1,n):
        if w[i-1][-1] != w[i][0]:
            print("No")
            quit()

print("Yes")


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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

const int MAX = 1000000;
const int MOD = 1000000007;


int main(){
    string s, t;
    cin >> s >> t;
    int n = s.size(),m = t.size();
    int ans = 100100;
    rep(i, 0, n){
        int temp=0;
        bool fl = true;
        rep(j, 0, m){
            if(i+j>=n){
                fl = false;
                continue;
            }
            if(s[i+j]!=t[j])temp++;
        }
        if(fl)ans = min(ans,temp);
        //cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#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 ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
  int N; cin >> N;
  int A, B; cin >> A >> B;
  vector<int> P(N);
  rep(i, N) cin >> P[i];
  sort(ALL(P));
  vector<int> vec(3);
  rep(i, N) {
    if (P[i] <= A) vec[0]++;
    else if (P[i] > B) vec[2]++;
    else vec[1]++;
  }
  cout << vmin(vec) << endl;
}


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 n;
    cin >> n;
    vector<Int> a(n), b(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    reverse(a.begin(), a.end());
    reverse(b.begin(), b.end());

    Int ans = 0;
    for (Int i = 0; i < n; i++) {
        a[i] += ans;
        if (a[i] % b[i] != 0) {
            ans += b[i] - (a[i] % b[i]);
        }
    }

    cout << ans << endl;

    return 0;
}


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

const int maxn = 1e5 + 10, mod = 1e9 + 7;
vector<int> adj[maxn];
int fa[maxn], choice[maxn], vis[maxn];

void dfs(int u, int pa) {
  fa[u] = pa;
  for (auto v : adj[u]) {
    if (v != pa) dfs(v, u);
  }
}

int main() {
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  #endif
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < n - 1; ++i) {
    int u, v;
    cin >> u >> v;
    --u, --v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(0, -1);
  queue<pair<int, int>> q;
  vis[0] = 1;
  q.push(make_pair(0, k));
  while (!q.empty()) {
    int u, c;
    tie(u, c) = q.front();
    q.pop();
    choice[u] = c;
    int cnt;
    if (fa[u] == -1) cnt = k - 1;
    else cnt = k - 2;
    for (auto v : adj[u]) {
      if (!vis[v]) {
        q.push(make_pair(v, cnt--));
        vis[v] = 1;
      }
    }
  }
  long long ans = 1;
  for (int i = 0; i < n; ++i) ans *= choice[i], ans %= mod;
  cout << ans;
  return 0;
}

Measured memory_bytes: 10368
require "matrix"

#main
n = gets.to_i
arr = Array.new
n.times{arr << gets}
def dist(p1, p2)
   Math.sqrt((p1[1] - p2[1]) ** 2 + (p1[0] - p2[0]) ** 2)
end
def abs(x)
   if x < 0
      -x
   else
      x
   end
end
arr.each do |i|
   k = i.split(" ")
   k.map!{|j| j.to_f}
   pa = Vector[k[0], k[1]]
   ra = k[2]
   pb = Vector[k[3], k[4]]
   rb = k[5]
   d = dist(pa, pb)
   if (ra + rb) < d
      c = 0
   elsif abs(rb - ra) <= d
      c = 1
   elsif rb > ra
      c = -2
   else
      c = 2
   end
   puts c
end

Measured memory_bytes: 6428
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
	int cnt = 0;

	for(int i = 1; i<=n; i++) {
	    if(i%2==0) continue;
	    int locnt = 0;
	    for(int j = 1; j<=i;j++) {
		if(i%j==0) locnt++;
	    }
	    if(locnt==8) cnt++;
	}

	System.out.println(cnt);

    }
}

Measured memory_bytes: 23252
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
using namespace std;
using pii = pair<int, int>;
using ll = long long;
using ld = long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
typedef long long ll;

int main(){

	//int N, M, *A, *B, i, j, *W, *flag, sum=0, start, end, length, tmp;
	int N, K, H, W, B, **ans, flag = 0, i, j, ans_0 = 0, ans_W = 0, len, max_i=0;
	int A[200000];
	int temp, max=0;
	double sum = 0.0;


	scanf("%d", &N);
	for (i = 0; i < N; i++){
		scanf("%d", &A[i]);
	}

	sort(A, A + N);

	for (i = 0; i < N - 1; i++){
		if (A[i] == A[i + 1]){
			printf("NO\n");
			return 0;
		}

	}


	printf("YES\n");

	/*
	ans = (int **)malloc(sizeof(int *)* H);


	for (i = 0; i<H; i++) {
		ans[i] = (int *)malloc(sizeof(int)* W);
	}

	for (i = 0; i < H; i++){
		for (j = 0; j < W; j++){
			ans[i][j] = 0;
		}
	}
	*/

	return 0;

}
    


Measured memory_bytes: 1024
#include "bits/stdc++.h"
//#include <string>
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,m;


//文字列スウチ比較
//s0<s1 なら-1,s0==s1なら0,s0>s1なら1
int mystrcmp(string s0,string s1){
  int sl0=s0.length();
  int sl1=s1.length();
  if (sl0<sl1){
	  return -1;
  }
  if (sl0>sl1){
	  return 1;
  }
  const char *c0=s0.c_str();
  const char *c1=s1.c_str();
  int rt=strcmp(c0,c1);
  if (rt<0){
    return -1;
  }
  if (rt>0){
    return 1;
  }
  return 0;
}


int main(){
  cin>>n>>m;
  vi a(m);
  int mtchn[10] ={0,2,5,5,4,5,6,3,7,6};
  REP(i,m){
    cin>>a[i];
  }
  //mtchn[a[i]]
  vector<string> dpst(10001);

  REP(i,n+1){
	  REP(j,m){
		  //a[j]//実際の数字
		  //mtchn[a[j]]//マッチ数
		  int idx=i-mtchn[a[j]];
		  if (idx>=0){
			  if ((dpst[idx].length()!=0)|(idx==0)){
				string stchk=dpst[idx]+to_string(a[j]);
				int ret=mystrcmp(dpst[i],stchk);
				if (ret==-1){
					dpst[i]=stchk;
				}
			  }
		  }
	  }
  }


	cout<<dpst[n]<<endl;
  return 0;
}

Measured memory_bytes: 31872
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
typedef long long LL;

int main() {
	int a;

	std::cin >> a;

	if (a == 3 || a == 5 || a == 7) {
		std::cout << "YES" << std::endl;
	}
	else {
		std::cout << "NO" << std::endl;
	}
}

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

string S;

int main(void) {
	cin >> S;
	int len = S.length();

	int cnt_0 = 0;
	for (int i = 0; i < len; ++i) {
		if (S[i] == '0')
			++cnt_0;
	}
	int cnt_1 = len - cnt_0;
	int ren = abs(cnt_0 - cnt_1);
	int ans = len - ren;

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 512
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (chunk) {
    var lines = chunk.toString().split(' ');
    var a =lines[0];
var b = lines[1];
var c = lines[2];
if(a < b && b < c)
console.log("Yes");
else
console.log("No");
});

Measured memory_bytes: 7648
X = int(input())

div = []

sqrtX = int(X**0.5)+1
for i in range(1,sqrtX+1):
    if X % i == 0:
        div.append(i)
        div.append(X//i)

div = sorted(set(div))

for d in div:
    A = 0
    while True:
        B = A - d
        R = A**4 + A**3 * B + A**2 * B**2 + A* B**3 + B**4
        Y = (A-B) * R
        if Y == X:
            print(A,B)
            exit()

        B = d + A
        R = A**4 + A**3 * B + A**2 * B**2 + A* B**3 + B**4
        Y = (A-B) * R
        if Y == X:
            print(A,B)
            exit()
        if A > 1000:
            break
        A += 1


Measured memory_bytes: 84628
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll n,m;
  string a[100],b[100];
  cin >> n >> m;
  rep(i,n)cin >> a[i];
  rep(i,m)cin >> b[i];
  rep(i,n-m+1){
    rep(j,n-m+1){
      rep(k,m){
        rep(l,m){
          if(a[k+i][l+j]!=b[k][l])goto A;
        }
      }
      printf("Yes");
      return 0;
      A:;
    }
  }
  printf("No");
}

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

int main() {
  int n;
  cin >> n;
  vector<string> v(n);
  
  for(int i = 0; i < n; i++) {
    string s;
    cin >> s;
    v.at(i) = s;
  }
  int AC_cnt = 0, WA_cnt = 0, TLE_cnt = 0, RE_cnt = 0;
  for(int i = 0; i < n; i++) {
    if(v.at(i) == "AC") AC_cnt++;
    else if(v.at(i) == "WA") WA_cnt++;
    else if(v.at(i) == "TLE") TLE_cnt++;
    else RE_cnt++;
  }
  cout << "AC x " << AC_cnt << endl
  	   << "WA x " << WA_cnt << endl
       << "TLE x " << TLE_cnt << endl
       << "RE x " << RE_cnt << endl;
}

Measured memory_bytes: 6360
#include <iostream>
#include <algorithm>
#include <vector>

#define INPUT_ARRAY(N, A) \
    int N; \
    std::cin >> N; \
    std::vector<int> A(N); \
    for(int i = 0; i < N; ++i) std::cin >> A[i];

template<class T>
void print(const T &C)
{
    for(auto i : C)
    {
        std::cout << i << " ";
    }
    std::cout << std::endl;
}

int main()
{
    int N, Y;
    std::cin >> N >> Y;
    
    int a, b, c;
    for(a = N; a >= 0; --a)
    {
        if(10000 * a + 5000 * (N - a) < Y) continue;
        
        for(b = N - a; b >= 0; --b)
        {
            c = N - a - b;
            if(10000 * a + 5000 * b + 1000 * c == Y)
                goto answer;
        }
    }
    
    a = -1; b = -1; c = -1;
    
answer:
    std::cout << a << " " << b << " " << c;
}


Measured memory_bytes: 256
X=int(input())
for i in range(121):
    a=i
    for j in range(121):
        b=j
        if(a**5-b**5==X):
            A=a
            B=b
        b=-j
        if(a**5-b**5==X):
            A=a
            B=b
print(A,B)

Measured memory_bytes: 9064
#include <iostream>
#include <stdlib.h>
#include <vector> //vector
#include <algorithm> //sort()

using namespace std;

template<class T> inline bool chmin(T& a, T b);
template<class T> inline bool chmax(T& a, T b);

uint64_t a, b, c, d, i, j, k, n, m;

int main(){
//////////////////////////////////////////////////////

    //string s;
    
    //cin >> s;

    uint64_t x;
    cin >> n >> m;

    // for ( int i = 0 ; i < 10 ; i ++)
    // {
        
    //     x = a * x - b;
    //     cout << x << endl;
    // }

    // cout << "n:" << n << endl;

    uint64_t l,r;
    uint64_t lmax=0,rmin=1000000000;



    // vector<long> l(n+1);
    // vector<long> r(n+1);
    for (int i = 1 ; i <= m ; i ++ )
    {
        // cin >> l[i] >> r[i];
        // cout << "l[" << i << "]=" << l[i] << endl;
        // cout << "r[" << i << "]=" << r[i] << endl;

        cin >> l >> r;

        chmax(lmax,l);
        chmin(rmin,r);
        //cout  << "lmax"<< lmax << endl;
        //cout  << "rmin"<< rmin << endl;
        


    }

    if(lmax > rmin)
    {
        cout << 0 << endl;
    }
    else
    {
         cout << rmin-lmax + 1 << endl;
    }
    

   

    // sort(input.begin() , input.end());

    // uint64_t max = numeric_limits<uint64_t>::max();


    //////////////////////////////////////////////////////
    // DP

//     // 無限大の値
//     const uint64_t INF = (uint64_t)1 << 60;
//     //const int64_t NINF = -1 * ((int64_t)1 << 60 );

//     // DP テーブル
//     uint64_t dp[100010];

//     //DPテーブル初期化（最小化用）
//     for (int i = 0; i < 100010; ++i)
//     {
//         //dp[i] = INF;
//         dp[i] = 0;
//     } 

//     // 初期条件
//     dp[0] = 0;

//     // ループ
//     for (int i = 1; i <= n; ++i) {
//         //chmin( dp[i], dp[i - 1] + abs( input[i] - input[i - 1] ));
//         //if (i < 2)continue;
//         //chmin( dp[i], dp[i - 2] + abs( input[i] - input[i - 2] ));



//         // chmax ( dp [i] , dp[i - 1]);
//         // chmax ( dp [i] , dp[i - 1] + input[i]);
//         // cout << "dp[" << i <<"] = " << dp[i] << endl;

//     }



// //////////////////////////////////////////////////////

//     cout << dp[n] << endl;

//////////////////////////////////////////////////////
// Ctrl + Opt + N to make
    return 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;
}

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

using namespace std;

using ll = long long;

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

    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> b[i];
    for (int i = 0; i < n; ++i) cin >> c[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll cnt = 0;
    for (int i = 0; i < n; ++i) {
        ll na = distance(a.begin(), lower_bound(a.begin(), a.end(), b[i]));
        ll nc = distance(upper_bound(c.begin(), c.end(), b[i]), c.end());
        cnt += na * nc;
    }

    cout << cnt << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const long long INF=INT_MAX/4;
const long long MOD=998244353;
const double EPS=1e-14;
const bool DEBUG=false;

const string YES = "YES";
const string NO = "NO";
const string Yes = "Yes";
const string No = "No";

template<class T>
void debug(T head){
    if(DEBUG){
        cout<<head<<endl;
    }
}

template <class Head, class... Body>
void debug(Head head, Body... body){
    if(DEBUG){
        cout<<head<<" ";
        debug(body...);
    }
}

/////
void answer(ll N, vector<string> &s){
    ll answer = 0;
    ll x = 0, y = 0, z = 0;
    for(auto ss : s){
        int len = ss.length();
        for(int i=0; i<len - 1; ++i){
            if(ss.substr(i, 2) == "AB"){
                answer++;
            }
        }
        if(ss[0] == 'B' && ss[len - 1] == 'A'){
            z++;
        }else if(ss[0] == 'B'){
            x++;
        }else if(ss[len - 1] == 'A'){
            y++;
        }
    }
    debug(answer);
    debug(x, y, z);
    if(z>0){
        answer += z-1;
        // if(x != y){
        if(x + y > 0){
            answer++;
        }
    }
    answer += min(x, y);
    cout<<answer<<endl;
    return;
}

/////

int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout.precision(16);

    ll N;
    cin>>N;
    vector<string> s(N);
    for(auto &ss : s){
        cin>>ss;
    }
    answer(N, s);

    return 0;
}


Measured memory_bytes: 3664
power=[1,2]

if __name__ == '__main__':
    N,M=list(map(int,input().split()))
    data=[list(map(int,input().split())) for i in range(N)]
    ans=0
    for i in power:
        for j in power:
            for k in power:
                temp=[]
                for cake in data:
                    temp.append(cake[0]*(-1)**i+cake[1]*(-1)**j+cake[2]*(-1)**k)
                temp.sort()
                temp2=temp[-M:]
                ans=max(ans,sum(temp2))

    if M==0:
        print(0)
    else:
        print(ans)




Measured memory_bytes: 41200
// 2012/07/25 Tazoe

#include <iostream>
using namespace std;

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

		if(n==0)
			break;

		int i[1000], p[1000], q[1000], r[1000];
		for(int j=0; j<n; j++){
			cin >> i[j] >> p[j] >> q[j] >> r[j];
		}

		int P, Q, R, C;
		cin >> P >> Q >> R >> C;

		bool flg = false;
		for(int j=0; j<n; j++){
			if(p[j]<=P&&q[j]<=Q&&r[j]<=R&&4*p[j]+9*q[j]+4*r[j]<=C){
				cout << i[j] << endl;
				flg = true;
			}
		}

		if(!flg){
			cout << "NA" << endl;
		}
	}

	return 0;
}

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

int main(){
    string s;
    cin >> s;
    if((s[0] == s[1]&&s[1]==s[2])||(s[1] == s[2]&& s[2] == s[3])){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a=0,b=0,c=0,d,n=0,x;
    VI m(3);
    string s,s1,s2;
    cin >> a >> b;   
    cout << a*b - a - b+1  << endl;
    return 0;
} 

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

int main(){
  int n, m; cin >> n >> m;
  
  vector<vector<int>> graph(n+1);
  
  for(int i = 0; i < m; i++){
  	int a, b; cin >> a >> b;
  
  	graph[a].push_back(b);
  	graph[b].push_back(a);
  }
  
  queue<int> que;
  que.push(1);
  
  vector<int> seen(n+1, -1);
  seen[1] = 1;
  
  vector<int> parent(n+1);
  
  while(!que.empty()){
  	int nv = que.front();
    que.pop();
  
  	for(int v : graph[nv]){
    	if(seen[v] != -1) continue;
      	que.push(v);
      
      	seen[v] = 1;
      
      	parent[v] = nv;
  	}
  
  }
  
  cout << "Yes" << endl;
  for(int i = 2; i <= n; i++) cout << parent[i] << endl;
}


Measured memory_bytes: 10708
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[][] c = new int[10][10];
		int[][] A = new int[h][w];
		for(int i = 0 ; i < 10 ; i++) {
			for(int j = 0 ; j < 10 ; j++) {
				c[i][j] = sc.nextInt();
			}
		}
		for(int i = 0 ; i < h ; i++) {
			for(int j = 0 ; j < w ; j++) {
				A[i][j] = sc.nextInt();
			}
		}
		for(int k = 0 ; k < 10 ; k++) {
			for(int i = 0 ; i < 10 ; i++) {
				for(int j = 0 ; j < 10 ; j++) {
					c[i][j] = Math.min(c[i][j], c[i][k] + c[k][j]);
				}
			}
		}
		int ans = 0;
		for(int i = 0 ; i < h ; i++) {
			for(int j = 0 ; j < w ; j++) {
				if(A[i][j] >= 0) {
					ans += c[A[i][j]][1];
				}
			}
		}
		System.out.println(ans);
	}
}

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

//二項係数を求める。
const int MAX = 210000;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
  ll N,K; cin>>N>>K;
  COMinit();
  vector<ll> A(N); rep(i,N)cin>>A.at(i);
  sort(begin(A),end(A));
  ll res = 0;
  for(ll i = K-1; i < N; i++){
    ll tmp = A.at(i)*COM(i,K-1)%MOD;
    tmp += MOD;
    res += tmp;
    res %= MOD;
  }
  ll res2 = 0;
  for(ll i = 0; i+K <= N; i++){
    ll tmp = A.at(i)*COM(N-1-i,K-1)%MOD;
    tmp += MOD;
    res2 += tmp;
    res2 %= MOD;
  }
  
  cout<<((res-res2)%MOD+MOD)%MOD<<endl;
}


Measured memory_bytes: 5888
import math
import itertools

n = int(input())
l = []
ll = []
for i in range(n):
    l.append(list(map(int, input().split())))
for v in itertools.permutations(l, n):
    ll.append(list(v))

ans = 0
for j in ll:
    for k in range(n-1):
        a = j[k]
        b = j[k+1]
        aa = pow((b[0] - a[0]),2)
        bb = pow((b[1] - a[1]),2)
        ans+=pow(aa+bb, 1/2)
print(ans/len(ll))




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

using namespace std;
long long a[1000001],k=0,n;
int main()
{
    cin>>n;
    for(int i=1;i<=2*n;i++)cin>>a[i];
    sort(a+1,a+1+2*n);
    for(int i=1;i<=2*n;i+=2)
    {
        k=k+a[i];
    } 
    cout<<k;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

using namespace std;

long long f(long long x, long long b) {
  long long ret = 0;
  if (b <= 1)
    return -1;
  while (x > 0) {
    ret += x % b;
    x /= b;
  }
  return ret;
}

/*
p + q = s;
p *b + q = x
*/
int main() {
  long long n, s;
  cin >> n >> s;
  if (n == s) {
    cout << n + 1 << endl;
    return 0;
  }
  if (s > n) {
    cout << -1 << endl;
    return 0;
  }
  for (long long i = 2; i * i <= n; i++) {
    if (s == f(n, i)) {
      cout << i << endl;
      return 0;
    }
  }
  long long ans = 100000000000;
  for (long long i = 1; i * i <= n && i <= s; i++) {
    long long j = s - i;
    if ((n - j) / i) {
      if (f(n, ((n - j) / i)) == s)
        ans = min(ans, (n - j) / i);
    }
  }
  if (ans >= 100000000000)
    cout << -1 << endl;
  else
    cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  for (int i=0; i<N; i++) cin >> H[i];
  vector<int> memo(N-1); // memo[i]には，i+1<=j<NにおけるH[j]の最小値を格納
  for (int i=N-2; i>=0; i--) {
    if (i==N-2) memo[i] = H[i+1];
    else if (H[i]<memo[i+1]) memo[i] = H[i];
    else memo[i] = memo[i+1];
  }
  bool can = true;
  for (int i=0; i<N-1; i++) {
    if (H[i]-memo[i]>1) {
      can = false;
      break;
    }
  }
  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main(){
  double a, b, x;
  cin >> a >> b >> x;
  double ans;
  if(x > a*a*b/2.0) {
    ans = atan(2.0*(a*a*b-x)/(a*a*a));
  } else {
    ans = atan(a*b*b/(2.0*x));
  }
  ans = 180.0*ans/3.14159265359;
  printf("%.12f\n",ans);
  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

const int INF = 1 << 24;
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

typedef unsigned long long ull;
typedef std::pair<int,int> P;

std::vector<int> G[20];
std::vector<int> order;
int used[20];

void dfs(int from){
    used[from] = 1;

    REP(i, G[from].size()){
        if(!used[G[from][i]]){
            dfs(G[from][i]);
        }
    }

    order.push_back(from+1);
}

int main(){
    int M, N;
    std::cin >> M >> N;
    
    REP(i, N){
        int x, y;
        std::cin >> x >> y;
        x--; y--;

        G[x].push_back(y);
    }

    REP(i, M){
        if(!used[i]){
            dfs(i);
        }
    }

    std::reverse(order.begin(), order.end());

    REP(i, M){
        std::cout << order[i] << std::endl;
    }
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define MAX_N 100005
int N,M;
int i;
int par[MAX_N];
int ran[MAX_N];

void init(int n) {
  for(int i=0;i<n;i++) {
    par[i]=i;
    ran[i]=0;
  }
}

int find(int x) {
  if(par[x]==x) {
    return x;
  } else {
    return par[x]=find(par[x]);
  }
}

void unite(int x,int y) {
  x=find(x);
  y=find(y);
  if(x==y) return;
  if(ran[x]<ran[y]) {
    par[x]=y;
  } else {
    par[y]=x;
    if(ran[x]==ran[y]) ran[x]++;
  }
}

bool same(int x,int y) {
  return find(x)==find(y);
}
  
int main() {
  int j;
  cin >> N >> M;
  int p[N];
  for(j=0;j<N;j++) cin>>p[j];
  init(N);
  for(j=0;j<M;j++) {
    int A,B;
    cin >>A >> B;
    unite(A,B);
  }
  ll ans=0;
  for(int k=0;k<N;k++){
	if(same(k+1,p[k])) ans+=1;
  }
  cout<<ans<<endl;
  return 0;  
}


Measured memory_bytes: 1408