akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, a, n) for (ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;

int main(void) {
  ll N, M;
  cin >> N >> M;
  vector<pair<ll, ll>> P(M);
  REP(i, 0, M) cin >> P[i].second >> P[i].first;
  sort(P.begin(), P.end());

  ll ans = 0, t = 0;
  REP(i, 0, M) {
    if (t <= P[i].second) {
      ans++;
      t = P[i].first;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	int l,n;
    cin>>n>>l;
	vector <string> s(n);
	for(int i=0;i<n;i++) cin>>s[i];
	sort(s.begin(),s.end());
	for(int i=0;i<n;i++) cout<<s[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
//#include <boost/multiprecision/cpp_dec_float.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#include <bitset>
#include <iomanip>
using namespace std;
//namespace mp = boost::multiprecision;
//using llll = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
//using Real = mp::number<mp::cpp_dec_float<1024>>;
using ll = long long;
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  //cout<<fixed<<setprecision(10);
  ll h,w,n,ans=0;
  cin>>h>>w>>n;
  ans=n/max(h,w)+(n%max(h,w)==0?0:1);
  cout<<ans<<endl;
}


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

#define V vector
typedef long long ll;
typedef unsigned long long ull;

typedef V<int> vi;
typedef V<ll> vll;
typedef V<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define f(i,a) for(int i = 0 ; i < a ; i++)
#define fll(i,a) for(ll i = 1 ; i <= a ;i++)
#define forab(i,a,b) for(int i = a ; i < b ; i++)
#define prec(x) cout<<fixed<<setprecision(x)
#define ff first
#define ss second
#define INF 1000000000

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1

long long binpow(long long a, long long b) {
	long long res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}



void solve()
{
	ll n , cost = 0;
	ll expo = 1;
	cin >> n;

	for (ll i = 2 ; i <= sqrt(n) ; i++)
	{
		ll count = 0;

		if (n % i == 0)
		{
			while (n % i == 0)
			{
				count++;
				n /= i;
			}

			for (ll j = 1 ; ; j++)
			{
				if (count < j)
					break;
				count -= j;
				cost++;
			}
		}
	}

	if (n != 1) cost++;

	cout << cost << "\n";
}



int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);


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


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

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

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    long long sum = 0;
    for (int i = 0; i < N; i++)
    {
        cin >>A[i];
        sum+=A[i];
    }
    vector<int> X(N);

    X[0]=0;
    for (int i = 0; i < N; i++)
    {
        if(i%2==0)X[0]+=A[i];
        else X[0]-=A[i];
    }    
    cout << X[0];

    for (int i = 1; i < N; i++)
    {
        X[i]=(2*A[i-1])-X[i-1];
        cout << " "<<X[i];
    }
    

    return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define MAX 400
#define CMAX 999999

int d[40][MAX+1][MAX+1];

int main(){
	for(int i=0; i<40; i++){
		for(int j=0; j<=MAX; j++){
			for(int k=0; k<=MAX; k++){
				if(j==0 && k==0) d[i][j][k]=0;
				else d[i][j][k]=CMAX;
			}
		}
	}
	int n, ma, mb;
	cin >> n >> ma >> mb;

	int a, b, c;
	cin >> a >> b >> c;
	d[0][a][b]=c;
	for(int i=1; i<n; i++){
		int a, b, c;
		cin >> a >> b >> c;
		for(int j=0; j<=MAX; j++){
			for(int k=0; k<=MAX; k++){
				d[i][j][k]=d[i-1][j][k];
			}
		}
		for(int j=a; j<=MAX; j++){
			for(int k=b; k<=MAX; k++){
				d[i][j][k]=min(d[i][j][k], d[i-1][j-a][k-b]+c);
			}
		}
	}

	int ans=CMAX;
	for(int i=1; i*ma<=MAX && i*mb<=MAX; i++){
		if(d[n-1][i*ma][i*mb]!=CMAX){
			ans=min(ans, d[n-1][i*ma][i*mb]);
		}
	}
	if(ans==CMAX) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 25344
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef long long ll;
#define REP(i, n) for(int i = 0;i < n;i++)
#define ALL(a) a, a+sizeof(a)/sizeof(a[0])
#define all(a) a.begin(),a.end()
#define MOD 1000000007

ll gcd(ll n, ll m) {
	if (m == 0) return n;
	return gcd(m, n % m);
}
ll lcm(ll n, ll m) { return m / gcd(n, m) * n; }

int main(void) {
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	if (x + r > w || y + r > h || x - r < 0 || y - r < 0) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3116
#include <stdio.h>
 
int main()
{
	int datanum;
	int i = 0;
	int cnt = 0;
	int endnum;
	int flag = 1;
	long A[200];
 
	scanf("%d", &datanum);
	for (i = 0; i < datanum; i++) {
		scanf("%d", &A[i]);
	}
	while (flag) {
		for (i = 0; i < datanum; i++) {
			if ((A[i] & 1)!= 0) {
				flag = 0;
				break;
			}
			else {
				A[i] = A[i] >> 1;
			}
		}
		cnt++;
	}
	printf("%d\n", (cnt - 1));
    return 0;
}

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

// ------------ Greatest Common Divisor (Update 8/7) ------------ //
inline unsigned long long gcd(unsigned long long x, unsigned long long y) {
	while (y != 0) {
		unsigned long long r = x;
		x = y;
		y = r % y;
	}
	return x;
}

// ------------ Prime Factorization (Update 8/6) ------------ //
std::map<unsigned long long, unsigned> prime_factorize(unsigned long long x) {
	std::map<unsigned long long, unsigned> ret;
	for (unsigned i = 2; 1ULL * i * i <= x; i++) {
		while (x % i == 0) x /= i, ret[i]++;
	}
	if (x != 1) ret[x]++;
	return ret;
}

// ------------ Enumerate Divisors (Update 10/27) ------------ //
std::vector<unsigned long long> calc_divisors(unsigned long long x) {
	std::map<unsigned long long, unsigned> res = prime_factorize(x);
	std::vector<unsigned long long> ret; ret.push_back(1);
	for (std::pair<unsigned long long, unsigned> w : res) {
		int s = ret.size();
		unsigned long long mul = 1;
		for (int i = 0; i < w.second; i++) {
			mul *= w.first;
			for (int j = 0; j < s; j++) ret.push_back(ret[j] * mul);
		}
	}
	sort(ret.begin(), ret.end());
	return ret;
}

int n, a, x;
int main() {
	cin >> n >> a; x = a;
	for(int i = 1; i < n; i++) cin >> a, x = gcd(x, a);
	vector<unsigned long long> v = calc_divisors(x);
	for(unsigned long long i : v) cout << i << endl;
	return 0;
}

Measured memory_bytes: 3176
#include <bits/stdc++.h>
template<typename T>
class fixed_point : T {
  public:
    explicit constexpr fixed_point (T&& t) noexcept
      : T(std::forward<T>(t)) {}
    template<typename... Args>
    constexpr decltype(auto) operator()(Args&&... args) const
      {return T::operator()(*this, std::forward<Args>(args)...);}
};
template<typename T>
static inline constexpr decltype(auto) fix (T&& t) noexcept {
  return fixed_point<T>{std::forward<T>(t)};
}
int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  auto grundy = fix ([&](auto grundy, int n, int k) -> int {
    int q = n / k, r = n % k;
    auto ret = q == 0
      ? 0
      : r == 0
      ? q
      : grundy(n - (r + q) / (q + 1) * (q + 1), k);
    return ret;
  });
  int n; std::cin >> n;
  int g = 0;
  for (int i = 0; i < n; i++) {
    int a, k; std::cin >> a >> k;
    g ^= grundy(a, k);
  }
  std::cout << (g == 0 ? "Aoki" : "Takahashi") << std::endl;
  return 0;
}

Measured memory_bytes: 768
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()

C.sort()
ans = 0
for b in B:
    a = bisect.bisect_left(A, b)

    c = bisect.bisect_right(C, b)
    ans += a*(N-c)
print(ans)


Measured memory_bytes: 23232
from itertools import product
N,M = map(int,input().split())
K = []
S = []
for i in range(M):
    k, *s = map(int,input().split())
    K.append(k)
    S.append(s)
P = list(map(int,input().split()))

pro = product([0,1],repeat=N)
ans = 0
for pr in pro:
#    print(pr)
    flag = True
    for i in range(M):
        tmp = 0
        for p in S[i]:
            tmp += pr[p-1]
        if tmp % 2 != P[i]:
            flag = False
            break
    if flag: ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>
#include <limits>
#include <cassert>
#include <bitset>

using namespace std;

/* template */

using ll = long long;

void debug_out() { std::cout << std::endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cout << "debug: "; debug_out(__VA_ARGS__)
#else
#define debug(...) 
#endif

#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)
#define rrep(i, a, n) for (int i = ((int)(n-1)); i >= (int)(a); i--)
#define Rep(i, a, n) for (long long i = (long long)(a); i< (long long)(n); i++)
#define RRep(i, a, n) for (long long i = ((long long)(n-1ll)); i>=(long long)(a); i--)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}

struct Edge{
    int to;
    ll weight;
    Edge(int t, ll w) : to(t), weight(w){ }
};

struct edge{
    int from;
    int to;
    ll weight;
    edge(int f,int t,ll w) : from(f), to(t), weight(w){ }
};


using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;
using edges = vector<edge>;

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>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

constexpr ll LNF = 1LL<<60;

constexpr int INF = 1e9+7;

const double PI=3.14159265358979323846;


vector<int> dx = {-1,0,1,0,-1,1,-1,1};
vector<int> dy = {0,-1,0,1,1,-1,-1,1};

/* template */

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    int k = n%10;
    if(k==3){
        cout << "bon" << endl;
    } else if(k==0 || k== 1 || k == 6 || k==8){
        cout << "pon" << endl;
    } else{
        cout << "hon" << endl;
    }
} 

Measured memory_bytes: 3656
import java.util.Scanner;
public class Main {
  public static void main(String[] args){
    Scanner input = new Scanner (System.in);
    int a = input.nextInt();
    if (a >= 0 && a<=10){
      System.out.println(a + a * a + a * a * a);
    }else{
      return;
    }
  }
}


Measured memory_bytes: 35832
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdio>
#include <map>
#include <set>
#include <utility>
#include <vector>
#include <queue>
#include <cmath>
#define read(X) scanf("%d",&X);
#define readLL(X) cin>>X;
#define readN(N,a) for(int i=0;i<N;i++)scanf("%lld",&a[i]);
#define LL long long
#define FOR(x,a,b) for(int x=a;x<b;x++)
#define pii pair<int,int>
#define INF 3000000
using namespace std;


int main(){
int N;
int kagi=0;
read(N);
for (int i=0;i<N;i++){
int a;
read(a);
kagi += (a % 2);
}
if (kagi % 2) cout<<"NO"<<endl;
else cout<<"YES"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int a,b,c,d;
	int k1,k2;
	cin>>a>>b>>c>>d;
	k1=min(a,b);
	k2=min(c,d);
	cout<<k1+k2<<endl;
	
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a,b,c,d,ans=0;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  if(a<=b)ans+=a;
  else ans+=b;
  if(c<=d)ans+=c;
  else ans+=d;
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
A=input()
B=input()

if len(A)>len(B):
    print("GREATER")

elif len(A)<len(B):
    print("LESS")
else:
    for i in range(len(A)):
        if int(A[i])>int(B[i]):
            print("GREATER")
            exit()
        elif int(A[i])<int(B[i]):
            print("LESS")
            exit()
    print("EQUAL")

Measured memory_bytes: 3064
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#define N 2100
#define mmod 1000000007
using namespace std;
int n,m,k,f[N],g[N],ans;
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	f[0]=1;
	for(int i=1;;i++)
	{
		if((i-1)*(k-1)+k>n+m) break;
		int sum=(i-1)*(k-1),sa,sb;
		for(int j=0;j<=n;j++)
		{
			if(f[j]==0) continue;
			for(int a=1;a<k;a++)
			{
				sa=j+a;
				sb=sum-j+k-a;
				if(sa>n || sb>m || sb<0) continue;
				if((n-sa)%(k-1)==0 && (m-sb)%(k-1)==0) ans=(ans+f[j])%mmod;
			}
		}
		for(int j=0;j<=n;j++) g[j]=0;
		for(int j=0;j<=n;j++)
			for(int x=0;x<k;x++)
				g[j+x]=(g[j+x]+f[j])%mmod;
		for(int j=0;j<=n;j++) f[j]=g[j];
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
N=int(input())

list = []

def standard(n, cur):
  if n == 0:
    ##print(''.join(cur))
    add = ''.join(cur)
    if str(add).isnumeric() and add != "0":
        list.append(int(add))
  else:
    newC = chr(ord(cur[-1]) + 1)
    standard(n - 1, cur + [newC])
    newC2 = chr(ord(cur[-1]) - 1)
    standard(n - 1, cur + [newC2])
    newC3 = chr(ord(cur[-1]))
    standard(n - 1, cur + [newC3])

for i in range(10):
    for j in range(9):
        standard(i, [str(j+1)])

list = sorted(list)
print(list[N-1])

Measured memory_bytes: 12568
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 
 using namespace std;
 
 const double pi=3.14159265;
 
 int main()
 {
   int step,degree;
   double x,y;
   x=0;
   int count=0;
   double final_degree=0;
   char temp;
   while(cin>>step>>temp>>degree)
   {
     if(step==0&&degree==0) break;
     else
     {
       x=x+sin(final_degree/180*pi)*step;
       y=y+cos(final_degree/180*pi)*step;
       final_degree+=degree;
     }                        
   }
   printf("%d\n%d\n",(int)x,(int)y);
   //while(1);      
   return 0;    
 }
 
 

Measured memory_bytes: 3348
# coding: utf-8
# Your code here!
eki = str(input())
if eki[0] == "A" and eki[1] == "A" and eki[2] == "A":
    print("No")
elif eki[0] == "B" and eki[1] == "B" and eki[2] == "B":
    print("No")
else:
    print("Yes")


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

int main() {
  ll n, m;
  cin >> n >> m;
  if (n > m) swap(n, m);
  if (n == 1) {
    ll res = max(0ll, m - 2);
    if (m == 1) res = 1;
    printf("%lld\n", res);
  } else if (n == 2) {
    puts("0");
  } else {
    ll res = (n - 2) * (m - 2);
    printf("%lld\n", res);
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N;
    cin >> N;
    int A[N+1], B[N+1], C[N];
    for(int i=1; i<=N; i++) cin >> A[i];
    for(int i=1; i<=N; i++) cin >> B[i];
    for(int i=1; i<=N-1; i++) cin >> C[i];
    int sum=0;
    for(int i=1; i<=N; i++){
        sum=sum+B[A[i]];
        //cout << sum << endl;
        if(i!=1 && (A[i]-1)==A[i-1]) sum=sum+C[A[i-1]];
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
	cin>>a>>b;
	sort(b.begin(),b.end());
	reverse(b.begin(),b.end());
	sort(a.begin(),a.end());
	if(b>a)
		puts("Yes");
	else puts("No"); 
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <stack>
using namespace std;

int main() {
	stack<int> S;
	int a, b, x;
	string s;

	while (cin >> s) {
		if (s[0] == '+') {
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a + b);
		}
		else if (s[0] == '-') {
			b = S.top(); S.pop();
			a = S.top(); S.pop();
			S.push(a - b);
		}
		else if (s[0] == '*')  {
			a = S.top(); S.pop();
			b = S.top(); S.pop();
			S.push(a * b);
		}
		else {
			S.push(atoi(s.c_str()));
		}
	}

	cout << S.top() << endl;

	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define pii pair<int,int>
#define eb emplace_back
#define MOD 1000000007
#define int long long
using namespace std;
#define s second
#define f first

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    int k;
    if( n%1000 == 0 )
        k = n/1000;
    else 
        k = n/1000 + 1;
    int ans = k*1000 - n;
    cout << ans ;
}   

Measured memory_bytes: 3648
N=gets.to_i
es = {}
(N-1).times do
  a,b = gets.split.map(&:to_i)
  es[a] ||= []
  es[a] << b
  es[b] ||= []
  es[b] << a
end
cs = gets.split.map(&:to_i).sort
ret = cs[0..-2].inject(&:+)

arr = [0,cs.pop]
q = es[1]
until q.empty?
  n = q.shift
  next if arr[n]
  arr[n] = cs.pop
  q += es[n]
end

p ret
puts arr[1..-1].join(' ')


Measured memory_bytes: 96532
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;

int main(){
  int a,b;cin >> a >> b;
  int sum = 0;
  sum += max(a,b);
  if(a <= b) sum += max(a,b-1);
  else sum += max(a-1,b);
  cout << sum << endl;
  return 0;
}


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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    double N, M;
    cin >> N >> M;
    cout << N * (N - 1) / 2 + M * (M - 1) / 2 << endl;
    return 0;
}


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

int main()
{
    int n;
    vector<int> a;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int t;
        cin >> t;
        a.push_back(t);
    }
    for (int i = 0; i < n; i++) {
        cout << a[n - i - 1];
        if (i < n - 1) cout << " ";
        else cout << endl;
    }
}



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

int gcd(int a, int b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

int main()
{
    int i, j, n, k, a, b, c, sum = 0, num;
    cin >> k;

    for (i = 1; i < k + 1; i++)
    {
        a = i;
        for (j = 1; j < k + 1; j++)
        {
            b = j;
            for (n = 1; n < k + 1; n++)
            {
                c = n;
                num = gcd(a, b);
                sum += gcd(num, c);
            }
        }
    }
    cout << sum;
}


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

int main(){
    long a;
    cin >> a;
    long b;
    cin >> b;
    if(a < b){
        long c;
        c = b;
        b = a;
        a = c;
    }
    long x = a * b;
    
    long r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    long y = x / b;
    cout << y << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<list>
#include<functional>
#define mp make_pair
#define X first
#define Y second
#define INF 987654321
#define PI 3.14159265358979323846264
#define MOD 1000000007LL
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef complex<double> base;
ll POW(ll a, ll b) { if (b == 0)return 1; if (b == 1)return a; if (b & 1)return (a*POW(a, b - 1)) % MOD; ll t = POW(a, b / 2); return (t*t) % MOD; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[] = { 0,-1,1,0 }, dy[] = { 1,0,0,-1 };//동북남서
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };


int main() {
	int n, a, b;
	scanf("%d%d%d", &n, &a, &b);
	int t = (b - a) % 2;
	if (t == 0)puts("Alice");
	else puts("Borys");
}

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

using namespace std;

int m, n;
int main(){
    while(scanf("%d%d", &m, &n) && m && n){
        for(int i = 1; i <= m; ++i){
            for(int j = 1; j <= n; ++j){
                if(i == 1 || i == m || j == 1 || j == n) cout << "#";
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a + 3);
    cout << a[0] + a[1] << endl;
    return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    return a // gcd(a, b) * b


N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

lcm_ = 1
for i in range(N):
    lcm_ = lcm(lcm_, A[i])

ans = 0
for i in range(N):
    ans += lcm_ // A[i]

print(ans % mod)

Measured memory_bytes: 4084
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n);i>=(j);i--)
using ll=long long;
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; }
const ll INF=1LL<<60;

string s;

int main(){
    cin>>s;
    vector<int> cnt(3);
    rep(i,0,s.size()){
        if(s[i]=='a') cnt[0]++;
        else if(s[i]=='b') cnt[1]++;
        else cnt[2]++;
    }
    sort(cnt.begin(),cnt.end(),greater<int>());
    if(cnt[0]==cnt[1] && cnt[0]==cnt[2]) cout<<"YES"<<"\n";
    else if(cnt[0]==cnt[1] && cnt[0]-cnt[2]==1) cout<<"YES"<<"\n";
    else if(cnt[1]==cnt[2] && cnt[0]-cnt[1]==1) cout<<"YES"<<"\n";
    else cout<<"NO"<<"\n";
    return 0;
}


Measured memory_bytes: 3740
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define freopen freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#else
#define freopen //comment
#endif
#define io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define pb push_back
typedef tree<int, null_type,less<int>,  rb_tree_tag,tree_order_statistics_node_update>  ordered_set;
#define int long long int
#define endl "\n"
main()
{ 
// freopen
 io
 string s;
 cin>>s;
 int ans=0;
 for(int i=0;i<s.size();i++)
 {
   ans+=s[i]-'0';
 }
 if(ans%9)cout<<"No"<<endl;
 else cout<<"Yes"<<endl;

}


Measured memory_bytes: 3728
#include <stdio.h>
#include <stdlib.h>

#define N 100
#define infinity 1000000
#define white 2
#define gray 1
#define black 0

int prim(void);

int n, M[N][N];

int main(){
  int i, j, weight;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      scanf("%d", &M[i][j]);

      if(M[i][j] == -1)
	M[i][j] = infinity;
    }
    }

  weight = prim();
  
  printf("%d\n", weight);
  
  return 0;
}

int prim(){
  int i, col[N], comp[N], pa[N], cost, weight = 0, top;

  for(i = 0; i < n; i++){
    col[i] = white;
    comp[i] = infinity;
  }

  comp[0] = 0;
  pa[0] = -1;

  while(1){
    cost = infinity;

    for(i = 0; i < n; i++){
      if(col[i] != black && comp[i] < cost){
	cost = comp[i];
	top = i;
      }
    }

      if(cost == infinity)
	break;

      col[top] = black;
      
      for(i = 0; i < n; i++){
	if(col[i] != black && M[top][i] != infinity){
	  if(M[top][i] < comp[i]){
	    comp[i] = M[top][i];
	    pa[i] = top;
	    col[i] = gray;
	  }
	}
      }
  }
  
  for(i = 0; i < n; i++){
    if(pa[i] != -1)
      weight += M[i][pa[i]];
  }

  return weight;
}
  



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

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

int main() {
    string s, c;
    cin >> s;
    int n = s.length();
    int j = 0;
    int g = 0;
    int d = 0;
    rep(i,n){
        if(s[i] != 'A'){
            c += s[i];
        }
    }

    rep(i,n){
        if(s[i] == s[i+1]){
            j = 1;
        }
        if(s[i] == 'K' && s[i+1] != 'I'){
            g = 1;
        }
        if(s[i] == 'I' && s[i+1] != 'H'){
            d = 1;
        }
    }

    if(c == "KIHBR" && j < 5 && j == 0 && g == 0 && d == 0){
        cout << "YES";
        }else{
            cout << "NO";
        }
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int main(void){
	int i,j,k,ii,jj,n,rr[10][3],r,temp,flg;
	char t[11],ctm,tcopy[11];
	while(1){
		cin>>n;
		if(n==0)break;
		for(i=0;i<n;i++){
			cin>>t[i];
			tcopy[i]=t[i];
			rr[i][0]=0; rr[i][1]=0; rr[i][2]=0;
			for(j=0;j<n-1;j++){
				cin>>r;
				rr[i][r]++;
			}
		}
//		for(i=0;i<n;i++)printf("%c ??????%d?????????%d\n",t[i],rr[i][0],rr[i][1]);
		for(i=0;i<n-1;i++){
			for(j=i+1;j<n;j++){
				if(rr[i][0]<rr[j][0]){
					temp=rr[i][0];
					rr[i][0]=rr[j][0];
					rr[j][0]=temp;
					
					temp=rr[i][1];
					rr[i][1]=rr[j][1];
					rr[j][1]=temp;
					
					ctm=t[i];
					t[i]=t[j];
					t[j]=ctm;
				}
			}
		}
		for(i=0;i<n-1;i++){
			for(j=i+1;j<n;j++){
				if(rr[i][1]>rr[j][1]&&rr[i][0]==rr[j][0]){
					temp=rr[i][0];
					rr[i][0]=rr[j][0];
					rr[j][0]=temp;
					
					temp=rr[i][1];
					rr[i][1]=rr[j][1];
					rr[j][1]=temp;
					
					ctm=t[i];
					t[i]=t[j];
					t[j]=ctm;
				}
			}
		}
		for(i=0;i<n-1;i++){
			for(j=i+1;j<n;j++){
				if(rr[i][1]==rr[j][1]&&rr[i][0]==rr[j][0]){
					flg=0;
					for(k=0;k<n;k++){
						if(t[i]==tcopy[k])flg=1;
						if(t[j]==tcopy[k]&&flg==0){
							temp=rr[i][0];
							rr[i][0]=rr[j][0];
							rr[j][0]=temp;
							
							temp=rr[i][1];
							rr[i][1]=rr[j][1];
							rr[j][1]=temp;
							
							ctm=t[i];
							t[i]=t[j];
							t[j]=ctm;
							break;
						}
					}
				}
			}
		}
		for(i=0;i<n;i++) cout<<t[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 2976
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(':');
            var hh = int.Parse(line[0]);
            var mm = int.Parse(line[1]);
            var rm = mm * 6d;
            var rh = hh * 30d + mm / 2d;
            var res = Math.Abs(rh - rm);
            if (res > 180) { res -= 360; res = Math.Abs(res); }
            if (res >= 90 && res <= 180) Console.WriteLine("safe");
            else if (res >= 0 && res < 30) Console.WriteLine("alert");
            else Console.WriteLine("warning");
        }
    }
}

Measured memory_bytes: 8816
#include <iostream>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
#define int ll
ll n, m;
ll x[500000];
ll y[500000];
ll z[500000];
ll vis[500000];
vector<pair<int, int> > g[500000];
ll c1[500000];
ll c2[500000];
ll ok = 1;

void dfs1(int v, int value)
{
    //cout << v << " " << value << endl;
    if (c1[v] != 0 && c1[v] != value)
        ok = 0;
    if (c1[v] != 0)
        return;
    c1[v] = value;
    for (int i = 0; i < g[v].size(); i++)
    {
        ll res = value;
        if (g[v][i].second == 1)
            res = 3 - res;
        dfs1(g[v][i].first, res);
    }
}

void dfs2(int v, int value)
{
    if (c2[v] != 0 && c2[v] != value)
        ok = 0;
    if (c2[v] != 0)
        return;
    c2[v] = value;
    for (int i = 0; i < g[v].size(); i++)
    {
        ll res = value;
        if (g[v][i].second == 1)
            res = 3 - res;
        dfs2(g[v][i].first, res);
    }
}

signed main()
{
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> x[i] >> y[i] >> z[i];
        z[i] %= 2;
        g[x[i]].push_back({y[i], z[i]});
        g[y[i]].push_back({x[i], z[i]});
    }
    ll cnt = 0;
    for (int i = 1; i <= n; i++)
    {
        if (c1[i] == 0)
        {
            ok = 1;
            dfs1(i, 1);
            dfs2(i, 2);
            if (ok == 1)
                cnt++;
        }
    }
    cout << cnt;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> a[i][j];
        }
    }
    vector<vector<int>> b(h, vector<int>(w));
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> b[i][j];
        }
    }
    int mid = 12800; // 80 * 2 * 80
    vector<vector<bitset<25600>>> dp(h, vector<bitset<25600>>(w, bitset<25600>(0)));
    int shift          = abs(a[0][0] - b[0][0]);
    bitset<25600> init = 0;
    init[mid]          = 1;
    dp[0][0] |= init << shift;
    dp[0][0] |= init >> shift;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            if (i + 1 < h) {
                int shift = abs(a[i + 1][j] - b[i + 1][j]);
                dp[i + 1][j] |= dp[i][j] << shift;
                dp[i + 1][j] |= dp[i][j] >> shift;
            }
            if (j + 1 < w) {
                int shift = abs(a[i][j + 1] - b[i][j + 1]);
                dp[i][j + 1] |= dp[i][j] << shift;
                dp[i][j + 1] |= dp[i][j] >> shift;
            }
        }
    }
    int ret = 1e8;
    for (int i = 0; i < 25600; ++i) {
        if (dp[h - 1][w - 1][i] == 1)
            chmin(ret, abs(i - mid));
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 20736
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		n = sc.nextInt();

		for(int i=0;i<n;i++){
			int[] num = new int[3];
			for(int j=0;j<3;j++){
				num[j] = sc.nextInt();
			}
			Arrays.sort(num);
			if(num[0]*num[0]+num[1]*num[1]==num[2]*num[2]){
				System.out.println("YES");
			}else{
				System.out.println("NO");
			}
		}
	}

}

Measured memory_bytes: 23376
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vv vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int> >
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define INF 1000000000
#define eps 1e-7
#define mod 1000000007
#define int ll
using namespace std;

int N;
vi C;
map<int, vi> I; //I[終点]→始点
int dp[2*100000+10];

signed main(void) {
    cin >> N;
    rep(i, N) {
        int c; cin >> c;
        if (C.size()==0) C.pb(c);
        else if (C[C.size()-1] != c) C.pb(c);
    }
    map<int, int> start;
    rep(i, C.size()) {
        if (start[C[i]] == 0) { //未出現
            start[C[i]] = i+1;
        } else { //出現済→区間を登録
//            cout << "i+1:" <<i+1<< endl;
//            cout << "start[C" << i << "]=" << start[C[i]] << endl;
            I[i].pb(start[C[i]]);
            start[C[i]] = i+1;
        }
    }
//    for (auto itr=I.begin(); itr!=I.end(); ++itr) {
//        cout << "!!" << itr->fi << endl;
//        for (auto e2:itr->se) {
//            cout << e2 << endl;
//        }
//    }
    REP(i, 0, C.size()) dp[i]=0;
    dp[0] = 1;
    dp[1] = 1;
    REP(i, 2, C.size()) {
        if (I[i].size()>0) { //iで終了する区間が存在
            for (auto s : I[i]) {
                dp[i] += dp[s-1];
                dp[i] %= mod;
            }
        }
        dp[i] += dp[i-1];
        dp[i] %= mod;
    }
//    REP(i, 0, C.size()) {
//        cout << "dp[" << i << "]=" << dp[i] << endl;
//    }
    cout << (dp[C.size()] % mod) << endl;
    return 0;
}

Measured memory_bytes: 31472
#include <iostream>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <tuple>
#include <queue>
using namespace std;

typedef long long ll;

#define INF 100000000;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define eps 1.0e-14;
#define mod 1e9 + 7;

int main(){
	int x,y; cin >> x >> y;
	string ans = "No";
	rep(i,x){
		y -= 2;
	}
	if (y < 0){
		cout << ans << endl;
	}else if (y == 0){
		cout << "Yes" << endl;
		return 0;
	}
	else {
		rep(i,x){
			y -= 2;
			if(y == 0){
				cout << "Yes" << endl;
				return 0;
			}
		}
		cout << ans << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
#define int long long
signed main(){
    int a,b;
    char o;
    cin>>a>>o>>b;
    if(o=='+')cout<<a+b<<endl;
    else cout<<a-b<<endl;
    return 0;
}





Measured memory_bytes: 256
#include <iostream>
#define  NMAX 100001
using namespace std;


int main(){
	int n, count;
	int a[NMAX];
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i];
	}
	count = 0;
	for (int i = 1; i <= n; ++i)
	{
		if (a[a[i]] == i){
			count++;
		}
	}
	cout << count/2 << endl;

}


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

int main() {
  int N,M,k,s;
  vector<int> S[10];
  int P[10];
  cin >> N >> M;
  rep(i, M) {
    cin >> k;
    rep(j, k) {
      cin >> s;
      S[i].push_back(--s);
    }
  }
  rep(i,M) {
    cin >> P[i];
  }

  int ans = 0;
  rep(i, (1 << N)) {
    bool flag=true;
    rep(j, M) {
      int sum = 0;
      rep(k, S[j].size()) {
        if(i & (1 << S[j][k])) sum++;
      }
      if(sum%2 != P[j]) flag=false;
    }
    if(flag) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

#define LL long long

int flags[3] = {1, 2, 4};
inline LL getUtility(LL data[], int IsABS){
    LL ans = 0;
    for(int i = 0; i < 3; i++){
        ans += ((IsABS & flags[i]) >= 1 ? -data[i] : data[i]);
    }
    return ans;
}


int main(){
    int n, m; cin >> n >> m;
    LL data[1000][3] = {0};

    LL scores[8][1000] = {0};
    // LL scores000[1000] = {0};
    // LL scores001[1000] = {0};
    // LL scores010[1000] = {0};
    // LL scores011[1000] = {0};
    // LL scores100[1000] = {0};
    // LL scores101[1000] = {0};
    // LL scores110[1000] = {0};
    // LL scores111[1000] = {0};

    for(int i = 0; i < n; i++){
        LL inputs[3] = {0};
        cin >> inputs[0] >> inputs[1] >> inputs[2];

        for(int j = 0; j < 8; j++){
            scores[j][i] = getUtility(inputs, j);
        }
    }

    for(int i = 0; i < 8; i++){
        sort(scores[i], scores[i] + n, greater<LL>());
    }

    LL ans = 0;
    for(int i = 0; i < 8; i++){
        LL temp = 0;
        for(int j = 0; j < m; j++){
            temp += scores[i][j];
        }
        ans = max(ans, temp);
    }
    cout << ans << endl;
}

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

using namespace std;


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

  vector< pair<int64_t, int64_t> > v(N);

  for(int64_t i = 0; i < N; i++) {
    cin >> v[i].first >> v[i].second;
  }

  pair<int64_t, int64_t> current = v[0];

  for(int64_t i = 1; i < N; i++) {
    int64_t mul = max((current.first + v[i].first - 1) / v[i].first, (current.second + v[i].second - 1) / v[i].second);
    mul = max((int64_t)1, mul);
    current.first = mul * v[i].first;
    current.second = mul * v[i].second;
  }

  cout << current.first + current.second << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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; }

__attribute__ ((constructor))
void init() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}

signed main(){
  int r;
  cin >> r;
  cout << 3 * r * r << endl;
  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ll  long long
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

int main(){

    string s;

    cin >>s;
    int n = s.length();
   // cout << n<< endl;
    for(int i =0;i<(n-1)/2;i++){

        if(s[i]!=s[((n-3)/2)-i]){
            cout << "No";
            return 0;
        }
    }

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

        if(s[i]!=s[((3*n)-1)/2-i]){
            cout << "No";
            return 0;
        }
    }

    for(int i=0;i<(n-1)/2;i++){

        if(s[i]!=s[n-1-i]){
            cout << "No";
            return 0;
        }
    }

    cout << "Yes";
}




Measured memory_bytes: 256
#include <iostream>
#include <map>
#define MOD 1000000007
using namespace std;

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

ll H;
#define MAXN 10000000000
ll num = 0;
/*map<ll,ll> Ma;
ll count(ll a){//この数を返す
    if(Ma.find(a) != Ma.end())return Ma[a];
    Ma[a] = count(a/2)*2+1;
    return Ma[a];
}*/

int main(){
    cin >> H;
    int num = 0;
    ll counter = 0;
    ll co = 1;
    while(true){
        if(co > H)break;
        num++;
        counter += co;
        co *= 2;
    }

    cout << counter << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int n, j, s[4] = { 0 }, cnt = 0;
	char box;

	cin >> n;

	for (int i = 0; i < n; i++){
		cin >> box;

		switch (box){
		case 'P': s[0]++; break;
		case 'W': s[1]++; break;
		case 'G': s[2]++; break;
		case 'Y': s[3]++; break;
		}
	}

	for (int i = 0; i < 4; i++)
		if (s[i] != 0)
			cnt++;

	if (cnt == 3)
		cout << "Three" << endl;
	else
		cout << "Four" << endl;

	return 0;
}

Measured memory_bytes: 256
//ALDS1_2_D_19140837_Ojima_Yukiya.cpp
//
//提出日 2020/07/01 wednesday
//
//プログラミング基礎演習2 CS 第8回課題 ALDS1_2_D
//
//学修番号 19140837　小島優希也

#include <iostream>
#include <vector>
#include <math.h>
using namespace std;

void display(vector<int> v) {
    for (int i = 0; i < v.size(); i++) {
        cout << v.at(i) << endl;
    }
}

void insertionsort(vector<int>& a, int g, int &cnt) {
    for (int i = g; i < a.size(); i++) {
        int v = a.at(i);
        int j = i - g;
        while (j >= 0 && a.at(j) > v) {
            a.at(j + g) = a.at(j);
            j -= g;
            cnt++;
        }
        a.at(j + g) = v;
    }
}

void shellsort(vector<int> a) {
    int cnt = 0;
    int m = 0;

    vector<int> G;
    int p = 1;
    int sum = 0;
    while (true) {
        sum = sum + p;
        p = p*3;
        if (sum <= a.size()) {
            G.push_back(sum);
            m++;
        }
        else {
            break;
        }
    }

    cout << m << endl;
    for (int i = m - 1; i >= 1; i--) {
        cout << G.at(i) << " ";
    }
    cout << G.at(0) << endl;

    for (int i = m - 1; i >= 0; i--) {
        insertionsort(a, G.at(i), cnt);
    }

    cout << cnt << endl;
    display(a);
}

int main(void) {
    vector<int> vec;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        int value;
        cin >> value;
        vec.push_back(value);
    }
    shellsort(vec);
    return 0;
}


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

using namespace std;

int main(){
	
	int i;
	char senha[5];
	scanf("%s", senha);
	for (i = 0; i < 3; ++i){
		if (senha[i] == senha[i + 1]){
			printf("Bad\n");
			return 0;
		}
	}
	printf("Good\n");
	return 0;
}

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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;
ll a, b, c, d;

unordered_map<ll, ll> m(20000);

ll get(ll n){
	if (n == 0) return 0LL;
	if (n == 1) return d;

	if (m.count(n)) return m[n];

	ll ans = 2e18;
	if (ans / d >= n) ans = n * d;

	ans = min(ans, get(n / 2) + a + (n % 2) * d);
	ans = min(ans, get((n + 1) / 2) + a + (2 - n % 2) * d);

	ans = min(ans, get(n / 3) + b + (n % 3) * d);
	ans = min(ans, get((n + 2) / 3) + b + (3 - n % 3) * d);

	ans = min(ans, get(n / 5) + c + (n % 5) * d);
	ans = min(ans, get((n + 4) / 5) + c + (5 - n % 5) * d);

	m[n] = ans;

	return ans;
}

void solve(){
	ll n;
	cin >> n >> a >> b >> c >> d;

	m.clear();
	cout << get(n) << '\n';
}

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

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

	int Q;
	cin >> Q;
	while (Q--) solve();

    return 0;
}


Measured memory_bytes: 4100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int P = sc.nextInt();
		sc.close();
		
		int p_ex=A*3;
		
		
		System.out.println((p_ex+P)/2);

	}

}


Measured memory_bytes: 21844
a, b, c = map(int, input().split())

if a == 5 and b == 5 or a == 5 and c == 5 or b == 5 and c == 5:
    if a == 7 or b == 7 or c ==7:
        print("YES")
    else:
        print("NO")
else:
    print("NO")

Measured memory_bytes: 3060
n,m,*L=map(int,open(0).read().split())
a=L[:n];b=L[n:]
if n//2+m<n-1:
	print('Impossible')
	exit()
if n-1==m:
	print(0)
	exit()
con=[[] for _ in range(n)]
vis=[0]*n
for x,y in zip(*[iter(b)]*2):
	con[x].append(y)
	con[y].append(x)
least=[]
rest=[]
cnt=0
for i in range(n):
	if not vis[i]:
		cnt+=1
		q=[i]
		es=[a[i]]
		vis[i]=1
		while q:
			cur=q.pop()
			for nxt in con[cur]:
				if not vis[nxt]:
					q.append(nxt)
					es.append(a[nxt])
					vis[nxt]=1
		mi=min(es)
		es.remove(mi)
		least.append(mi)
		rest+=es
# print(least,rest)
print(sum(least+sorted(rest)[:2*(n-1-m)-cnt]))

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

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  ll ans = 1;
  vector<int> x(3);
  for (int i = 0; i < n; ++i) {
    int cnt = 0;
    for (int j = 0; j < 3; ++j) {
      if (a[i] == x[j]) {
        cnt++;
      }
    }
    ans = (ans * cnt) % MOD;
    for (int j = 0; j < 3; ++j) {
      if (a[i] == x[j]) {
        x[j]++;
        break;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
import itertools
N,M=map(int,input().split())
path=[tuple(map(int,input().split())) for _ in range(M)]
cnt=0
for li in itertools.permutations([k for k in range(2,N+1)],N-1):
    flag=True
    li=list(li)
    li.insert(0,1)
    for i in range(N-1):
        if (li[i],li[i+1]) not in path and (li[i+1],li[i]) not in path:
            flag=False
    if flag:
        cnt+=1
print(cnt)

Measured memory_bytes: 3064
k, n = map(int, input().split(" "))
aL = list(map(int, input().split(" ")))

ma = 0
for i in range(len(aL)):
    if i == len(aL) - 1:
        ma = max(abs(k - aL[i] + aL[0]), ma)
    else:
        ma = max(abs(aL[i] - aL[i + 1]), ma)

print(k - ma)

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define PB push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

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

	ll n; cin >> n;

	ll p26 = 26;

	int cnt = 1;
	while(n > p26){
		n-=p26;
		cnt++;
		p26*=26;
	}

	string ans;

	n--;

	while(n){
		ans.PB('a'+n%26);
		n/=26;
	}

	while((int) ans.size() < cnt)
		ans.PB('a');

	reverse(all(ans));

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3648
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double m = r * r * pi;
        double s = 2 * r * pi;
        System.out.printf("%.6f %.6f%n",m,s);
    }
}


Measured memory_bytes: 28216
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> capital(26);
  for(int i=0; i<N; i++){
    string S;
    cin >> S;
    int x = S.at(0) - 'A';
    capital.at(x)++;
  }
  int cnt = 0;
  while(N >= K){
    sort(capital.rbegin(),capital.rend());
    bool flag = true;
    for(int i=0; i<K; i++){
      if(capital.at(i) > 0){
        capital.at(i)--;
        N--;
      }
      else{
        flag = false;
        N = 0;
      }
    }
    if(flag){
      cnt++;
    }
  }
  cout << cnt << endl; 
}
  

Measured memory_bytes: 256