akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
  int n;
  double d;
  cin >> n >> d;
  vector<double> x(n);
  vector<double> y(n);
  for(int i = 0; i < n; i++){
    cin >> x[i] >> y[i];
  }
  
  int count = 0;
  
  for(int i = 0; i < n; i++){
    if(abs(sqrt(x[i] * x[i] + y[i] * y[i])) <= d)
      count++;
  }
  
  printf("%d", count);
}

int main()
{
  std::cout << std::fixed << std::setprecision(15);
  Main();
}



Measured memory_bytes: 6484
n, y = map(int, input().split())
for i in range(n + 1):
    for j in range(n - i + 1):
        if i * 10000 + j * 5000 + (n - i - j) * 1000 == y:
            print(i, j, n - i - j)
            exit()
print("-1 -1 -1")

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

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


int main(){

  ll a,b,c,d;
  cin >> a >> b >> c >> d;
  while(1){
    c -= b;
    if(c <= 0){
      cout << "Yes" << endl;
      return 0;
    }

    a -= d;
    if(a <= 0){
      cout << "No" << endl;
      return 0;
    }

  }


  return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
using PL = pair<ll , ll> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007
 
int main(){
    int n, k ;
    cin >> n >> k ;
    vector<ll> a (n) ;
    ll ans = INF ;
    if(k == 1){
        cout << 0 << endl ;
        return 0 ;
    }
    rep(i, n) cin>> a[i] ;
    rep(i, 1 << n){
        int cnt = 0 ;
        rep(j, n){
            if(i >> j & 1){
                cnt++ ;
            }
        }
        if(cnt < k || !(i >> 0 & 1)) {
            continue ;
        }
        ll pos = 0 ;
        ll mx = a[0] ;
        rep(j, n){
            if(j == 0) {
                continue ;
            }
            if(i >> j & 1){
                if(mx >= a[j]){
                    pos += (mx - a[j]) + 1 ;
                    mx++ ;
                }
            }
            mx = max(mx, a[j]) ;
        }
        ans = min(pos, ans) ;
    }
    cout << ans << endl ;
}

Measured memory_bytes: 3612
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		int[] Nlist = new int[N];
		for(int i=0;i<K;i++) {
			int A  = scan.nextInt();
			for(int j = 0;j<A;j++) {
				int tmp = scan.nextInt();
				Nlist[tmp-1]++;
			}
		}
		scan.close();

		int num = 0;

		for(int sum:Nlist) {
			if(sum==0) {
				num++;
			}
		}
		System.out.println(num);

	}
}

Measured memory_bytes: 46424
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define fr(i,a,b) for(int i=a;i<b;i++)
#define frn(i,a,b) for(int i=a;i>=b;i--)
#define vi vector<int>
#define pii pair<int,int>
#define vpi vector<pair<int,int>>
#define vvi vector<vector<int>>
#define test int t;cin>>t; while(t--)
#define mp make_pair
#define pb push_back
#define pu push
#define fi first
#define se second
#define mod 1000000007
typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update> seti;
void fast() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
int n;
map<int,set<int>> g;
map<int,bool> vis;
int r;
void dfs(int i,int p){
    vis[i] = true;
    r++;
    for(auto x:g[i]){
        if(x!=p && !vis[x]){
            dfs(x,i);
        }
    }
}

int32_t main(){
  //  fast();
    cin>>n;
    int m;
    cin>>m;
    int a,b;
    fr(i,1,n+1) vis[i] = false;
    fr(i,0,m){
        cin>>a>>b;
        g[a].insert(b);
        g[b].insert(a);
    }
    int ans = 1;
    fr(i,1,n+1){
        if(!vis[i]){
            r = 0;
            dfs(i,0);
            ans = max(r,ans);
        }
    }
    cout<<ans;
    return 0;
}

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

int main(){
	string s;
	cin >> s;
	
	if(s.size() % 2 == 1){
		cout << "No" << endl;
		return 0;
	}
	
	bool ok = true;
	
	rep(i,s.size()){
		//偶数番目は必ずhになる
		if(i%2==0){
			if(s[i] != 'h') ok = false;
		}
		if(i%2==1){
			if(s[i] != 'i') ok = false;
		}
	}
	
	if(ok) {
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

int main(){
    string sa,sb,sc;
    cin>>sa>>sb>>sc;
    ll a=0,b=0,c=0;
    char turn = sa.at(0);
    a++;
    while(true){
        if(turn == 'a'){
            if(a!=sa.size()){
                turn = sa.at(a);
                a++;
            }
            else {
                a++;
                break;
            }
        }else if(turn == 'b'){
            if(b!=sb.size()){
                turn = sb.at(b);
                b++;
            }
            else {
                b++;
                break;
            }
        }else if(turn == 'c'){
            if(c!=sc.size()){
                turn = sc.at(c);
                c++;
            }
            else {
                c++;
                break;
            }
        }
    }
    if(a==sa.size()+1) {
        cout<<"A"<<endl;
        return 0;
    }
    else if(b==sb.size()+1) {
        cout<<"B"<<endl;
        return 0;
    }
    else if(c==sc.size()+1) {
        cout<<"C"<<endl;
        return 0;
    }
}


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

int main(){
  int n;cin >> n;
  int t;
  bool ans = false;
  if(n==2){
    t = 2;
  }else{
  for(int i=n;!ans;i++){
    t = i;
    for(int j=2;j<n;j++){
      ans = true;
      if(i%j==0){
        ans = false;
        break;
      }
    }
  }
  }
  cout << t << endl;
}

Measured memory_bytes: 256
#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; }

const int NIL = -1;
const long long INF = 1LL << 60;
const long long MOD = 1e9+7;
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int N;
vector<vector<pair<int, int>>> A;

bool solve(int bit) {
  for (int i = 0; i < N; ++i) {
    if (!(bit & (1<<i))) continue;
    for (int j = 0; j < A[i].size(); ++j) {
      if (A[i][j].second == 0 && (bit & (1<<A[i][j].first))) return false;
      if (A[i][j].second == 1 && (!(bit & (1<<A[i][j].first)))) return false;
    }
  }
  return true;
}

int main() {
  cin >> N;
  A.resize(N);
  for (int i = 0; i < N; ++i) {
    int a; cin >> a;
    A[i].resize(a);
    for (int j = 0; j < a; ++j) {
      int x, y;
      cin >> x >> y; x--;
      A[i][j].first = x;
      A[i][j].second = y;
    }
  }
  int ans = 0;
  for (int bit = 0; bit < (1<<N); ++bit) {
    if (solve(bit)) {
      int cnt = 0;
      for (int i = 0; i < N; ++i) {
        if (bit & (1<<i)) cnt++;
      }
      ans = max(cnt, ans);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(i64 i = 0; i < N; i++)
#define Rep(i, k, N) for(i64 i = k; i < N; i++)
#define all(v) v.begin(), v.end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}

int main(){
    int N, K;
    cin >> N >> K;
    
    vector<int> snuke(N, 0);
    rep(i, K){
        int d; 
        cin >> d;
        rep(i, d) {
            int A;
            cin >> A;
            snuke[A-1]++;
        }
    }

    int ans = 0;
    for(auto& c : snuke) ans += (c == 0);

    Cout(ans);
}


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

int main() {
  int n, a;
  cin >> n;
  int count = 0;
  int max = 0;
  for(int i=0; i<n; i++) {
    cin >> a;
    if(max <= a) {
      count++;
      max = a;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define REP(a, b) for(int a = 0; a < b; a++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define mp make_pair
#define f first
#define s second
#define pb push_back
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> LL;
typedef vector<int> vi;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 100;

int DP[MAXN];
int n, k;
int A[MAXN];

int rek(int now) {
	if (now == 0) return false;
	int &ret = DP[now];
	if (ret != -1) return ret;
	ret = false;
	REP(i, n) {
		if (now >= A[i] && rek(now - A[i]) == false) return ret = true;
	}
	return ret;
}

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n >> k;
	REP(i, n) cin >> A[i];
	memset(DP, -1, sizeof DP);
	if (rek(k)) cout << "First\n";
	else cout << "Second\n";
}

Measured memory_bytes: 5376
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	while(1)
	{
		vector<int> vec;
		int n;
		cin >> n;
		if(n==0)break;
		while(1)
		{
			vec.pb(n%8);
			if(n<8)break;
			n/=8;
		}
		reverse(vec.begin(),vec.end());
		for(int i=0;i<vec.size();i++)
		{
			if(vec[i]==4)
			{
				vec[i]++;
			}
			else if(vec[i]==5||vec[i]==6||vec[i]==7)
			{
				vec[i]+=2;
			}
		}
		for(int i=0;i<vec.size();i++)
		{
			cout << vec[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)n; i++)
#define MOD 1000000009
using namespace std;
typedef long long ll;
int main()
{
  ll a;
  cin >> a ;
  ll b;
  b = sqrt(a);
  ll c = 0;
  if(b * b == a){
    cout << 2*(b - 1) << endl;
    return 0;
  }else{
    for(ll i = 0; i < b; i ++){
      c = b - i;
      if(a%c == 0){
	cout << (c - 1) + (a/c - 1) <<endl;
	return 0;
      }
    }
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX 10000003
using namespace std;
ll count(ll arr[][3], ll n, ll i, ll c, vector<vector<ll>> &dp)
{
    if(i>=n) return 0;
    if(dp[i][c]!=-1) return dp[i][c];
    if(c==0)  return dp[i][c]=max(arr[i][1]+count(arr,n,i+1,1,dp),arr[i][2]+count(arr,n,i+1,2,dp));
    else if(c==1)  return dp[i][c]=max(arr[i][0]+count(arr,n,i+1,0,dp),arr[i][2]+count(arr,n,i+1,2,dp));
    else if(c==2) return dp[i][c]=max(arr[i][1]+count(arr,n,i+1,1,dp),arr[i][0]+count(arr,n,i+1,0,dp));
    ll x=arr[i][0]+count(arr,n,i+1,0,dp);
    ll y=arr[i][1]+count(arr,n,i+1,1,dp);
    ll z=arr[i][2]+count(arr,n,i+1,2,dp);
    return dp[i][c]=max(x,max(y,z));
}
void solve()
{
    ll n;  cin>>n;
    ll arr[n][3];
    vector<vector<ll>> dp(n+1,vector<ll>(3,-1));
    rep(i,0,n)  cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
    cout<<count(arr,n,0,4,dp);
}
int main()
{
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    return 0;
}

Measured memory_bytes: 20320
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    long long a,b;
    cin >>a>>b;
    // if(a%2==0 && b%2==0){
    //     cout <<(a*b)/2;
    // }
    if (a==1 || b==1) {
        cout <<1;
        return 0;
    }
    if (((a*b)%2)==0){
        cout << fixed;
        cout <<(a*b)/2;
    }
    else {
        cout << fixed;
        cout <<((((a*b)/2))+1);
    }
    
    
}

Measured memory_bytes: 256
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val (x, y) = listOfInt()
    val aList = listOf(1, 3, 5, 7, 8, 10, 12)
    val bList = listOf(4, 6, 9, 11)

    if ((x in aList && y in aList) || (x in bList && y in bList)) {
        println("Yes")
    } else {
        println("No")
    }
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 36100
n = int(input())
l = list(map(int, input().split()))
l.sort()
ans = 0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if l[i]+l[j]>l[k] and l[i]!=l[j] and l[j]!=l[k]:
                ans+=1
print(ans)

Measured memory_bytes: 9100
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	int n;
	cin>>n;
	vector<int> vect(n);
	for(int i=0; i<n;i++)
		cin>>vect[i];
	ll minPos = INT_MAX;
	for(int i=1;i<=100;i++)
	{
		ll total = 0;
		for(int j=0; j<n;j++)
		{
			total = total + (i-vect[j])*(i-vect[j]);
		}
		minPos = min(minPos, total);
	}
	cout<<minPos<<"\n";
}

Measured memory_bytes: 256
n,k=map(int,input().split())
lst=list(map(int,input().split()))
ans=0
for i in range(n):
    judge=lst[i]
    front=lst[:i]
    back=lst[i+1:]
    former=0
    latter=0
    for j in front:
        if j>judge:
            former+=1
    for j in back:
        if j>judge:
            latter+=1
    ans+=(former*((k+1)*k//2)+latter*((k-1)*k//2))
    ans%=(10**9+7)
print(ans)

Measured memory_bytes: 74000
#include<bits/stdc++.h>
#define maxn 530005
#define rep(i,j,k) for(int i=(j),lim=(k);i<=lim;i++)
#define Clear(a,l,r) memset(a+(l),0,((r)-(l)+1)*(sizeof a[0]))
using namespace std;
const int mod = 924844033, inv2 = (mod+1)/2;
int w[maxn],WL,r[maxn],lg[maxn],inv[maxn],fac[maxn],invf[maxn];
int Pow(int a,int b){int s=1;for(;b;b>>=1,a=1ll*a*a%mod) b&1&&(s=1ll*s*a%mod); return s;}
void init(int n){
	w[0]=WL=inv[0]=inv[1]=fac[0]=fac[1]=invf[0]=invf[1]=1;
	while(WL<=n) WL<<=1; w[1]=Pow(5,(mod-1)/WL);
	for(int i=2;i<=WL;i++) w[i]=1ll*w[i-1]*w[1]%mod,lg[i]=lg[i>>1]+1;
	for(int i=2;i<=WL;i++) fac[i]=1ll*fac[i-1]*i%mod,inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod,invf[i]=1ll*invf[i-1]*inv[i]%mod;
}
int upd(int x){return x+(x>>31&mod);}
void NTT(int *a,int len,int flg){
	for(int i=0;i<len;i++) if(i<(r[i]=r[i>>1]>>1|(i&1?len>>1:0))) swap(a[i],a[r[i]]);
	for(int i=2,l=1,v;i<=len;l=i,i<<=1) for(int j=0,t=WL/i;j<len;j+=i) for(int k=j,o=0;k<j+l;k++,o+=t)
		a[k+l]=upd(a[k]-(v=1ll*w[flg^1?WL-o:o]*a[k+l]%mod)),a[k]=upd(a[k]+v-mod);
	if(flg^1) for(int i=0,Inv=mod-(mod-1)/len;i<len;i++) a[i]=1ll*a[i]*Inv%mod;
}
int n,siz[maxn],A[maxn],B[maxn];
vector<int>G[maxn];
void dfs(int u,int ff){siz[u]=1; for(int v:G[u]) if(v!=ff) dfs(v,u),siz[u]+=siz[v];}
int main()
{
	scanf("%d",&n),init(2*n);
	for(int i=1,x,y;i<n;i++) scanf("%d%d",&x,&y),G[x].push_back(y),G[y].push_back(x);
	dfs(1,0);
	for(int i=2;i<=n;i++) A[siz[i]]++,A[n-siz[i]]++;
	for(int i=0;i<n;i++) A[i]=1ll*A[i]*fac[i]%mod,B[i]=invf[n-1-i];
	NTT(A,WL,1),NTT(B,WL,1);
	for(int i=0;i<WL;i++) A[i]=1ll*A[i]*B[i]%mod;
	NTT(A,WL,-1);
	for(int i=1;i<=n;i++)
		printf("%d\n",upd(1ll*n*fac[n]%mod*invf[i]%mod*invf[n-i]%mod-1ll*A[n-1+i]*invf[i]%mod));
}

Measured memory_bytes: 52876
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int inf = 0x3f3f3f3f,oo = inf;
#define IL inline
#define RG register
#define rep(i,a,b) for(RG int i=(a);i<(b);++i)
#define Rep(i,a,b) for(RG int i=(a);i<=(b);++i)
#define Dep(i,a,b) for(RG int i=(a);i>=(b);--i)
#define pc putchar
#define gc getchar
IL ll read(){
    RG ll x=0;char f=0;RG char c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return f?-x:x;
}
IL double readdb(){
    RG double x=0,p=0.1;RG char f=0,c=gc();
    for(;!isdigit(c);c=gc())f|=(c=='-');
    for(;isdigit(c);c=gc())x=x*10+(c^48);
    if(c=='.')for(c=gc();isdigit(c);c=gc(),p/=10)x=x+(c^48)*p;
    return f?-x:x;
}
IL void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);pc(x%10+'0');}
IL void writeln(ll x){write(x);puts("");}
IL void writeln(ll x,char c,ll y){write(x);pc(c);writeln(y);}
IL void writeln(ll x,char c,ll y,char d,ll z){write(x);pc(c);write(y);pc(d);writeln(z);}
#define debug(x) printf(#x" = %d\n",x);
#define rd() read()
#define rdb() readdb()
#define mem(x,v) memset(x,v,sizeof(x))
#define pb push_back
#define Mk make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define fin(x) freopen(#x".in","r",stdin)
#define fout(x) freopen(#x".out","w",stdout)
#define y1 ____y1
#define hash __hash
#define union _union
const ll N=200010;
ll a[N],del[N],q[N],First[N],Resulit,answ,top,n,Left=0;
int main(){
	n=read();
	Rep(i,1,n)a[i]=read();
	Rep(i,1,n)if (i-a[i]<=0){puts("-1");return 0;}
	Dep(i,n,1){
		while((Left<top)&&(q[Left+1]>=i)){
			++Left;
		} 
		while(top&&(q[top]>=i))--top;
		Left=min(Left,top);
		if ((Left<top)&&Left+1<First[i]){
			{puts("-1");return 0;}
		}
		if (!a[i]){
			if (top){
				puts("-1");
				return 0;
			}
		}
		else if (!top||(q[top]!=i-a[i])){
			q[++top]=i-a[i];
			del[i-a[i]]++;
			++Resulit;
			First[i-a[i]] = max(First[i-a[i]],top);
		}
		Resulit-=del[i];		answ+=Resulit;
	}writeln(answ);
}


/*

n-2 XXXX n-1 X X n-2 X n

8
6 3 1 2 7 4 8 5

给你一棵树，你可以进行若干次（无穷多）操作，
每次可以新建一个点和树上的一个点连边
然后把这个树染色
使得所有颜色相同的节点对(u,v)
满足以u为根和以v为根这两棵树是同构的（正常的同构，和颜色无关（好像是））。 
问最小的颜色数，和在最小颜色数前提下最小的树的叶子节点数 
*/ 




/*


X 0 1 1 2 3 4
+1 +1 +1 +1 +2 +1 +1
0 1 1 0 1 2 2 1 2

0 1 2 3 4
*/

Measured memory_bytes: 6528
N=gets.to_i
a=gets.split.map(&:to_i)
a4,a=a.partition{|i|i%4==0}
a2,a=a.partition{|i|i%2==0}
#warn a4.inspect
#warn a2.inspect
#warn a.inspect
a4 = a4.size
a = a.size
if a2.size > 0
    a+=1
end
if a4 >= a - 1
    puts "Yes"
else
    puts "No"
end


Measured memory_bytes: 22436
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <stack>
using namespace std;

int main(){
	int r,c,n;
	cin >> r >> c >> n;
	vector<pair<int,int> > p;
	for(int i=0; i<n; i++){
		int x[2], y[2];
		cin >> x[0] >> y[0] >> x[1] >> y[1];
		int dist[2] = {-1,-1};
		for(int j=0; j<2; j++){
			if(y[j]==0){
				dist[j] = x[j];
			}else if(x[j]==r){
				dist[j] = r +y[j];
			}else if(y[j]==c){
				dist[j] = r+c +(r-x[j]);
			}else if(x[j]==0){
				dist[j] = r+c+r +(c-y[j]);
			}
		}
		if(dist[0]!=-1 && dist[1]!=-1){
			p.push_back(make_pair(dist[0], i));
			p.push_back(make_pair(dist[1], i));
		}
	}
	sort(p.begin(), p.end());
	
	stack<int> st;
	for(int i=0; i<(int)p.size(); i++){
		if(st.empty() || st.top()!=p[i].second){
			st.push(p[i].second);
		}else{
			st.pop();
		}
	}
	if(st.empty()){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 2420
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

int max(int a, int b){
  return a >= b ? a : b;
}
int min(int a, int b){
  return b >= a ? a : b;
}
int sei(int a){
  return a>0 ? a : 0;
}
int factorial(int n) {
    if (n > 0) return n*factorial(n - 1);
		else return 1;
}
int compare_up_int(const void *a, const void *b){
   return *(int*)a - *(int*)b;
}
int compare_down_int(const void *a, const void *b){
   return *(int*)b - *(int*)a;
}
int euclid(int a, int b){
  if(a < b){int tmp = a;a = b;b = tmp;}
  int r = a % b;
  if(r < 0) r += b;
  while(r != 0){
    a = b;b = r;r = a % b;
    if(r < 0) r += b;
  }
  return b;
}

int main(){
  char a[3],b[3],c[3];
  scanf("%s",a);
  scanf("%s",b);
  scanf("%s",c);
  printf("%c",a[0]); printf("%c",b[1]); printf("%c",c[2]);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int n, c[3], d[3], h, m, r; char e;
int main() {
	while(cin >> n, n) {
		c[0] = c[1] = c[2] = 0;
		d[0] = d[1] = d[2] = 0;
		for(int i = 0; i < n; i++) {
			cin >> h >> e >> m >> r;
			int t = h * 60 + m, u = (r - m + 60) % 60;
			if(660 <= t && t < 900) c[0]++, d[0] += (u < 9 ? 1 : 0);
			if(1080 <= t && t < 1260) c[1]++, d[1] += (u < 9 ? 1 : 0);
			if(1260 <= t && t < 1440 || t < 120) c[2]++, d[2] += (u < 9 ? 1 : 0);
		}
		cout << "lunch ";
		if(!c[0]) cout << "no guest" << endl;
		else cout << 100 * d[0] / c[0] << endl;
		cout << "dinner ";
		if(!c[1]) cout << "no guest" << endl;
		else cout << 100 * d[1] / c[1] << endl;
		cout << "midnight ";
		if(!c[2]) cout << "no guest" << endl;
		else cout << 100 * d[2] / c[2] << endl;
	}
}

Measured memory_bytes: 3012
#include <iostream>
#include <iomanip>
#include <queue>
#include <deque>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <bitset>

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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

using namespace std;
using ll = long long;

const int kInf = 2e9;
const ll kLInf = 2e18;

int gcd (int a, int b) {
   return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

string S;

int main()
{
   cout << fixed << setprecision(10);
   cin >> S;
   int ans = 0;
   REP(i, SZ(S)) {
      if (S[i] != S[SZ(S) -1 - i]) {
         ans++;
      }
   }
   cout << ans / 2 << endl;
   return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>

using namespace std;

const int INF = 1000000000;
int dp[1 << 18][18][2];

int main()
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector< vector<int> > a(n, vector<int>(2));
    for (int i = 0; i < n; ++i)
        cin >> a[i][0];
    for (int i = 0; i < n; ++i)
        cin >> a[i][1];
    if (n == 1)
    {
        cout << "0";
        return 0;
    }
    for (int i = 0; i < (1 << 18); ++i)
        for (int j = 0; j < 18; ++j)
            for (int k = 0; k < 2; ++k)
                dp[i][j][k] = INF;
    for (int i = 0; i < n; ++i)
        dp[1 << i][i][i % 2] = i;
    for (int mask = 1; mask < (1 << n) - 1; ++mask)
    {
        vector<int> r;
        for (int i = 0; i < n; ++i)
            if ((mask & (1 << i)) == 0)
                r.push_back(i);
        vector<int> p(r.size(), 0);
        for (int i = 0; i < r.size(); ++i)
            for (int j = 0; j < n; ++j)
                if ((mask & (1 << j)) > 0 && j > r[i])
                    p[i] ^= 1;
        for (int i = 0; i < n; ++i)
        {
            if ((mask & (1 << i)) == 0)
                continue;
            for (int j = 0; j < 2; ++j)
            {
                if (dp[mask][i][j] == INF)
                    continue;
                for (int k = 0; k < r.size(); ++k)
                {
                    int stan = (p[k] + k) % 2;
                    if (a[i][j] <= a[r[k]][stan])
                        dp[mask | (1 << r[k])][r[k]][stan] = min(dp[mask | (1 << r[k])][r[k]][stan], dp[mask][i][j] + k);
                }
            }
        }
    }
    int odp = INF;
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < 2; ++j)
            odp = min(odp, dp[(1 << n) - 1][i][j]);
    if (odp == INF)
        odp = -1;
    cout << odp;
    return 0;
}


Measured memory_bytes: 37120
#include<stdio.h>
#include<stdlib.h>
int main(){
  long long n,d[100010],min,max,mi=0,ma=0,s=0,i;
  scanf("%lld",&n);
  for(i=0;i<n;i++){
    scanf("%lld",&d[i]);
    s+=labs(d[i]);
    if(d[mi]>d[i])mi=i;
    if(mi==ma||d[ma]<d[i])ma=i;
  }
  if(d[mi]>0)s-=d[mi]+d[mi];
  if(d[ma]<0)s+=d[ma]+d[ma];
  printf("%lld\n",s);
  max=d[ma];
  min=d[mi];
  for(i=0;i<n;i++){
    if(i==mi||i==ma)continue;
    if(d[i]>0){
      printf("%lld %lld\n",min,d[i]);
      min-=d[i];
    }
    else{
      printf("%lld %lld\n",max,d[i]);
      max-=d[i];
    }
  }
  printf("%lld %lld\n",max,min);
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> P;

int main(){
    int N;
    cin >> N;
    vector<int> s(N);
    for(int i = 0;i < N;i++)    cin >> s[i];
    LL ans = 0;
    for(int c = 1;c < N;c++){
        LL score = 0;
        for(int k = 0;;k++){
            int A = (N-1)-k*c;
            if(A <= 0 || A-c <= 0)    break;
            if(A%c == 0 && A <= k*c)    break;
            score += s[(N-1)-k*c];
            score += s[k*c];
            ans = max(ans, score);
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main() {
    int N;

    cin >> N;

    vector<pair<int, int> > E;
    int C[N];

    int a, b;
    for(int i = 0; i < N - 1; i++) {
        cin >> a >> b;
        E.emplace_back(make_pair(a, b));
    }

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

    sort(C, C + sizeof(C)/sizeof(C[0]), greater<int>());

    int M = 0;
    int D[N + 1];
    int index = 0;
    bool visited[N + 1];

    for(int i = 1; i < N + 1; i++) {
        D[i] = 0;
        visited[i] = false;
    }

    for(int i = 1; i < N; i++) M += C[i];

    auto e = E.front();
    E.erase(E.begin());

    visited[e.first] = true;
    visited[e.second] = true;
    D[e.first] = C[index];
    index++;
    D[e.second] =C[index];
    index++;

    int target;
    while(!E.empty()) {
        for(auto itr = E.begin(); itr != E.end(); ++itr) {
            if(visited[itr->first]) {
                target = itr->second;
                E.erase(itr);
                break;
            } else if(visited[itr->second]) {
                target = itr->first;
                E.erase(itr);
                break;
            }
        }
        visited[target] = true;
        D[target] = C[index];
        index++;
    }

    cout << M << endl;

    for(int i = 1; i < N + 1; i++) {
        if(i != 1) cout << " ";
        cout << D[i];
    }
    cout << endl;

}

Measured memory_bytes: 640
import std.stdio, std.conv, std.string, std.math, std.algorithm;

void main(){
	auto ip = readln.chomp;
	if(ip[0] == 'H'){
		if(ip[2] == 'H') 'H'.writeln;
		else if(ip[2] == 'D') 'D'.writeln;
	} else if(ip[0] == 'D') {
		if(ip[2] == 'H') 'D'.writeln;
		else if(ip[2] == 'D') 'H'.writeln;
	}
}


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

const char *p;

int solve() {
  int ret = 0;
  
  ++p;
  if(*p == '[') {
    vector<int> v;
    while(*p=='[') v.push_back(solve());
    sort(v.begin(), v.end());
    for(int i = v.size()/2; i>=0; i--) ret+=v[i];
  } else {
    char *e;
    ret = strtol(p, &e, 10)/2 + 1;
    p = e;
  }
  ++p;
  return ret;
}

int main() {
  int n;
  string str;
  
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> str;
    p = str.c_str();
    cout << solve() << endl;
  }
  return 0;
}

Measured memory_bytes: 1288
using System;
using System.Linq;

namespace arc059_a
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            long min = 9223372036854775807;
            for (int i = -100; i <= 100; i++)
            {
                int now = 0;
                for (int j = 0; j < n; j++)
                {
                    now += (x[j] - i) * (x[j] - i);
                }
                min = Math.Min(min, now);
            }
            Console.WriteLine(min);
        }
    }
}

Measured memory_bytes: 2776
n = int(input())  
red_li = [list(map(int, input().split())) for _ in range(n)]
blue_li = [list(map(int, input().split())) for _ in range(n)]
ans = 0
red_li.sort(reverse = True, key = lambda x : (x[0], x[1]))
blue_li.sort( key = lambda x : (x[0], x[1]))

def count(red, blue):
    used_red = []
    used_blue = []
    for i in red:
        if i in used_red:
            continue
        for j in blue:
            if j in used_blue:
                continue
            if i[0] < j[0] and i[1] < j[1]:
                used_red.append(i)
                used_blue.append(j)
                break
    return len(used_red)

ans = count(red_li, blue_li)
red_li.sort(reverse = True,key = lambda x : (x[1], x[0]))
blue_li.sort( key = lambda x : (x[1], x[0]))
ans = max(ans, count(red_li, blue_li))
red_li.sort(reverse = True,key = lambda x : (x[1], x[0]))
blue_li.sort( key = lambda x : (x[0], x[1]))
ans = max(ans, count(red_li, blue_li))
red_li.sort(reverse = True,key = lambda x : (x[0], x[1]))
blue_li.sort( key = lambda x : (x[1], x[0]))
ans = max(ans, count(red_li, blue_li))
print(ans)

Measured memory_bytes: 3064
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
int main()
{   int n,k,s;
    scanf("%d%d%d",&n,&k,&s);
    if(s!=1000000000){
        for(int i=0;i<k;i++){
            printf("%d ",s);
        }
    
    for(int i=k;i<n;i++){
    printf("1000000000 ");}
    }else{
        for(int i=0;i<k;i++){
            
                printf("1000000000 ");
            
        }
        for(int i=k;i<n;i++){
            printf("1 ");
        }
    }
    return 0;
}


Measured memory_bytes: 1280
using System;
using System.Collections.Generic;
public class Hello{
    public static void Main(){
        int DataNum = int.Parse(Console.ReadLine());
        string[] Data;
        int a2, b2, c2;
        
        for(int i = 0; i < DataNum; i++){
            Data = Console.ReadLine().Split(' ');
            a2 = (int)Math.Pow(int.Parse(Data[0]), 2);
            b2 = (int)Math.Pow(int.Parse(Data[1]), 2);
            c2 = (int)Math.Pow(int.Parse(Data[2]), 2);
            if((a2 + b2) == c2 || b2 + c2 == a2 || a2 + c2 == b2){
                Console.WriteLine("YES");
            } 
            else{
                Console.WriteLine("NO");
            }
        }
    }
}

Measured memory_bytes: 9008
#include<iostream>

using namespace std;

int main(){
	long long n, x = 0, y = 0, z = 0;
	cin >> n;
	for(int i = 1; i <= 3500; i++){
		for(int j = 1; j <= 3500; j++){
			long long a, b;
			a = n * i * j;
			b = 4LL * i * j - n * i - n * j;
			if(b <= 0) continue;
			if(a % b == 0){
				x = i, y = j, z = a / b;
				cout << x << " " << y << " " << z << endl;
				return 0;
			}
		}
	}
}

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

int N,P,pow_10[200001];
string S;
map<int,long long>mp;
long long res;


int main(){
	cin>>N>>P>>S;
	if(P==2){
		for(int i=0;i<N;i++){
			if((S[i]-'0')%2==0)res+=i+1;
		}
		cout<<res<<endl;
		return 0;
	}
	if(P==5){
		for(int i=0;i<N;i++){
			if((S[i]-'0')%5==0)res+=i+1;
		}
		cout<<res<<endl;
		return 0;
	}
	mp[0]++;
	int t=0;
	pow_10[0]=1;
	for(int i=0;i<N;i++){
		pow_10[i+1]=pow_10[i]*10%P;
	}
	for(int i=N-1;i>=0;i--){
		t+=pow_10[N-1-i]*(S[i]-'0');
		t%=P;
		mp[t]++;
	}
	for(auto p:mp){
		res+=p.second*(p.second-1)/2;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 1796
from collections import defaultdict
from math import sqrt
def prime(n):
	d=defaultdict(int)
	while n%2==0:
		d[2]+=1
		n=n//2
	for i in range(3,int(sqrt(n))+1,2):
		while n%i==0:
			d[i]+=1
			n=n//i
	if n>2:
		d[n]+=1
	for p in d:
		if d[p]%2!=0:
			return False
	return True

n,d=map(int,input().split( ))
a=[]
for _ in range(n):
	l=list(map(int,input().split( )))
	a.append((l))
count=0
for i in range(n-1):
	for j in range(i+1,n):
		t1=a[i]
		t2=a[j]
		k=0
		check=0
		while k<d:
			diff=(t1[k]-t2[k])**2
			check+=diff
			k+=1
		if prime(check):
			count+=1
print(count)





Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int n,k,a[1001];
int main() {
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin>>n>>k;
	for(int i=1; i<=n; i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	int ans=0;
	for(int i=1; i<=k; i++)
		ans+=a[i];
	cout<<ans;
	return 0;
}

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

using namespace std;

int main(int argc, char* argv[]) {
  vector<int> input(3);
  cin >> input[0] >> input[1] >> input[2];

  sort(input.begin(), input.end());
  cout << input[0] << ' ' << input[1] << ' ' << input[2] << endl;
  return 0;
}

Measured memory_bytes: 1208
x = int(input())

exp = [1]
for b in range(2, 32):
    for p in range(2, 10):
        beki = b**p
        if beki <= 1000:
            exp.append(beki)
        else:
            break

exp.sort()
for e in exp:
    if e > x:
        break
    ans = e
else:
    ans = 1000

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
 
bool ch[302][302];
bool a[302];
ll ans[302][302];
int main() {
	ll h,w,k;
	cin>>h>>w>>k;
	for(ll i=0;i<h;i++){
		bool b=false;
		for(ll j=0;j<w;j++){
			char now;
			cin>>now;
			if(now=='#'){
				ch[i][j]=true;
				b=true;
			}
		}
		if(b!=true){
			a[i]=true;// a[i]=trueでイチゴ無し
		}
	}
	ll cnt=1;
	for(ll i=0;i<h;i++){
		if(a[i]==true){
			continue;
		}
		bool itigo=false;
		for(ll j=0;j<w;j++){
			if(ch[i][j]==true){
				if(itigo){
					cnt++;
				}
				itigo=true;
			}
			ans[i][j]=cnt;
		}
		if(itigo){
			cnt++;
		}
	}
	for(ll i=0;i<h-1;i++){
		if(ans[i+1][0]!=0){
			continue;
		}
		if(ans[i][0]==0){
			continue;
		}
		for(ll j=0;j<w;j++){
			ans[i+1][j]=ans[i][j];
		}
	}
	for(ll i=h-1;i>=1;i--){
		if(ans[i-1][0]!=0){
			continue;
		}
		if(ans[i][0]==0){
			continue;
		}
		for(ll j=0;j<w;j++){
			ans[i-1][j]=ans[i][j];
		}
	}
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			cout << ans[i][j];
			if(j!=w-1){
				cout << " ";
			}
		}
		cout <<endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
	char a;
	while(1){
		scanf("%c",&a);
		if(isalpha(a)){
			if(islower(a))cout<<(char)toupper(a);
			else if(isupper(a))cout<<(char)tolower(a);
		}
		else {cout<<a;}
		if(a=='\n')break;
	}
return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i, N) cin >> S[i];

    map<string, int> mp;

    rep(i, N){
        map<string, int>::iterator it;
        it = mp.find(S[i]);
        if (it != mp.end()){
            mp[S[i]]++;
        }else{
            mp.insert(make_pair(S[i], 1 ));
        }
    }

    vector<int> num(N);

    int max = 0;
    vector<string> ans(N);

    map<string, int>::iterator it;
    for(it = mp.begin(); it != mp.end(); it++){
        pair<string, int> item = *it;
        if (item.second > max){
            max = item.second;
        }
        // cout << item.first << "-->" << item.second << endl;
    }

    for(it = mp.begin(); it != mp.end(); it++){
        pair<string, int> item = *it;
        if (item.second == max){
            cout << item.first << endl;
        }
    }




    return 0;
}

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

int main() {
  string s;
  cin>>s;
  if (s == "a" || s == "e" || s == "i" || s == "o" || s == "u") {
    cout << "vowel";
  } else {
    cout << "consonant";
  }
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// hoge

fn main() {
    input! {
        mut a: [i64; 5],
        k: i64,
    }

    a.sort();

    let ans = if a[4] - a[0] > k { ":(" } else { "Yay!" };

    println!("{}", ans);
}


Measured memory_bytes: 4352
object Main{

  def main(args: Array[String]): Unit = {
    val Seq(x1, y1, x2, y2): Seq[Int] = io.StdIn.readLine().split(' ').map(_.toInt).toList
    val nums = findTheCoordinates(x1,y1,x2,y2)
    println(s"${nums._1} ${nums._2} ${nums._3} ${nums._4} ")
  }

  def findTheCoordinates(x1:Int, y1:Int, x2:Int, y2:Int) ={
    val xLength = x1-x2
    val yLength = y1-y2
    (x2+yLength, y2-xLength, x1+yLength, y1-xLength)
  }
}

Measured memory_bytes: 25536
answers=[]
while True:
    cards=input()
    if cards=='-':
        break
    shuffle=int(input())
    for i in range(shuffle):
        num_of_cards=int(input())
        cards=cards[num_of_cards::]+cards[:num_of_cards:]
    answers.append(cards)

for i in answers:
    print(i)

Measured memory_bytes: 7576
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    static long UB;
    static long N;
    public static void Main()
    {
        string s = Console.ReadLine();
        N = long.Parse(s);
        int[] canUse = Enumerable.Repeat(1, 10).ToArray();
        var dig = (long)Math.Pow(10, s.Length - 1);
        UB = dig * 10;

        Console.WriteLine(Solve(0, dig, canUse).ToString().PadLeft(s.Length, '0'));
    }

    static long GetDiff(long a, long b) => Min(Abs(a - b), UB - Abs(a - b));

    static long Solve(long num, long currentDig, int[] canUse)
    {
        if (currentDig == 0) return num;

        List<Tuple<long, int>> reses = new List<Tuple<long, int>>();
        for (int i = 0; i < 10; i++)
        {
            if (canUse[i] <= 0) continue;
            var diff = GetDiff(N, num + i * currentDig);
            reses.Add(new Tuple<long, int>(diff, i));
        }

        reses.Sort();reses.Reverse();
        long finalDiff = 0;
        long res = -1;

        Action<Tuple<long, int>> update = item =>
        {
            var i = item.Item2;

            var nextCanUse = canUse.ToArray();
            nextCanUse[i]--;
            var curRes = Solve(num + i * currentDig, currentDig / 10, nextCanUse);
            var diff = GetDiff(N, curRes);
            if (diff > finalDiff || (diff == finalDiff && curRes < res))
            {
                finalDiff = diff;
                res = curRes;
            }
        };

        foreach (var item in reses.OrderByDescending(x => x.Item1).ThenBy(x => x.Item2).Take(3))
        {
            update(item);
        }

        return res;
    }
}



struct Top2<T> where T : IComparable
{
    public T First;
    public T Second;
    public Top2(T first, T second) { First = first; Second = second; }
    public static Top2<T> Merge(Top2<T> a, Top2<T> b)
    {
        if (a.First.CompareTo(b.First) > 0)
            return new Top2<T>(a.First, a.Second.CompareTo(b.First) > 0 ? a.Second : b.First);
        else
            return new Top2<T>(b.First, b.Second.CompareTo(a.First) > 0 ? b.Second : a.First);
    }
    public static Top2<T> Merge(Top2<T> a, T b)
    {
        if (a.Second.CompareTo(b) > 0) return a;
        if (a.First.CompareTo(b) > 0) return new Top2<T>(a.First, b);
        return new Top2<T>(b, a.First);
    }
    public static Top2<T> operator |(Top2<T> a, Top2<T> b) => Merge(a, b);
    public static Top2<T> operator |(Top2<T> a, T b) => Merge(a, b);
}


Measured memory_bytes: 24760
#include<stdio.h>
int main(void){
 int n;
  scanf("%d",&n);
  switch(n%10){
    case 0:
    case 1:
    case 6:
    case 8:puts("pon");break; 
    case 3: puts("bon");break;
    default:puts("hon");
  }
  return 0;
}


Measured memory_bytes: 1628
n = int(input())
a = list(map(int, input().split(' ')))
a = [a[i]-i-1 for i in range(n)]
a.sort()
if n%2 == 0:
    num = int(n/2)
    b = int((a[num-1]+a[num])/2)
    a = [abs(a[i]-b) for i in range(n)]
else:
    num = int(n/2)
    b = int(a[num])
    a = [abs(a[i]-b) for i in range(n)]
print(sum(a))

Measured memory_bytes: 25708
#include <stdio.h>

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

int min(int a, int b) {
	if (a < b) return a;
	else return b;
}

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

	int notcut = a * x + b * y;
	int partialcut = 2 * c * min(x, y);
	if (min(x, y) == y) {
		partialcut = partialcut + a * (x - y);
	}
	else {
		partialcut = partialcut + b * (y - x);
	}
	int allcut = 2 * c * max(x, y);

	printf("%d\n", min(allcut, min(notcut, partialcut)));
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstring>
#include<set>
#include<vector>
#include<queue>
#include<cmath>
#include<memory.h>
#include<ctime>
#include<cstdio>
#include<map>
#include<stack>

using namespace std;

int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.size();i+=2)
	{
		cout<<s[i];
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 512
import java.io.*;
import java.util.*;
public class Main {
    private static void solver(InputReader sc, PrintWriter out) {
        int k = sc.nextInt();
        String s = sc.next();
        StringBuilder sb = new StringBuilder("");
        int n = s.length();
        if( n <= k){
            out.println(s);
        }else{
            for(int i=0; i<k; i++) sb.append(s.charAt(i));
            sb.append("...");
            out.println(sb);
        }
    }
    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public int[] readIntArray(int n){
            int arr[] = new int[n];
            for(int i=0;i<n;i++) arr[i] = nextInt();
            return arr;
        }
    }
}
class Pair{
    int x,y;
    Pair(int x, int y){
        this.x = x;
        this.y = y;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Pair pair = (Pair) o;
        return x == pair.x &&
                y == pair.y;
    }

    @Override
    public int hashCode() {
        return Objects.hash(x, y);
    }
}

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

int main()
{
    int A, B, C, X;
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> X;
    int ans = 0;
    for (int i = 0; i <= A; ++i){
        for (int j = 0; j <= B; ++j){
            for (int k = 0; k <= C; ++k){
                if (500 * i + 100 * j + 50 * k == X) ++ans;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(void) {
	string s;
	string t;
	cin >> s;
	cin >> t;
	if (s.size() + 1 != t.size()) {
		cout << "No";
	}
	else {
		for (int i = 0; i < s.size(); ++i) {
			if (s[i] != t[i]) {
				cout << "No";
				return 0;
			}
		}
		cout << "Yes";
	}
	return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a <= 9 && b <= 9) {
			System.out.println(a * b);
		} else {
			System.out.println(-1);
		}

		sc.close();
	}
}


Measured memory_bytes: 23892