akhauriyash/Code-Regression huggingface dataset:
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())


#n = ip()                              #入力整数1つ
#a,b= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y= (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
a = input()                                   #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)


#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
s = 0
for i in range(len(a)):
    s+= int(a[i])
j(int(a)%s ==0)

Measured memory_bytes: 13796
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N;
    cin>>N;
    vint L(N);
    for (size_t i = 0; i < N; i++)
    {
        cin>>L[i];
    }
    int ans=0;
    for (size_t i = 0; i < N; i++)
    {
        for (size_t j = i+1; j < N; j++)
        {
            for (size_t k = j+1; k < N; k++)
            {
                if(L[i]==L[k] or L[i]==L[j] or L[k]==L[j])continue;
                if(L[i]<L[j]+L[k] and L[j]<L[i]+L[k] and L[k]<L[i]+L[j])ans++;
            }
            
        }
        
    }
    cout<<ans;
    return 0;
}

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = atan(1.0) * 4.0;
// const int MOD = 998244353;
const ll LINF = 9e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};

void cinfast() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

bool used[100001];
ll a[100000];
ll ans[51];
signed main() {
    LCIN(K);
    REP(i, 50) ans[i] = 49 + K / 50;
    K %= 50;
    REP(i, K) {
        ans[i] += 51;
        REP(i, 50) ans[i]--;
    }
    cout << 50 << "\n";
    REP(i, 50) cout << ans[i] << (i == 49 ? "\n" : " ");
}


Measured memory_bytes: 256
n = int(input())
h = [int(i) for i in input().split()]

dp = [0] * n
dp[1] = abs(h[1] - h[0])
for i in range(2, n):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[n - 1])

Measured memory_bytes: 13980
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iterator>
#include <utility>
#include <string>
#include <algorithm>
#include <time.h>
#include <tuple>
#include <deque>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <iostream>

#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define pll pair<long long, long long>
#define all(v) v.begin(), v.end()

using namespace std;

typedef long long int ll;

mt19937 rnd(time(NULL));

const ll INF = (ll)1e18;
const ll MOD = 1e9 + 7;
const ll maxn = (ll)2 * 1e5 + 10, L = 23;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll x;
    cin >> x;
    cout << x / 500 * 1000 + (x % 500) / 5 * 5;
    return 0;
}

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

int main() {
  
  string a,b,c;
  cin >> a >> b >> c;
  
  if ( ( a.at(a.size() - 1) == b.at(0) ) && ( b.at( b.size() - 1 ) == c.at(0) )){
  	cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
}

Measured memory_bytes: 256
import itertools
H,W = map(int, input().strip().split(' '))

S = [list('.'*(W+2))]
S += [list('.'+input().strip()+'.') for _ in range(H)]
S.append(list('.'*(W+2)))

for x,y in itertools.product(range(1,W+1), range(1,H+1)):
  if S[y][x] == '#': continue
  S[y][x] = sum([S[y+dy][x+dx] == '#' for dx,dy in itertools.product([-1,0,1], repeat=2)])

for y in range(1,H+1):
  print(*S[y][1:-1], sep='')

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

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;
ll fac[100005];
ll rfac[100005];

ll p(ll a, ll x) {
  ll res = 1;
  while(x > 0) {
    if(x & 1) res = a * res % mod;
    a = a * a % mod;
    x >>= 1;
  }
  return res;
}

ll nCr(ll n, ll r) {
  if(n <= 0 || n < r) return 0;
  else return fac[n] * rfac[r] % mod * rfac[n-r] % mod;
}

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

  vector<ll> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];
  
  if(n == 1 || k == 1) {
    cout << 0 << endl;
    return 0;
  }

  fac[0] = rfac[0] = 1;

  for(int i = 1; i <= n; i++) {
    fac[i] = fac[i-1] * i % mod;
    rfac[i] = p(fac[i],mod-2);
  }
  sort(a.begin(),a.end());

  ll MAX = 0, MIN = 0;

  int l = n - 1, r = n - 1;

  while(l >= 0) {
    while(l >= 0 && a[l] == a[r]) l--;
 
    MAX = (MAX + a[r] * ((nCr(r+1,k) - nCr(l+1,k) + mod) % mod) % mod + mod) % mod;
    //  cout << l <<"  "<< r << endl;
    r = l;
    // cout << "MAX = "<< MAX << endl;
  }

 
  
  l = 0; r = 0;
  while(r < n) {
    while(r < n && a[l] == a[r]) r++;
  
    MIN = (MIN + a[l] * ((nCr(n-l,k) - nCr(n-r,k) + mod) % mod) % mod + mod) % mod;
    // cout << l <<"  "<< r << endl;
    l = r;
     
    //  cout << "MIN = "<< MIN << endl;
  }

  cout << (MAX - MIN + mod) % mod << endl;
}
  

  


Measured memory_bytes: 2688
import itertools


N = int(input())

P = "".join(input().split())
Q = "".join(input().split())

p_index = -1
q_index = -1
permutation_list = list(itertools.permutations([x + 1 for x in range(N)]))
for i in range(len(permutation_list)):
    param = "".join(map(str, permutation_list[i]))
    if P == param:
        p_index = i
    if Q == param:
        q_index = i
    if p_index != -1 and q_index != -1:
        print(abs(p_index - q_index))
        exit(0)


Measured memory_bytes: 8052
#include<bits/stdc++.h>
#define ll          long long int
#define ld          long double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         100000000000001
#define MAXN        200005
#define mod         1000000007
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    if(s=="Sunny"){
        cout<<"Cloudy";
    }
    if(s=="Cloudy"){
        cout<<"Rainy";
    }
    if(s=="Rainy"){
        cout<<"Sunny";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<queue>
using namespace std;

int counter=2;
int Map[50][50];
int x[8] = {0,0,1,-1,1,1,-1,-1};
int y[8] = {-1,1,0,0,1,-1,1,-1};
int w,h;

void bfs(int xx,int yy){
  Map[yy][xx]=counter;
  queue<int> q;
  int pos = yy*w+xx;
  q.push(pos);
  while(!q.empty()){
    pos=q.front();
    q.pop();
    yy=pos/w;
    xx=pos%w;
    for(int k=0;k<8;k++){
      int a=xx+x[k];
      int b=yy+y[k];
      if(a < 0 || a >= w || b < 0 || b >= h) continue;
      if(Map[b][a]==1){
	Map[b][a]=counter;
	q.push(b*w+a);
      }
    }
  }
}

int main(){
  while(cin>>w>>h , w+h){
    counter=2;
    memset(Map,0,sizeof(Map));
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin>>Map[i][j];
      }
    }

    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(Map[i][j]==1){
	  bfs(j,i);
	  counter++;
	  //     	  cout<<" i = "<<i<<" j = "<<j<<endl;
	}
      }
    }
    cout<<counter-2<<endl;
  }
  return 0;
}

Measured memory_bytes: 1228
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <queue>
#include<iomanip>
#include <cmath>
#include <set>

#define ABS(x) ((x)>0?(x):-(x))
#define MIN(x,y) ((x)>(y)?(y):(x))

using namespace std;
typedef long long ll;

ll newton(long long int a, long long int  b)
{
	if(a==b)
		return a;
	while(a != 0 && b != 0)
	{
		if(a > b)
		{
			b += a;
			a = b-a;
			b -= a;
		}
		b %= a;
	}
	return a;
}

struct UnionFind {
	vector<int> p;
	UnionFind(int N):p(N)
	{
		for(int i=0; i< N; i++)
		{
			p[i] = i;
		}
	}
	int root(int x)
	{
		if(p[x] == x)
			return x;
		return p[x] = root(p[x]);
	}
	void unite(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		if(rx == ry) return;
		p[rx] = ry;
	}
	bool issame(int x, int y)
	{
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

//大きな数に対する割り算をするとき、MODを指定することで掛け算の値に変換できる

ll div2mul_calc(ll a, ll b, ll m)
{
	if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll d = div2mul_calc(a, b / 2, m);
        return (d * d) % m;
    } else {
        return (a * div2mul_calc(a, b - 1, m)) % m;
    }
}
ll div2mul(ll n, ll mod)
{
	return div2mul_calc(n, mod-2, mod);
}

	int mp[2010][2010] = {0};
	int tot[2010][2010] = {0};
	int tot2[2010][2010] = {0};
int main()
{
	ll i,j,k,n;
	ll mod = 1000000007;
	string L;
	cin >> L;
	ll l_len = L.size();

	ll ans = 0;
	ll cur = 1;
	for(i=0; i< l_len; ++i)
	{
		if(L[i]=='1')
		{
			ans += cur * div2mul_calc(3, l_len-i-1, mod);
			cur *= 2;
			ans %= mod;
			cur %= mod;
		}
	}
	cout << (ans+cur)%mod << endl;

	return 0;
}




































Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    string s;
    cin>>s;
    if(SZ(s)==1)
    {
        cout<<0<<NL;
        return 0;
    }
    int cnt=0;
    int k=SZ(s);
    for(int i=0;i<SZ(s)/2;i++)
    {
        if(s[i]!=s[k-i-1])
        {
            cnt++;
        }
    }
    cout<<cnt<<NL;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

int main() {
    int N; cin >> N;
    int h[N]; rep(i, N) cin >> h[i];

    int ans = 0;
    while (1) {
        int count = 0;
        bool flag = 0;
        rep(i, N) {
            if (flag == 0 && h[i] > 0) {
                count++; flag = 1;
            } else if (flag == 1 && h[i] == 0) {
                flag = 0;
            }

            if (h[i] > 0) h[i]--;
        }

        ans += count;
        if (count == 0) break;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <cstring>
using namespace std;
typedef long long ll;
int main()
{
    //freopen("input.in", "r", stdin);
    ll n, m;
    while(scanf("%lld%lld", &n, &m)!=EOF){
        if(n>m){
            swap(n, m);
        }
        if(n==m || n+1==m)
            printf("Brown\n");
        else printf("Alice\n");
    }
    return 0;
}

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int dp[4][n];
	int a[3];
	int ans;
	for(int j=0;j<3;j++)
	{cin>>a[j];}
	for(int i=0;i<4;i++)
	{
		dp[i][0]=0;
	}
	dp[1][0]=a[0];
	dp[2][0]=a[1];
	dp[3][0]=a[2];
	for(int i=1;i<n;i++)
	{
		for(int j=0;j<3;j++)
		{cin>>a[j];}
		dp[1][i]=max(dp[2][i-1],dp[3][i-1])+a[0];
		dp[2][i]=max(dp[1][i-1],dp[3][i-1])+a[1];
		dp[3][i]=max(dp[1][i-1],dp[2][i-1])+a[2];
	}
	cout<<max(dp[1][n-1],max(dp[2][n-1],dp[3][n-1]));
	
	return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <bitset>
//#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
// namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
// using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main() {
  ll N;
  cin>>N;
  vector<ll> B(N);
  FOR(i,N-1){
    cin>>B[i];
  }
  ll sum=B[0];
  
  FOR(i,N-2){
    sum+=min(B[i],B[i+1]);
  }
  sum+=B[N-2];
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
n, k, s = map(int, input().split())
if s != 10**9:
  for i in range(n):
    if i < k:
      print(s)
    else:
      print(10**9)
else:
  for i in range(n):
    if i < k:
      print(10**9)
    else:
      print(1)

Measured memory_bytes: 48472
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
#include <iostream>
using namespace std;

/* 入力 */

int main() {
  int a,b ;
  cin>>a>>b;
  cout<<max(0,a-2*b)<<endl;

}


Measured memory_bytes: 256
use std::collections::HashSet;

fn main() {
    let nm = read_vec::<u32>();
    let m = nm[1];
    let mut v: Vec<(u32, String)> = Vec::new();
    let mut done: HashSet<u32> = HashSet::new();
    for _ in 0..m {
        let ps = read_vec::<String>();
        let p: u32 = ps[0].parse().ok().unwrap();
        let s = ps[1].clone();
        if s.clone() == "AC" {
            done.insert(p);
        }
        v.push((p, s));
        
    }

    let mut set: HashSet<u32> = HashSet::new();
    let mut wa = 0;
    for i in 0..m {
        let (p, s) = {
            let ps = v[i as usize].clone();
            (ps.0, ps.1)
        };

        if s == "AC" {
            set.insert(p);
        } else {
            if !set.contains(&p) && done.contains(&p) {
                wa += 1;
            }
        }
    }

    println!("{} {}", set.len(), wa);
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 13064
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

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

  ll tot = 0;
  vl s(N);
  rep(i, N){
    cin >> s[i];
    tot += s[i];
  }

  if(tot % 10 != 0){
    cout << tot << endl;
    return 0;
  }

  stable_sort(s.begin(), s.end());

  rep(i, N){
    if(s[i] % 10 != 0){
      cout << tot - s[i] << endl;
      return 0;
    }
  }

  cout << 0 << endl;

  return 0;
}


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

int H, W, d;

int main(){
	scanf("%d%d%d", &H, &W, &d);
	for(int i=1; i<=H; i++)
		for(int j=1; j<=W; j++){
			int x=(i+j)/d%2, y=(i-j+W)/d%2;
			if(x==1 && y==1)	putchar('R');
			if(x==1 && y==0)	putchar('G');
			if(x==0 && y==1)	putchar('B');
			if(x==0 && y==0)putchar('Y');
			if(j==W)	putchar('\n');
		}
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<map>
#include<random>
#include<functional>
#include<utility>

typedef long long ll;

#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
#define P pair<int, int>
#define PLI pair<ll, int>
#define PLL pair<ll, ll>
#define VI vector<int>
#define VII vector<VI>

using namespace std;


int W, H, N;
int main() {
	cin >> W >> H >> N;
	vector<ll> x(N), y(N);
	rep(i, N) {
		cin >> x[i] >> y[i];
	}
	vector<ll> xx(x), yy(y);
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());

	ll ans = 1LL << 60;
	int X, Y;
	for (int midx = (N - 1) / 2; midx <= N / 2; midx++) {
		for (int midy = (N - 1) / 2; midy <= N / 2; midy++) {
			ll mxd = 0, sum = 0;
			rep(i, N) {
				ll dist = abs(xx[i] - x[midx]) + abs(yy[i] - y[midy]);
				mxd = max(mxd, dist);
				sum += dist * 2;
			}
			if (ans > sum - mxd) {
				ans = sum - mxd;
				X = x[midx]; Y = y[midy];
			}
		}
	}

	cout << ans << endl;
	cout << X << ' ' << Y << endl;

	return 0;
}



Measured memory_bytes: 6052
N = int(input())
X = list(map(int,input().split()))
ans = 1000000000000000
for i in range(1,101):
    hp=0
    for j in range(N):
        B = (X[j]-i) ** 2
        hp+=B
    if ans > hp:
        ans=hp

print(ans)
        


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;

int main(){
	int N;
    cin >> N;
    vector<int> T(N), A(N);
    for(int i = 0; i < N; i++) cin >> T[i] >> A[i];

    ll t, a;
    t = T[0]; a = A[0];
    for(int i = 1; i < N; i++){
        ll tx, ay;
        tx = t/T[i]; ay = a/A[i];
        if(t % T[i] != 0) tx++;
        if(a % A[i] != 0) ay++;

        ll n;
        n = max(tx, ay);
        t = n * T[i];
        a = n * A[i];
    }
	
    cout << t + a << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))
cnt = 0
ans =[]
for i in range(N-1):
  if H[i]>=H[i+1]:
    cnt +=1
  else :
    ans.append(cnt)
    cnt = 0
ans.append(cnt)
ans=max(ans)
print(ans)


Measured memory_bytes: 14224
#01:55
#UnionFind最適化に向けた実験
n,m,k = map(int,input().split())
cnt = [1 for _ in range(n)]
pre = [i for i in range(n)]
num = [1 for _ in range(n)]
for _ in range(m):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  num[a] += 1
  num[b] += 1
  A = []
  B = []
  while a != pre[a]:
    a = pre[a]
    A.append(a)
  while b != pre[b]:
    b = pre[b]
    B.append(b)
  if a != b:
    if cnt[a] >= cnt[b]:
      pre[b] = a
      for aa in A:
        pre[aa] = a
      for bb in B:
        pre[bb] = a
      cnt[a] += cnt[b]
      cnt[b] = 0
    else:
      pre[a] = b
      for aa in A:
        pre[aa] = b
      for bb in B:
        pre[bb] = b
      cnt[b] += cnt[a]
      cnt[a] = 0
#print(pre)
#print(cnt)
root = []
ans = []
for i in range(n):
  I = int(i)
  while I != pre[I]:
    I = pre[I]
  root.append(I)
  ans.append(cnt[I]-num[i])
#print(root)
#print(ans)
for _ in range(k):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  if root[a] == root[b]:
    ans[a] -= 1
    ans[b] -= 1
print(' '.join(map(str,ans)))

Measured memory_bytes: 88992
lis = []
for i in range(5):
  lis.append(int(input()))
nmax = 0
index = 0
for v,item in enumerate(lis):
  if item % 10 != 0:
    if 10 - (item % 10) > nmax:
      nmax = 10 - (item % 10)
      index = v
nsum = lis.pop(index)
t = 0
while(t < 4):
  if lis[t]%10 != 0: 
    lis[t] += (10 - (lis[t] % 10))
  t += 1 
nsum += sum(lis)
print(nsum)

Measured memory_bytes: 3064
N,K = map(int,input().split())
NUM=[0]*N
bunsu=[0]*N

for i in range(N):
    for j in range(0,2**10):
        total=(i+1)*(2**j)
        if(total>=K):
            break

    bunsu[i]=1/(N*(2**j))

print(sum(bunsu))


Measured memory_bytes: 6900
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define db cout<<"db: "
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define all(v) v.B,v.E
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int n,i,j,t;
    boost;

    ll a,b;
    cin>>a;
    string s;
    cin>>s;
    b=s[0]-'0';
    b*=10;
    b+=s[2]-'0';
    b*=10;
    b+=s[3]-'0';

    ll x= a*b;
    cout<<x/100;

    return 0;
}



Measured memory_bytes: 3652
#include <iostream>
#include <map>
#include <cstdlib>

using namespace std;

int comp(const void* a,const void* b) {

  pair<int,double>* t1=(pair<int,double>*) a;
  pair<int,double>* t2=(pair<int,double>*) b;

  if(t1->second > t2->second) return 1;

  else if(t1->second < t2->second) return -1;

  else return 0;

}

int main() {

  int id;
  double time;

  pair<int,double> rec1[10],rec2[10],rec3[10],reclose[20];

  while(cin >> id >> time) {

    rec1[0].first=id;
    rec1[0].second=time;

    for(int i=1;i<8;i++) {

      cin >> id >> time;

      rec1[i].first=id;
      rec1[i].second=time;
      
    }

    for(int i=0;i<8;i++) {

      cin >> id >> time;

      rec2[i].first=id;
      rec2[i].second=time;

    }

    for(int i=0;i<8;i++) {

      cin >> id >> time;

      rec3[i].first=id;
      rec3[i].second=time;

    }

    qsort(rec1,8,sizeof(rec1[0]),comp);

    qsort(rec2,8,sizeof(rec2[0]),comp);

    qsort(rec3,8,sizeof(rec3[0]),comp);

    //for(int i=0;i<8;i++) cout << rec1[i].first << " " << rec1[i].second << endl;
    
    for(int i=0;i<18;i++) {

      if(i<6) {

	reclose[i].first=rec1[(i%6)+2].first;
	reclose[i].second=rec1[(i%6)+2].second;

      }

      else if(i<12) {

	reclose[i].first=rec2[(i%6)+2].first;
	reclose[i].second=rec2[(i%6)+2].second;

      }

      else {

	reclose[i].first=rec3[(i%6)+2].first;
	reclose[i].second=rec3[(i%6)+2].second;

      }

    }

    //for(int i=0;i<18;i++) cout << reclose[i].first << " " << reclose[i].second << endl;
    
    qsort(reclose,18,sizeof(reclose[0]),comp);
    
    for(int i=0;i<2;i++) cout << rec1[i].first << " " << rec1[i].second << endl;

    for(int i=0;i<2;i++) cout << rec2[i].first << " " << rec2[i].second << endl;

    for(int i=0;i<2;i++) cout << rec3[i].first << " " << rec3[i].second << endl;

    for(int i=0;i<2;i++) cout << reclose[i].first << " " << reclose[i].second << endl;
    
 }

  return 0;

}
 

Measured memory_bytes: 0
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

int h[575];

int
main(void){  
  ios_base::sync_with_stdio(false);

  int n;
  int hmax = 0, ans = 0;
  cin >> n;
  REP(i, n) {
    cin >> h[i];
    hmax += h[i];
  }
  
  int sum = 0;
  REP(i, hmax){
    int cnt = 0;
    vector<int> v;

    int jtr = 0;
    while(jtr < n){
      if(h[jtr] == 0){
	if(cnt > 0){
	  sum++;
	  cnt = 0;
	}	
      }
      else{
	cnt++;
	if(jtr == n-1) sum++;
      }
      jtr++;
    }
    REP(j, n) if(h[j] != 0) v.push_back(j);
    
    //cout << "sum:" << sum << endl;
    if(v.size() > 0){
      for(auto itr = v.begin(); itr != v.end(); itr++){
	h[*itr]--;	  
      }
    }
    /*
    //check
    REP(j, n) cout << h[j] << " ";
    cout << endl;
    */
  }
  

  
  
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int x,y,a,b,c;
  cin >> x >> y >> a >> b >> c;
  vector <ll> red(a);
  vector <ll> green(b);
  vector <ll> colorless;
  //vector <ll> v;
  for(int i = 0; i < a; i++){
    cin >> red[i];
  }
  for(int i = 0; i < b; i++){
    cin >> green[i];
  }
  for(int i = 0; i < c; i++){
    ll t;
    cin >> t;
    colorless.push_back(t);
  }
  sort(red.rbegin(),red.rend());
  sort(green.rbegin(),green.rend());
  //sort(colorless.rbegin(),colorless.rend());
  ll ans = 0;
  for(int i = 0; i < x; i++){
    colorless.push_back(red[i]);
  }
  for(int i = 0; i < y; i++){
    colorless.push_back(green[i]);
  }
  sort(colorless.rbegin(),colorless.rend());
  for(int i = 0; i < x+y; i++){
    ans += colorless[i];
  }
  cout << ans;
}
         

Measured memory_bytes: 8048
# B

n, d = map(int, input().split())
xy_l = [[int(x) for x in input().split()] for y in range(n)]

d2 = d ** 2
ans = 0
for i in range(n):
    if d2 >= (xy_l[i][0]**2 + xy_l[i][1]**2):
        ans += 1
        
print(ans)

Measured memory_bytes: 42376
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
static const ll max_n = 200010;

ll N, X, Y;

void dfs(string s, char mx){
    if(s.size()==N){
        printf("%s\n", s.c_str());
    }else{
        for(char c = 'a';c <= mx;c++){
            dfs(s+c, ((c==mx)?(char)(mx+1) : mx));
        }
    }
}

int main(){
    // int u, v;
    // bool updated = alse;
    scanf("%lld", &N);

    dfs("", 'a');
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

int main(){
    ll n,m,cnt = 0,sum = 0;
    cin >> n >> m;
    ll a[n];
    rep(i,0,n){
        cin >> a[i];
        sum += a[i];
    }

    rep(i,0,n) if( ( (double)sum/ (4.0*m) ) <= a[i]) cnt++;
    
    cout << ((cnt >= m) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		int[] f = new int[n];
		for(int i =  0; i < n; i++) {
			f[i] = 0;
		}
		
		int a, b;
		for(int i = 0; i < m; i++) {
			a = sc.nextInt();
			b = sc.nextInt();
			
			f[a-1]++;
			f[b-1]++;
		}
		
		for(int x : f) {
			System.out.println(x);
		}

	}

}


Measured memory_bytes: 23252
n = int(input())
p_lst = list(map(int,input().split()))
q_lst = list(map(int,input().split()))
p_used = []
q_used = []
a = 0
b = 0

def factorial(n):
    answer = 1
    for i in range(1,n+1):
        answer *= i
    return answer

for i in range(n-1):
    p = p_lst[i]
    k = 0
    for l in range(len(p_used)):
        tmp = [j for j in range(1,p)]
        if p_used[l] in tmp:
            k += 1
    a += (p-1-k)*factorial(n-1-i)
    p_used.append(p)

for i in range(n-1):
    q = q_lst[i]
    k = 0
    for l in range(len(q_used)):
        tmp = [j for j in range(1,q)]
        if q_used[l] in tmp:
            k += 1
    b += (q-1-k)*factorial(n-1-i)
    q_used.append(q)

print(abs(a-b))

Measured memory_bytes: 38256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
using namespace std;

int main(){
  int N;
  cin>>N;
  int DP[N+1][3];
  DP[0][0]=0;
  DP[0][1]=0;
  DP[0][2]=0;
  
  for(int i=1; i<=N; ++i){
    int a,b,c;
    cin>>a>>b>>c;
    DP[i][0]=max(DP[i-1][1],DP[i-1][2])+a;
    DP[i][1]=max(DP[i-1][2],DP[i-1][0])+b;
    DP[i][2]=max(DP[i-1][0],DP[i-1][1])+c;
  }
  cout<<max(DP[N][0],max(DP[N][1],DP[N][2]))<<endl;
}


Measured memory_bytes: 1408
N,*L = open(0).read().split()

ans = 0
a = 0
b = 0
c = 0
for s in L:
  for j in range(len(s)-1):
    if s[j]=='A' and s[j+1]=='B':
      ans += 1
  if s[-1]=='A' and s[0]=='B':
    c += 1
  elif s[-1]=='A':
    a += 1
  elif s[0]=='B':
    b += 1
if c!=0:
  if a+b>0:
    ans += c+min(a,b)
  else:
    ans += c-1
else:
  ans += min(a,b)
print(ans)

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

int main() {
	int N;
	while (cin >> N, N != 0) {
		int a[10] = {},field = 0;
		string str;
		char c;

		cin >> str;

		for (int i = 0; i < 100; i++) {
			c = str[i];

			if (c == 'M')
				a[i % N]++;
			if (c == 'S') {
				field += a[i % N] + 1;
				a[i % N] = 0;
			}
			if (c == 'L'){
				a[i % N] += field + 1;
				field = 0;
			}
		}
		sort(a, a + N);
		for (int i = 0; i < N; i++) {

			cout << a[i]<<" ";

		}
		cout << field << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int l, r; cin >> l >> r;
    int mod = 2019;
    if (r-l >= 2019 || l%mod == 0 || r%mod == 0) {
        cout << 0 << endl;
        return 0;
    }

    int mo = 2019;
    for (ll i=l; i<r; i++) {
        for (ll j=l+1; j<=r; j++) {
            int lmo = i%mod;
            int rmo = j%mod;
            mo = min(mo, lmo*rmo%mod);
        }
    }

    cout << mo << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int N;
    cin >> N;
    
    int N1 = N%10;
    int N10 = N/10;

    if(N1==9 || N10==9){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <cstring>
#include <bitset>
#include <cmath>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<long long> VI;
typedef unsigned long long ull;
const ll inff = 0x3f3f3f3f3f3f3f3f;
#define FOR(i,a,b) for(int i(a);i<=(b);++i)
#define FOL(i,a,b) for(int i(a);i>=(b);--i)
#define SZ(x) ((long long)(x).size())
#define REW(a,b) memset(a,b,sizeof(a))
#define inf int(0x3f3f3f3f)
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define mod ll(998244353)
#define pb push_back
#define eps 1e-6
#define lc d<<1
#define rc d<<1|1
#define Pll pair<ll,ll>
#define P pair<int,int>
#define pi acos(-1)
int n,a[100008],ans;
int main()
{
    cin.tie(0);
    cout.tie(0);
    cin>>n;
    FOR(i,1,n) si(a[i]);
    sort(a+1,a+n+1);
    ans=a[n/2+1]-a[n/2];
    if(ans<0) ans=0;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;

int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};

#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piiii pair<pii,pii>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define logg2 0.30102999566398119521373889472449L
#define plii pair<ll,pii>
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
const int maxn=1e5+5;


int h,w;
vector<string> grid;
int dis[450][450];
string s;
void solve(){
    cin>>h>>w;
    for(int i=0;i<h*w;i++)
        for(int j=0;j<h*w;j++){
            if(i==j) dis[i][j]=0;
            else dis[i][j]=MAX;
        }
    for(int i=1;i<=h;i++){
        cin>>s;
        grid.push_back(s);
    }
    int di,dj,p,q;

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            for(int k=0;k<4;k++){
                di=i+dx[k];dj=j+dy[k];

                if(di<0 || dj<0 || di>=h || dj>=w) continue;
                else if(grid[i][j]=='#' || grid[di][dj]=='#') continue;

                p=i*(w)+j;q=di*(w)+dj;
                //cout<<p<<" "<<q<<endl;
                dis[p][q]=1;
                dis[q][p]=1;
            }
        }
    }
    /*
    for(int i=0;i<h*w;i++){
        for(int j=0;j<h*w;j++){
            cout<<dis[i][j]<<" ";
        }
        cout<<endl;
    }
    */

    int maxx=-1;
    for(int k=0;k<h*w;k++){
        for(int i=0;i<h*w;i++){
            for(int j=0;j<h*w;j++){

                dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
            }
        }
    }
    /*
    for(int i=0;i<h*w;i++){
        for(int j=0;j<h*w;j++){
            cout<<dis[i][j]<<" ";
        }
        cout<<endl;
    }
    */
    for(int i=0;i<h*w;i++)
    for(int j=0;j<h*w;j++){
        if(dis[i][j]<MAX) maxx=max(maxx,dis[i][j]);
    }

    cout<<maxx;
    return;
}
int main(){
    IO

    //TEST
    solve();
    return(0);
}


Measured memory_bytes: 4284
#include <stdio.h>
int main(void){
    int a,b,c,d,e,k;
    scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&k);
    if(e-a<=k)
    {printf("Yay!");}
    else
    {printf(":(");}
}


Measured memory_bytes: 128
use std::cmp;
use std::collections::*;
use std::i32;
use std::io::{self, Read};
use std::mem;

const MOD: usize = 1000000007;

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock());

    let h: usize = sc.read().unwrap();
    let w: usize = sc.read().unwrap();
    let b: Vec<Vec<char>> = sc.read_board(h).unwrap();

    // // h 行目の障害物の数
    // let mut ho = Vec::with_capacity(h);
    // // w 列目の障害物の数
    // let mut wo = vec![0 as usize; w];
    // for i in 0..h {
    //     let mut l: usize = 0;
    //     for j in 0..w {
    //         if b[i][j] == '#' {
    //             l = l + 1;
    //             wo[j] = wo[j] + 1;
    //         }
    //     }
    //     ho.push(l);
    // }
    // println!("ho = {:?}", ho);
    // println!("wo = {:?}", wo);

    let mut t = Vec::with_capacity(h);
    // 横方向の探索
    for i in 0..h {
        t.push(vec![0 as usize; w]);

        let mut j: usize = 0;
        while j < w {
            // 横方向の障害物がないマスを数える
            let mut jj: usize = j;
            while jj < w && b[i][jj] == '.' {
                jj = jj + 1;
            }

            for k in j..jj {
                t[i][k] = jj - j;
            }
            j = jj + 1;
        }
    }

    // 縦方向の探索
    for j in 0..w {
        let mut i: usize = 0;
        while i < h {
            // 横方向の障害物がないマスを数える
            let mut ii: usize = i;
            while ii < h && b[ii][j] == '.' {
                ii = ii + 1;
            }

            for k in i..ii {
                t[k][j] = t[k][j] + (ii - i);
            }
            i = ii + 1;
        }
    }

    // println!("{:?}", t);

    let mut max: usize = 0;
    for i in 0..h {
        for j in 0..w {
            max = cmp::max(t[i][j], max);
        }
    }

    println!("{}", max - 1);
}

struct Scanner<R: Read> {
    reader: R,
}

impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: std::str::FromStr>(&mut self) -> Option<T> {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse()
            .ok()
    }

    fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Option<Vec<T>> {
        (0..n).map(|_| self.read()).collect()
    }

    fn read_vec2d<T: std::str::FromStr>(&mut self, m: usize, n: usize) -> Option<Vec<Vec<T>>> {
        (0..m).map(|_| self.read_vec(n)).collect()
    }

    fn read_board(&mut self, n: usize) -> Option<Vec<Vec<char>>> {
        (0..n)
            .map(|_| {
                self.read::<String>()
                    .map(|s| s.chars().collect::<Vec<char>>())
            })
            .collect()
    }
}


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


using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 1010;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}



// Main Code
int main()
{
	int n;
	cin>>n;
	vector<ll> v(n);
	rep(i, 0, n)
		cin>>v[i];
	sort(all(v));
	ll m = v[n-1] / 2;
	ll dist = INT_MAX;
	ll ans = 0;
	rep(i, 0, n-1)
	{
		ll d = abs(m - v[i]);
		if(d == dist)
		{
			ll l = min(ans, v[n-1] - ans);
			ll r = min(v[i], v[n-1] - v[i]);
			if(l < r)
			{
				ans = v[i];
			}
		}
		else if(dist > d)
		{
			dist = d;
			ans = v[i];
		}
	}
	cout<<v[n-1]<<" "<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

const ll INF = 1LL<<60;



int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    cin >> n >> m;
    vll a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];
    vll c(m), d(m);
    rep(i, m) cin >> c[i] >> d[i];
    vi ans(n);
    auto dist = [](ll x1, ll x2, ll y1, ll y2){
        ll dx = x1 - x2, dy = y1 - y2;
        return abs(dx) + abs(dy);
    };
    rep(i, n) {
        int idx = 0;
        ll mn = INF;
        rep(j, m) {
            if (chmin(mn, dist(a[i], c[j], b[i], d[j]))) idx = j+1;
        } 
        ans[i] = idx;
    }
    rep(i, n) cout << ans[i] << endl;
}

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

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

Measured memory_bytes: 256
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
    string s;
    std::cin >> s;
    ll lose = 0;
    for (int i = 0; i < s.length(); i++) {
        if(s[i] == 'x'){
            lose++;
        }
    }
    if(lose>=8){
        std::cout << "NO" << std::endl;
    }else{
        std::cout << "YES" << std::endl;
    }
}


Measured memory_bytes: 256
import sys

a,b,k=map(int,input().split())
list=[]
if (b-a)<=k*2-1:
	for l in range(b-a+1):
		print(l+a)
	sys.exit()
for i in range(a,a+k):
	list.append(i)
for j in range(b,b-k,-1):
	list.append(j)
list.sort()
for k in range(len(list)):
	print(list[k])

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	ll n;cin >> n;
	ll seica = 0;
	vector<ll> v(n);REP(i, n)cin >> v[i], seica ^= v[i];
	REP(i, n)cout << (seica ^ v[i]) << " ";cout << endl;

	return 0;
}


Measured memory_bytes: 4780
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef double db;
#define go(u) for(int i = head[u], v = e[i].to; i; i=e[i].lst, v=e[i].to)
#define rep(i, a, b) for(int i = a; i <= b; ++i)
#define pb push_back
#define re(x) memset(x, 0, sizeof x)
inline int gi() {
    int x = 0,f = 1;
    char ch = getchar();
    while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar();}
    while(isdigit(ch)) { x = (x << 3) + (x << 1) + ch - 48; ch = getchar();}
    return x * f;
}
template <typename T> inline bool Max(T &a, T b){return a < b ? a = b, 1 : 0;}
template <typename T> inline bool Min(T &a, T b){return a > b ? a = b, 1 : 0;}
const int N = 1e6 + 7, mod = 1e6 + 3;
int Q;
LL fac[N], invfac[N], inv[N];
LL Pow(LL a, LL b) {
	LL res = 1ll;
	for(; b; b >>= 1, a = a * a % mod) if(b & 1) res = res * a % mod;
	return res;	
}
int main() {
#ifdef fwat
#endif
	Q = gi();
	inv[1] = fac[0] = invfac[0] = 1;
	rep(i, 1, mod - 1) {
		if(i ^ 1) inv[i] = (mod - mod / i) * inv[mod % i] % mod;
		fac[i] = fac[i - 1] * i % mod;
		invfac[i] = invfac[i - 1] * inv[i] % mod;
	}
	while(Q--) {
		int x = gi(), d = gi(), n = gi();
		if(d == 0) { printf("%lld\n", Pow(x, n)); continue;}
		int st = x * inv[d] % mod;
		if(st == 0 || mod - st < n) { puts("0"); continue;}
		printf("%lld\n", fac[st + n - 1] * invfac[st - 1] % mod * Pow(d, n) % mod);
	}
	return 0;
}

Measured memory_bytes: 24320
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
    
int main()
{
	float p1=0,p4=0;
	double p2=0,p3=0;
	int n;
	cin >> n;
	int *x = new int[n];
	int *y = new int[n];
	for (int i = 0; i < n; i++)
		cin >> x[i];
	for (int i = 0; i < n; i++) {
		cin >> y[i];
		if (x[i] > y[i])
			x[i] -= y[i];
		else
			x[i] = y[i] - x[i];
		p1 += x[i];
		p2 += pow(x[i],2); 
		p3 += pow(x[i],3);
		if (p4 < x[i])
			p4 = x[i];
	}		
	cout << fixed << setprecision(5)
		 << p1 << endl
		 << sqrt(p2) << endl
		 << pow(p3,1.0/3.0) << endl
		 << p4 << endl;
	delete []x,y;
	return 0;
}

Measured memory_bytes: 3388
import sys
N = int(input())
A = [int(input()) for _ in range(N)] 
A_max1 = max(A)
if A.count(A_max1) >= 2:
    for i in range(N):
        print(A_max1)
    sys.exit()    
elif  A.count(A_max1) == 1:
    A[A.index(A_max1)] = 0
    A_max2 = max(A)
    A[A.index(0)] = A_max1
    for i in range(N):
        if A[i] == A_max1:
            print(A_max2)
        else:
            print(A_max1)


Measured memory_bytes: 12532
def main():
    from heapq import heappop, heappush, heapify

    LIMIT = 10 ** 18

    N = int(input())
    *A, = map(int, input().split())

    heapify(A)

    if A[0] is 0:
        print(0)
        return

    while len(A) > 1:
        x = heappop(A)
        y = heappop(A)
        heappush(A, x * y)

    ans = heappop(A)
    print(ans if ans <= LIMIT else -1)


if __name__ == '__main__':
    main()


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

void answer1() {
  int N, K;
  cin >> N >> K;
  vector<int> bucket(N + 1, 0);
  int in;
  while (cin >> in) {
    bucket.at(in)++;
  }
  sort(bucket.begin(), bucket.end());

  int count = 0;
  for (int i = 0; i < bucket.size() - K; i++) {
    count += bucket.at(i);
  }
  cout << count << endl;
}

void answer2() {
//  cin.tie(0);
//	ios_base::sync_with_stdio(false);
//
  int N, K;
  cin >> N >> K;
  int bucket[200001] = {0};
  int in;
  while (cin >> in) {
    bucket[in]++;
  }
  sort(bucket, bucket + N, greater<int>());

  int count = N;
  for (int i = 0; i < K; i++) {
    count -= bucket[i];
  }
  cout << count << endl;
}

int main() {
  //answer1();
  answer2();
}


Measured memory_bytes: 1024