akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5;
vector<int> edges[MAX];
const int MOD = 1e9 + 7;

int add(int a, int b) {
	a += b;
	if(a >= MOD) {
		a -= MOD;
	}
	return a;
}
void mul_self(int& a, int b) {
	a = (long long) a * b % MOD;
}

pair<int, int> dfs(int a, int parent) {
	int me_black = 1, me_white = 1;
	for(int b : edges[a]) {
		if(b == parent) {
			continue;
		}
		pair<int,int> his = dfs(b, a);
		// his.first - black
		// his.second - white
		mul_self(me_black, his.second);
		mul_self(me_white, add(his.first, his.second));
	}
	return {me_black, me_white};
}

int main() {
	int n;
	cin >> n;
	for(int i = 0; i < n - 1; ++i) {
		int a, b;
		cin >> a >> b;
		edges[a].push_back(b);
		edges[b].push_back(a);
	}
	pair<int,int> ways = dfs(1, -1);
	int total = add(ways.first, ways.second);
	cout << total << "\n";
}


Measured memory_bytes: 12672
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
string s[10010];
int n;
int main() {


cin>>n;
for (int i = 0; i < n; i++)
{
    cin>>s[i];
    /* code */
}
ll cnt=0;
for (int i = 0; i < n; i++){
    for (int j = 0; j < s[i].size()-1; j++)
    {
        if(s[i][j]=='A' && s[i][j+1]=='B') cnt++;
        }
 
}
int left=0,right=0;
int x=0;
int flag=0;
for(int i=0;i<n;i++){
        if(s[i][0]=='B' && s[i][s[i].size()-1]!='A') left++;
        if(s[i][s[i].size()-1]=='A' && s[i][0]!='B') right++;
        if(s[i][0]=='B' && s[i][s[i].size()-1]=='A')  x++;
}
if(x==0) cout<< cnt+min(left,right)<<endl;
else if(left==0 && right==0 && x>=1) cout<<cnt+x-1<<endl;
else {
    //cerr<<left<<right<<x<<endl;
    cout<<cnt+x+min(left,right)<<endl;
}
    return 0;
}

Measured memory_bytes: 768
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApplication2
{
    class Program
    {
        class Runner
        {
            public int Num { get; set; }
            public decimal time { get; set; }
            public Runner(string[] s)
            {
                Num = int.Parse(s[0]);
                time = decimal.Parse(s[1]);
            }
        }

        static void Main(string[] args)
        {
            List<Runner> finalist = new List<Runner>();
            List<Runner> looser = new List<Runner>();
            for (int i = 0; i < 3; i++)
            {
                List<Runner> list = new List<Runner>();
                for (int j = 0; j < 8; j++)
                {
                    list.Add(new Runner(Console.ReadLine().Split(' ')));
                }
                list = list.OrderBy(s=> s.time).ToList();
                finalist.AddRange(list.Take(2));
                looser.AddRange(list.Skip(2));
            }

            finalist.AddRange(looser.OrderBy(s => s.time).Take(2));


            foreach (Runner runner in finalist)
            {
                Console.WriteLine("{0} {1}", runner.Num, runner.time);
            }

            Console.ReadKey();
        }

        
    }
}

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

int main(){
  int H,W;
  cin >> H >> W;
  char mp[H][W];
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> mp[i][j];
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(mp[i][j]=='.'){
       int cnt=0;
        for(int k=-1;k<=1;k++){
          for(int l=-1;l<=1;l++){
            if((0<=i+k&&i+k<H)&&(0<=j+l&&j+l<W)){
              if(mp[i+k][j+l]=='#')
               cnt++;
            }
          }
        }
        mp[i][j] = '0'+cnt;
       }
     }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cout << mp[i][j];
    }
    cout << endl;
  }
}

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

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define fr(i,k,n) for (int i = k; i < n; ++i)
#define fri(i,k,n) for (int i = k; i >= n; --i)
#define INF (int)1e9
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define all(arr) arr.begin(),arr.end()

void boost(){
  ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vi par;

int findpar(int u){
  if(par[u]==u)
    return u;
  return par[u]=findpar(par[u]);
}

void uni(int u,int v){
  par[findpar(u)]=par[findpar(v)];
}

void solve(){
  int n,q;
  cin>>n>>q;
  par.resize(n+1);
  iota(all(par),0);
  int t,u,v;
  while(q--){
    cin>>t>>u>>v;
    if(t==0){
      uni(u,v);
    }else{
      if(findpar(u)==findpar(v)){
        cout<<1<<endl;
      }
      else{
        cout<<0<<endl;
      }
    }
  }
  return;
}

int main()
{
  boost();
  
  int tc=1;
  //cin>>tc;
  while(tc--)
    solve();
  return 0;
}

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

int main() {
    map <string,int> memo;
    int N;
    cin >> N;
    for (int i = 0; i < N; i++){
    string s;
    cin >> s;
    memo[s] += 1;
  }
   int max =0;

  for(auto p:memo){
      auto v = p.second;
      if(max<v) max=v;
  }

  for(auto p:memo){
      auto v=p.second;
      auto k=p.first;
      if(max==v)cout << k << endl;
  }

return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define REP(i,n) FOR(i,0,n)
int main(){
double n,t,a,k,ans,min=1e9;
  cin>>n>>t>>a;
  vector<double> h(n);
  vector<double> v;
  REP(i,n){
  cin>>h[i];
    k=t-0.006*h[i];
    v.push_back(abs(k-a));
  }
  REP(i,n){
  if(v[i]<min){
  min=v[i];
    ans=i+1;
  }
  }
  cout<<ans<<endl;
return 0;
}

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

#define int long long
#define INF (int)(1e9 + 7)

int n, a, b;
vector<int> h;

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

	cin >> n >> a >> b;

	h.resize(n);

	for (int i = 0; i < n; ++i)	{
		cin >> h[i];
	}

	sort(h.begin(), h.end(), greater<int>());

	int l = 0, r = INF, dif = a - b, t = 0, m, tmp, mid;

	for (;;) {
		mid = (r + l) / 2; // 危ない書き方
		t = m = 0;

		for (int i = 0; i < n; ++i) {
			m = h[i] - b * mid;
			if (m > 0) {
				t += (m % dif == 0) ? m / dif : m / dif + 1;
			}
			else if (m <= 0) break;
		}

		if (t < mid) r = mid;
		else l = mid + 1;

		if (r - l < 100) break;
	}

	int ans = INF;

	l = (l - 10 > 0) ? l - 10 : 0;
	r = (r + 10 < INF) ? r + 10 : r;

	for (int i = l; i <= r; ++i) {
		t = m = 0;

		for (int j = 0; j < n; ++j) {
			m = h[j] - b * i;
			if (m > 0) {
				t += (m % dif == 0) ? m / dif : m / dif + 1;
			}
			else if (m <= 0) break;
		}

		if (t <= i) {
			ans = i;
			break;
		}
	}

	cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <bitset>
#define N 1005
using namespace std;

int n, t, s, x[N], y[N];
vector<int> a[N];
bitset<5005> bs;
int main()
{
	int i, j;
	cin >> n;
	for (i = 2; i <= n; i++) {
		scanf ("%d", &t);
		a[t].push_back(i);
	}
	for (i = 1; i <= n; i++) {
		scanf ("%d", &x[i]);
	}
	for (i = n; i >= 1; i--) {
		bs = 1;
		s = 0;
		for (j = 0; j < a[i].size(); j++) {
			t = a[i][j];
			bs = (bs << x[t] | bs << y[t]);
			s += x[t] + y[t];
		}
		for (j = x[i]; j >= 0; j--) if (bs[j]) break;
		y[i] = s - j;
		if (j < 0) {
			cout << "IMPOSSIBLE";
			return 0;
		}
//		for (j = 0; j <= x[i]; j++) {
//			if (bs[x[i] - j] || bs[s - x[i] - j]) break;
//		}
//		if (j > x[i]) break;
//		printf("%d\n", bs[0]);
	}
	cout << "POSSIBLE";
    return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n;
  ll X;
  cin >> n >> X;
  vector<ll> x(n);
  rep(i, n) cin >> x[i];

  x.push_back(X);
  sort(ALL(x));
  ll ans = x[1]-x[0];
  rep(i, n) ans = __gcd(ans, x[i+1]-x[i]);
  cout << ans << endl;
}

Measured memory_bytes: 4732
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<bool> check(100001);
    for(int i=2;i<100001;i++){
        int K=i;
        map<int,int> a;
        for(int j=2;j<sqrt(i)+3;j++){
            while(K%j==0){
                a[j]++;
                K/=j;
            }
            if(K==1)break;
        }
        if(K!=1)a[K]++;
        if(a.size()==1 and (*a.begin()).second==1)check[i]=1;
    }
    vector<int> cnt(100001);
    for(int i=0;i<100001;i++){
        if(i%2 and check[i] and check[(i+1)/2])cnt[i]++;
    }
    for(int i=1;i<100001;i++)cnt[i]+=cnt[i-1];
    int Q;scanf("%d",&Q);
    while(Q--){
        int l,r;scanf("%d%d",&l,&r);
        printf("%d\n",cnt[r]-cnt[l-1]);
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int n;
  cin >> n;  
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    int cpy = i;
    int cnt = 0;
    while (cpy > 0) {
      cnt += 1;
      cpy /= 10;
    }
    if (cnt % 2) ans += 1;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        int Q = sc.nextInt();
        int[] A = new int[Q];
        for (int i=0; i<Q; i++) {
            A[i] = sc.nextInt();
        }

        String[] ans = solve(N, K, Q, A);
        for (int i=0; i<N; i++) {
            System.out.println(ans[i]);
        }
    }

    private static String[] solve(int N, int K, int Q, int[] A) {
        String[] ans = new String[N];
        int[] score = new int[N+1];

        for (int i=0; i<Q; i++) {
            score[A[i]]++;
        }

        for (int i=0; i<N; i++) {
            ans[i] = K - (Q - score[i+1]) > 0 ? YES : NO;
        }

        return ans;
    }
}

Measured memory_bytes: 58840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    int ans = n * (n - 1) / 2 + m * (m - 1) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
typedef vector<pr > vpr;
const int INF=1<<30;
ll lcm(ll a,ll b){
	if(a%b==0)
	return b;
	else
	return lcm(b,a%b);
}
ll GCD(ll a,ll b){
	return (a*b)/lcm(a,b);
}
int main() {
	ll N,M,D;
	ll divi[10];
	ll dived[100][10],gcd[10]={};
	cin >> N >> M >> D;
	REP(i,M){
	cin >> divi[i];
	}
	REP(i,D)
		REP(j,M)
			cin >> dived[i][j];
	ll now=N;
	REP(i,D){
		ll mn=0,ngcd=1;
		bool ans=false;
		REP(j,M){
			if(dived[i][j]==-1)	
				continue;
			if(!ans)
				mn=dived[i][j];
			ans=true;
			while(mn%divi[j]!=dived[i][j] && now>=mn) mn+=ngcd;
			ngcd=GCD(ngcd,divi[j]);
		}
		if(now<mn){
			now=-1;
			break;
		}
		if(ans){
			ll alpha=(now-mn)/ngcd;
			now=mn+alpha*ngcd;
		}
	}
	cout << now << endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 1164
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
#define ll long long
using namespace std;
const int N=2e5+10 ,base=2e3+2 ,M=8010;
const ll mod=1e9+7;
int n;
ll a[N],b[N],fac[M]={1},inv[M],dp[M/2][M/2],ans;
inline ll read(){
	char ch=getchar(); ll x=0, f=1;
	while(ch<'0' || ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0' && ch<='9') {x=x*10+ch-'0'; ch=getchar();}
	return x*f;}
inline ll powe(ll aa,ll tt)
{
	ll ans=1;
	for(ll i=tt;i;i>>=1,aa=aa*aa%mod) if(i&1) (ans*=aa)%=mod;
	return ans;
}
inline ll C(int nn,int mm){return fac[nn]*inv[mm]%mod*inv[nn-mm]%mod;}
int main()
{
	//freopen(".out","w",stdout);
	n=read();
	for(RG int i=1;i<=M;i++) fac[i]=fac[i-1]*i%mod;
	inv[M]=powe(fac[M],mod-2);
	for(RG int i=M-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	for(RG int i=1;i<=n;i++)
	{
		a[i]=read(); b[i]=read();
		dp[base-a[i]][base-b[i]]++;
	}
	for(RG int i=1;i<=base*2;i++)
	 for(RG int j=1;j<=base*2;j++)
	  (dp[i][j]+=dp[i-1][j]+dp[i][j-1])%=mod;
	for(RG int i=1;i<=n;i++) (ans+=dp[base+a[i]][base+b[i]]-C(2*a[i]+2*b[i],a[i]*2)+mod)%=mod;
	printf("%lld",ans*inv[2]%mod);
	//fclose(stdin); fclose(stdout);
	return 0;
}

Measured memory_bytes: 128768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))
#define SUM(v) accumulate(all(v), 0LL)

typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
struct fast_ios{ fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; }fast_ios_;

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

#define TOSTRING(x) string(#x)
template <typename T> istream &operator>>(istream &is, vector<T> &vec) { for (T &x : vec) is >> x; return is; }
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) { os  << "["; for(auto _: v) os << _ << ", "; os << "]"; return os; };
template <typename T> ostream &operator<<(ostream &os, set<T> &st) { os << "("; for(auto _: st) { os << _ << ", "; } os << ")";return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair< T, U >& p){os << "{" <<p.first << ", " << p.second << "}";return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &mp){ os << "["; for(auto _: mp){ os << _ << ", "; } os << "]" << endl; return os; }

#define DUMPOUT cerr
void dump_func(){ DUMPOUT << endl; }
template <class Head, class... Tail> void dump_func(Head &&head, Tail &&... tail) { DUMPOUT << head; if (sizeof...(Tail) > 0) { DUMPOUT << ", "; } dump_func(std::move(tail)...); }

#ifdef DEBUG
#define dbg(...) dump_func(__VA_ARGS__)
#define dump(...) DUMPOUT << string(#__VA_ARGS__) << ": "; dump_func(__VA_ARGS__)
#else
#define dbg(...)
#define dump(...)
#endif

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = 1000000007;
// const ll MOD = 998244353;
const long double PI = acos(-1.0);

/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/


int main() {
    int N, M;
    cin >> N >> M;
    cout << (N == M ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3624
#include<iostream>
using namespace std;
int n,m;
int dis(int x1,int y1,int x2,int y2)
{
    return abs(x1-x2)+abs(y1-y2);
}
int a1[10000],b1[100000],a2[10000],b2[100000];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a1[i]>>b1[i];
    }
    for(int i=1;i<=m;i++)
    {
        cin>>a2[i]>>b2[i];
    }
    for(int i=1;i<=n;i++)
    {
        int pos;
        int Max=(1<<31)-1;
        for(int j=1;j<=m;j++)
        {
            int ans=dis(a1[i],b1[i],a2[j],b2[j]);
            if(ans<Max)
            {
                pos=j;
                Max=ans;
            }
        }
        cout<<pos<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	long long a,b;
	char op;
	scanf("%lld %c %lld",&a,&op,&b);
	if(op=='+')   printf("%lld\n",a+b);
	if(op=='-')   printf("%lld\n",a-b);
	return 0;
}

Measured memory_bytes: 128
n=int(input())
field=[[0 for i in range(20)]for j in range(15)]
for i in range(n):
    b,f,r,v=map(int,input().split())
    h=(b-1)*4+f-1
    w=r*2-1
    n=v
    field[h][w]+=n
for y in range(15):
    for x in range(20):
        if(y%4==3):field[y][x]='#'
        elif x%2==0 :field[y][x]=' '
        print(field[y][x],end='')
    print()


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

int main()
{
	int N;
	cin >> N;
	vector<ll> A(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	vector<ll> sum(N + 1);
	for (int i = 0; i < N; i++) {
		sum[i + 1] = sum[i] + A[i];
	}
	int id = N / 2;
	ll res = ((sum[N] - sum[id]) - A[id] * (N - id) + A[id] * id - sum[id]) * 2;
	if (N & 1) res -= min(A[id + 1] - A[id], A[id] - A[id - 1]);
	else res -= A[id] - A[id - 1];
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
typedef long long ll;
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pii pair < int , int >
#define pll pair < ll, ll >
#define mp make_pair
#define ff first
#define ld long double
#define ss second
#define vi vector < int >
#define vll vector < ll >
#define pb push_back
#define pf push_front
#define PI 3.1415926535897932384626
#define INF 0x3f3f3f3f
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)

const int mod = 1'000'000'007;

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}


	
int main()
{
		fastio;
		ll t = 1;
		//cin >> t;
		rep(tt,1,t+1)
		{
			ll n;
			cin >> n;
			vll A(n);
			ll sum = 0;
			rep(i, 0, n)
			{
				cin >> A[i];
				sum+=A[i];
			}
			ll dp[n][n];
			for(int i = n-1; i>=0; i--)
			{
				rep(j,0,n)
				{
					if(i>j) continue;
					if(i == j) 
					{
						dp[i][i] = A[i];
						continue;
					}
					dp[i][j] = max(A[i] - dp[i+1][j], A[j] - dp[i][j-1]);
				}
			}
			
			ll ans = 0;
			ans = dp[0][n-1];
			cout << ans<< endl;
		}
		return 0;
	}
					


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

int main() {
  int n, k, q;
  cin >> n >> k >> q;

  vector<int> a(q);
  rep (i, q) cin >> a.at(i);

  vector<int> answer(n, k);
  rep (i, q) {
    answer.at(a.at(i) - 1)++;
  }

  rep (i, n) {
    if (answer.at(i) - q > 0) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1408
# coding: utf-8
# Your code here!
#途中

H,W,D=map(int,input().split())

A=[]
for i in range(H):
    A.append(list(map(int,input().split())))

loc=[[0,0] for i in range(W*H)]

#print(loc)

for i in range(H):
    for j in range(W):
        loc[A[i][j]-1][0]=i
        loc[A[i][j]-1][1]=j
        #print(loc)
#print(loc)

cost=[[0]*((H*W)//D) for i in range(D)]

for i in range((H*W)%D):
    cost[i].append(0)

for i in range(D):
    pass
    count=1
    temp=i
    while temp+D<(H*W):
        temp=i+D*count
        cost[temp%D][temp//D]=abs(loc[temp][0]-loc[temp-D][0])+abs(loc[temp][1]-loc[temp-D][1])+cost[temp%D][temp//D-1]
        count+=1
        #print(cost)
cost[-1]=[0]+cost[-1]

Q=int(input())
for _ in range(Q):
    x,y=map(int,input().split())
    #print(cost[x%D-1][x//D-1])
    print(cost[y%D-1][y//D]-cost[x%D-1][x//D])

#print(cost)



Measured memory_bytes: 25700
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

int main(){
   int A,B;
   cin >> A >> B;
   B += A*3;
   cout << B/2 << endl;

   return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int n,i;
  int Asum,Bsum;
  while(1){
    Asum=0;
    Bsum=0;
    
    scanf("%d",&n);
    if(n==0)
      break;

    int A[n],B[n];
    for(i=0; i<n; i++){
      scanf("%d %d",&A[i],&B[i]);
      if(A[i]>B[i])
	Asum+=A[i]+B[i];
      else if(A[i]<B[i])
	Bsum+=A[i]+B[i];
      else{
	Asum+=A[i];
	Bsum+=B[i];
      }
    }
    printf("%d %d\n",Asum,Bsum);
  }

  return 0;
  
}


Measured memory_bytes: 1924
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<tint> vtint;
typedef vector<vint> vvint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//↑templete
signed main(){

    int N;
    cin>>N;
    set<string> tes;
    for(int i=0;i<N;i++){
        string s;
        cin>>s;
        tes.insert(s);
    }
    cout<<tes.size()<<endl;

    return 0;
}


Measured memory_bytes: 19228
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int X;
	cin>>X;

	int C=X%100;
	int cnt=0;
	rrep(i,1,6)
	{
		cnt+=C/i;
		C%=i;
	}

	if(cnt<=X/100)cout<<1<<endl;
	else cout<<0<<endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

int main(void){
    char s[100],t[100]={0};
    int a;
    scanf("%s",s);
    a=strlen(s);
    for(int b=0;b<a;b++){
        t[b]='x';
    }
    printf("%s",t);
}

Measured memory_bytes: 128
#[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")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

fn main() {
    input! {
        n: usize,
        mut h: [i64; n],
    }
    let mut changed = vec![false; n];
    for i in 1..n {
        if h[i] - h[i - 1] >= 1 {
            if !changed[i] {
                changed[i] = true;
                h[i] -= 1;
            }
        }

        if i + 1 >= n {
            continue;
        }

        if h[i] - h[i + 1] == 1 {
            if !changed[i] && h[i] - 1 >= h[i - 1] {
                h[i] -= 1;
            } else {
                println!("No");
                return;
            }
        } else if h[i] - h[i + 1] > 1 {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 4352
// using no_way as a way
// using no_limitation as a limitation

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#include<stdio.h>
using namespace std;
const double PI = acos(-1.0);
const double EPS = (1e-9);
typedef long long ll;
typedef unsigned long long ull;
#define flush fflush(stdout), cout.flush()
#define all(v) ((v).begin()),((v).end())
#define rall(v) ((v).rbegin()),((v).rend())
#define clr(v,line) memset(v,line,sizeof(v))
#define rep(i,n) for(int(i)=0;(i)<(int)(n);(i)++)
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define RT(x) return cout<<x, 0;
//#define lcm(a,b) (a*(b/__gcd(a,b)))
#define P 1000000007
#define endl '\n'
// const int dx[] = {1,-1,0,0,1,-1,1,-1};
// const int dy[] = {0,0,1,-1,1,-1,-1,1};
// const int dxhorse[] = {-2,-2,-1,-1,1,1,2,2};
// const int dyhorse[] = {1,-1,2,-2,2,-2,1,-1};
 
void file() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void fast()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL); cout.tie(NULL);
}


int main(int argc, char const *argv[])
{
    // file();
    fast();
    
    int n; cin>>n;
    ll ans = 0;
    for (int i = 1; i <= n; ++i)
    {
        if (i % 3 == 0 or i % 5 == 0)
        {
            continue;
        }
        ans+=i;
    }
    cout<<ans;
}

Measured memory_bytes: 3636
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > //第二成分の大きさが関係ない
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}



#define inf 1000000007
struct Combinations {
    
    long long mod;
    vector< long long > inv;
    vector< long long > fact;
    vector< long long > inv_fact;
    
    Combinations (int n, int m) : inv(n), fact(n), inv_fact(n), mod(m) {
        inv[1] = 1;
        for (long long i = 2; i < n; i++) {
            inv[i] = inv[mod%i] * (mod - mod / i) % mod;
        }
        fact[0] = inv_fact[0] = 1;
        for (long long i = 1; i < n; i++) {
            fact[i] = (fact[i-1] * i) % mod;
            inv_fact[i] = (inv_fact[i-1] * inv[i]) % mod;
        }
    }
    
    long long nPr(long long n, long long r) {
        if (n < r || r < 0) return 0;
        return fact[n] * inv_fact[n-r] % mod;
    }
    
    long long nCr(long long n, long long r) {
        if (n < r || r < 0) return 0;
        return nPr(n,r) * inv_fact[r] % mod;
    }
    
    long long nHr(long long n, long long r) {
        return nCr(n+r-1,r);
    }
    
};
/*
 usage:
 O(N);
 Combination C(N,inf);//Nまでの全てのcombination, %inf;
 C.nCr(a,b); // aCbの値
 C.nPr,  C.nHrなどもある
 */

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll H,W,A,B; cin >> H >> W >> A >> B;
    Combinations C(500000, inf);
    
    vector<pair<ll,ll> > F,T;
    rep(i,W){
        if(B+1+i > W) break;
        F.pb(mp(H-A  , B+1+i));
        T.pb(mp(H-A+1, B+1+i));
    }
    
    ll ans = 0;
    for(ll i = 0; i< F.size(); i++){
        ll ret = 0;
        ret += C.nCr((F[i].first -1)+(F[i].second -1), (F[i].first -1));
        ret *= C.nCr( (H-T[i].first)+(W-T[i].second),(H-T[i].first) );
        ret %= inf;
        ans += ret;
        ans %= inf;
    }
    
    cout << ans << endl;
    
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 15340
package main

import (
	"fmt"
	"sort"
)

func main() {
	// Code for B - Iroha Loves Strings (ABC Edition)
	var N, L int
	fmt.Scanf("%d %d", &N, &L)
	S := make([]string, N)

	for i := 0; i < N; i++ {
		fmt.Scanf("%s", &S[i])
	}

	sort.Sort(sort.StringSlice(S))
	for i := 0; i < N; i++ {
		fmt.Printf(S[i])
	}

	fmt.Printf("\n")
}


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

int main() {
  int n, h, w;
  cin >> n >> h >> w;

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

  int cnt = 0;

  for (int i = 0; i < n; ++i) {
    if (a[i] >= h && b[i] >= w)
      ++cnt;
  }

  cout << cnt << endl;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

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 double PI=3.14159265358979323846;

int mod = 1e9+7;
const long long INF = 1LL<<60;


int main(){
  string str;
  cin >> str;
  ll K;
  cin >> K;

  for(int i=0; i<min((ll)str.size(), K); i++){
    if(str[i] != '1'){
      cout << str[i] << endl;
      return 0;
    }
  }

  cout << 1 << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = sc.NextInt()
	}

	ans := 0
	for i := 0; i < n-1; i++ {
		for j := i + 1; j < n; j++ {
			ans += a[i] * a[j]
		}
	}
	fmt.Printf("%v\n", ans)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#[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")
    };
}

// hog

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
#include <iostream>

using namespace std;

int main(){
    int a[9999];
    int i,n;
    
    cin >> n;
    
    for(i = 0;i < n;i++){
        cin >> a[i];
    }
    
    i = n - 1;
    
    while(1){
        cout << a[i];
        
        if(i == 0){
            break;
        }
        i--;
        cout << ' ';
    }
    
    cout << endl;
}


Measured memory_bytes: 3116
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char *mk = "SHCD";
int get_index(char c)
{
  int i;
  for (i=0; i<4; i++) {
   if (c == *(mk+i))
     return i;
  }
  return -1;
}

int main()
{
  static char tramp[13][4];
  int len;
  int i,j;
  char str[256];

  fgets(str, sizeof(str), stdin);
  sscanf(str, "%d", &len);

  for (i=0; i<len; i++) {
    char m;
    int v;
    fgets(str, sizeof(str), stdin);
    sscanf(str, "%c %d", &m, &v);
    tramp[v-1][get_index(m)] = 1;
  }

  for (i=0; i<4; i++) {
    for (j=0; j<13; j++) {
      if (!tramp[j][i])
        printf("%c %d\n", *(mk+i), j+1);
    }
  }

  return 0;
}

Measured memory_bytes: 604
def main():
    n = int(input())
    arr = list(map(int,input().split()))
    nums = {}
    for i in arr:
        if i not in nums.keys():
            nums[i] = 0

        nums[i] += 1

    total = sum(arr)
    ans = []
    q = int(input())
    for i in range(q):
        b,c = map(int,input().split())
        if b in nums.keys():
            total -= b*nums[b]
            total += c*nums[b]
            count = nums[b]
            del nums[b]
            if c not in nums.keys():
                nums[c] = 0

            nums[c] += count
            
        ans.append(total)

    for i in ans:
        print(i)

main()


Measured memory_bytes: 21872
n, m = gets.split(" ").map(&:to_i)
vote = gets.split(" ").map(&:to_i)

rate = 1 / (4 * m).to_f
vote_all = vote.inject(:+)

border = rate * vote_all

judge = []
vote.each do |num|
  if num >= border
    judge << "Yes"
  end
end

if judge.count("Yes") >= m
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
#include <stdio.h>
#include <string.h>

int getaline(char *);
int str_str(char str[], char word[]);

int main(void)
{
	char w[12];
	char t[1001];
	int n = 0;
	int iw[3];
	memset(w, 0, 12);

	// input w
	getaline(w);
	
	int find_num = 0;

	while(1){
		// input t
		char tp[12];
		memset(tp, 0, 12);
		memset(t, 0, 1001);
		getaline(t);
		//printf("%s\n", t);
		int len_t = strlen(t);
		
		if(len_t == 11 && str_str(t, "END_OF_TEXT")) 
			break;
	
		int i, j;
		char c;
		
		for(i=0, j=0; j < len_t; j++){
			c = t[j];
			if(c >= 'A' && c <='Z') 
					c += 0x20;
			if(c ==' ' || c == '\n'){
				find_num += str_str(tp, w);
				memset(tp, 0, 12);
				i = 0;
				continue;
			}
			if(j == (len_t - 1)){
				tp[i] = c;
				find_num += str_str(tp, w);
				break;
			}
			if(i<12){
				tp[i++] = c;
			}
		}

	}

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



// compare 10 length string
int str_str(char str[], char word[]){
	int find = (str[0] ^ word[0]) || (str[1] ^ word[1]) || (str[2] ^ word[2]) || 
		(str[3] ^ word[3]) || (str[4] ^ word[4]) || (str[5] ^ word[5]) || (str[6] ^ word[6]) ||
		(str[7] ^ word[7]) || (str[8] ^ word[8]) || (str[9] ^ word[9]) || (str[10] ^ word[10]);
	return(find == 0);
}

// input one line and convert capital to small
int getaline(char *s){
	int i = 0;
	while(1){
		int c = getchar();
		if(c == '\n' || c == EOF)
			break;
		s[i++] = c;
	}
	s[i]=0;
	return i;
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

bool e[52525];

int main(){
  float mxh=-1, mnh=1e18;
  float height;
  while(~scanf("%f",&height)){
    if(height==-1.f)break;
    mxh = max(mxh,height);
    mnh = min(mnh,height);
  }
  cout.precision(4);
  cout<<fixed<<(mxh-mnh)<<endl;
  return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const string YES = "YES";
const string NO = "NO";

int main(){
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    REP(np, n - 1){
        const ll nn = n - 1 - np;
        const ll minv = np * c - nn * d;
        const ll maxv = np * d - nn * c;
        if(minv <= b - a && b - a <= maxv){
            cout << YES << endl;
            return 0;
        }
    }
    cout << NO << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1e9+7;
const ll  longinf = 1LL<<60;
const int mod=1e9+7;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<min(a,b)+min(c,d)<<endl;
  return 0;
  }

Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

N, K = getNM()
V = getList()

V = 2 * V

ans = 0
for i in range(1, min(K + 1, N + 1)):
    slow = K - i
    for j in range(N - i, N + 1):
        opt = sorted(V[j: j + i])
        for l in range(min(len(opt), slow)):
            if opt[l] < 0:
                opt[l] -= opt[l]
        ans = max(ans, sum(opt))
print(ans)

Measured memory_bytes: 83932