akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 2e5 + 5;
const ll maxm = 1e3 + 5;
namespace IO{
    const int SIZE = (1 << 20) + 1;
    char ibuf[SIZE], *iS, *iT, obuf[SIZE],*oS = obuf, *oT = obuf + SIZE - 1;
    char _st[55];
    int _qr = 0;
    inline char gc(){
        return (iS == iT ? iT = (iS = ibuf) + fread(ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS++) : *iS++);
    }
    inline void qread(){}
    template<class T1, class ...T2>
    inline void qread(T1 &IEE, T2&... ls){
        register T1 __ = 0, ___ = 1;
        register char ch;
        while(!isdigit(ch = gc())) ___ = (ch == '-') ? -___ : ___;
        do{
            __ = (__ << 1) + (__ << 3) + (ch ^ 48);
        }while(isdigit(ch = gc()));
        __ *= ___;
        IEE = __;
        qread(ls...);
        return ;
    }
    inline void flush(){
        fwrite(obuf, 1, oS - obuf, stdout);
        oS = obuf;
        return ;
    }
    inline void putc_(char _x){
        *oS++ = _x;
        if(oS == oT) flush();
    }
    inline void qwrite(){}
    template<class T1, class ...T2>
    inline void qwrite(T1 IEE, T2... ls){
        if(!IEE) putc_('0');
        if(IEE < 0) putc_('-'), IEE = -IEE;
        while(IEE) _st[++_qr] = IEE % 10 + '0', IEE /= 10;
        while(_qr) putc_(_st[_qr--]);
        qwrite(ls...);
        return ;
    }
    struct Flusher_{~Flusher_(){flush();}}io_flusher;
}
using namespace IO;
ll n, cnt;
ll a[maxn];
ll ct[1000000 + 5];
int main(){
    qread(n);
    for(int i = 1;i <= n;i++){
        qread(a[i]);
        ct[a[i]]++;
    }
    for(int i = 1;i <= n;i++){
        bool f = 0;
        if(ct[a[i]] > 1){
            f = 1;
        }
        if(a[i] != 1 && ct[1] >= 1){
            f = 1;
        }
        for(int j = 2;j * j <= a[i];j++){
            if(a[i] % j) continue;
            if(ct[j] || ct[a[i] / j]){
                f = 1;
                break;
            }
        }
        if(!f) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 13836
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;

int main() {

	int r0, w, c, r;
	while(cin >> r0 >> w >> c >> r, r0){
		
		int ans = 0;
		int rr = r0;
		// rr >= c * w
		while(rr < c * w){
			rr += r;
			ans++;
		}
		cout << ans << endl;
		
	}

	return 0;
}

Measured memory_bytes: 3080
N = int(input())
A = list(map(int,input().split()))
counts = [0,0,0]
out = 1
for i in range(N):
  cur = 0
  for j in range(3):
    if counts[j] == A[i]:
      cur += 1
  out *= cur
  out %= 1000000007
  for j in range(3):
    if counts[j] == A[i]:
      counts[j] += 1
      break
print(out)

Measured memory_bytes: 13964
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

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

#define pb push_back
#define fr first
#define sc second

const int INF = 1000000000;

struct SEG{
	int l;
	int r;
	int m[2];
	int loc[2];
	bool ch;
	SEG *chl,*chr;
	void init(int l_,int r_,int m0 = INF,int m1 = INF,int loc0 = -1,int loc1 = -1){
		l = l_;
		r = r_;
		m[0] = m0;
		m[1] = m1;
		loc[0] = loc0;
		loc[1] = loc1;
		ch = false;
	}
	void mkch(){
		chl = new SEG;
		chl->init(l,(l+r)/2);
		chr = new SEG;
		chr->init((l+r)/2,r);
		ch = true;
	}
	void set(int a,int x){
		if(a < l || r <= a)return;
		if(l == a && r == a+1){
			m[a&1] = x;
			loc[a&1] = a;
			return;
		}
		if(!ch)mkch();
		chl->set(a,x);
		chr->set(a,x);
		int ml = chl->m[a&1];
		int mr = chr->m[a&1];
		if(ml <= mr){
			m[a&1] = ml;
			loc[a&1] = chl->loc[a&1];
		}
		else {
			m[a&1] = mr;
			loc[a&1] = chr->loc[a&1];
		}
	}
	pair<int,int> min_loc(int a,int b,int c){
		if(b <= l || r <= a)return pair<int,int>(INF,-1);
		if(a <= l && r <= b)return pair<int,int>(m[c],loc[c]);
		P pl = chl->min_loc(a,b,c);
		P pr = chr->min_loc(a,b,c);
		return min(pl,pr);
	}
}seg;

struct node{
	int a;
	int b;
	node* ch[3];
	bool operator < ( const node y ) const {
		if(this->a == y.a)return this->b < y.b;
		else return this->a < y.a;
	}
	bool operator > ( const node y ) const {
		if(this->a == y.a)return this->b > y.b;
		else return this->a > y.a;
	}
};

node* sol(int l,int r){
	if(r-l == 0)return nullptr;
	node* ret = new node;
	P a = seg.min_loc(l,r,l&1);
	P b = seg.min_loc(a.sc+1,r,(r+1)&1);
	ret->a = a.fr;
	ret->b = b.fr;
	ret->ch[0] = sol(l,a.sc);
	ret->ch[1] = sol(a.sc+1,b.sc);
	ret->ch[2] = sol(b.sc+1,r);
	return ret;
}

int main(){
	int N;
	int p[200010];
	scanf("%d",&N);
	for(int i = 1 ; i <= N ; i ++){
		scanf("%d",&p[i]);
	}
	
	seg.init(0,1<<18);
	for(int i = 1 ; i <= N ; i ++){
		seg.set(i,p[i]);
	}
	
	node *ans = sol(1,N+1);
	vector<int> ret;
	priority_queue<node,vector<node>,greater<node>> que;
	que.push(*ans);
	while(!que.empty()){
		node q = que.top(); que.pop();
		ret.pb(q.a);
		ret.pb(q.b);
		for(int i = 0 ; i < 3 ; i ++){
			if(q.ch[i] == nullptr)continue;
			que.push(*q.ch[i]);
		}
	}
	for(int i = 0 ; i < ret.size() ; i ++){
		printf("%d%c",ret[i],(i==ret.size()-1)?'\n':' ');
	}
}



Measured memory_bytes: 59508
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  ll n;
  cin>>n;
  ll a[n];
  ll m=0;
  ll o=0;
  ll c=INF;
  rep(i,n) {
    cin>>a[i];
      m=max(m,a[i]);
    if(a[i]==m){
      c=i;
  }
  
  }
  
  rep(i,n){
    if(c!=i) o=max(o,a[i]);
  }
  
  rep(i,n){
    if(a[i]!=m){
    cout<<m<<endl;
    }
    else{
      cout<<o<<endl;
    }
  }
}
  



Measured memory_bytes: 3200
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

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

  int D;
  cin>>D;
  
  int C[27];
  int S[366][27];
  int last[366][27];

  for(int d=1;d<=26;d++) cin>>C[d];
  for(int d=1;d<=D;d++){
    for(int i=1;i<=26;i++) cin>>S[d][i];
  }

  for(int d=1;d<=D;d++){
    int mi=1;
    int max=-1e9;
    for(int i=1;i<=26;i++){
      int tmp=S[d][i];
      for(int j=1;j<=26;j++){
        if(j!=i) tmp-=C[j]*(d-last[d-1][j]);
      }
      if(max<tmp){
        max=tmp;
        mi=i;
      }
    }
    for(int i=1;i<=26;i++) last[d][i]=last[d-1][i];
    last[d][mi]=d;
    cout<<mi<<endl;
  }

  return 0;
}

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

using namespace std;

using int64 = long long;

int main() {
  int N;
  int S[5] = {};
  string X = "MARCH";
  cin >> N;
  for(int i = 0; i < N; i++) {
    string x;
    cin >> x;
    auto p = X.find(x[0]);
    if(p == string::npos) continue;
    S[p]++;
  }
  int64 sum = 0;
  for(int i = 0; i < 5; i++) {
    for(int j = i + 1; j < 5; j++) {
      for(int k = j + 1; k < 5; k++) {
        sum += 1LL * S[i] * S[j] * S[k];
      }
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(void){
    while(1){
        char x[50][50];
        char y[1000];
        int h, w;
        scanf("%d%d",&h,&w);
        if(h==0) break;
        for(int i=0;i<h;i++)
        scanf("%s",x[i]);
        scanf("%s",y);
        //printf("%s\n",y);
        int nh=0, nw=0;
        int t = 0;
        for(int i=0;y[i]!='\0';i++){
            for(int j=0;j<h;j++){
                for(int k=0;k<w;k++){
                    if(x[j][k]==y[i]){
                        t += abs(nh-j)+abs(nw-k)+1;
                        nh = j; nw = k;
                    }
                }
            }
        }
        printf("%d\n",t);
    }
}



Measured memory_bytes: 2052
#include <iostream>

using namespace std;

int main(){
  int min,minc,n,m,a,t,mini,minqd,minqdc,minqdi;

  cin >> n >> m;

  while (n !=0 || m !=0){
    cin >> a;
    min=m - m % a;
    minc=1;
    mini=1;
    minqd=a;
    minqdi=1;
    minqdc=1;
    for (int i = 1;i<n;i++){
      cin >> a;
      if ((min/a+1)*a > m) t = (min/a)*a;else t=(min/a+1)*a;
      if (t == min) {
	minc ++;
	if (minqd==a) minqdc ++;
	else if(minqd>a){
	  	minqd=a;
		minqdi=i+1;
		minqdc=1;
	}
      } else if(t<min){
	min=t;
	mini=i+1;
	minc=1;
	minqd=a;
	minqdi=i+1;
	minqdc=1;
      }
    }
    if (minc>=2){
      if (minqdc>=2) cout << n << endl;
      else cout << minqdi << endl;
    }else cout << mini << endl;

    cin >> n >> m;
  }

  return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <iostream>
#include <math.h>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	char[] s;//原文
	int index;//今なん文字目か
	int[] table;//PQRの値
	public static void main(String[] args) {
		new Main().run();
	}
	void run(){
		Scanner sc=new Scanner(System.in);
		while(true){
			String str=sc.next();
			if(str.equals(".")) break;
			//s=(str+"$").toCharArray();
			s=str.toCharArray();
			table=new int[3];
			int ans=0;
			for(int p=0; p<3; p++){
				table[0]=p;
				for(int q=0; q<3; q++){
					table[1]=q;
					for(int r=0; r<3; r++){
						table[2]=r;
						index=0;
						if(formura()==2) ans++;
					}
				}
			}
			System.out.println(ans);
		}
	}
	int formura(){
		int r=term();
		while(index < s.length){
			char c = c();
			if(c == '*'){
				int a = term();
				r = Math.min(r, a);
			}
			else if(c == '+'){
				int a = term();
				r = Math.max(r, a);
			}
			else break;
		}
		return r;
	}
	int term(){
		char c=c();
		if(c=='('){
			int r=formura();
			return r;
		}
		if(c=='-'){
			int r=term();
			if(r==2){
				return 0;
			}
			else if(r==1){
				return 1;
			}
			else if(r==0){
				return 2;
			}
		}
		if(Character.isDigit(c)) return c-'0';
		if(c=='P'){
			return table[0];
		}
		else if(c=='Q'){
			return table[1];
		}
		else if(c=='R'){
			return table[2];
		}
		return -1;
	}
	char c(){
		return s[index++];
	}
}

Measured memory_bytes: 34564
n,k=map(int,input().split())
s=input()
l=[]
if s[0]=="0":
  l.append(0)

from itertools import groupby,accumulate
gr=groupby(s)

for K,g in gr:
  l.append(len(list(g)))

l_sum=list(accumulate(l))
l_sum=[0]+l_sum

add=2*k+1
ans=0
for i in range(0,len(l)+1,2):
  left=i
  right=min(i+add,len(l))
  tmp=l_sum[right]-l_sum[left]
  ans=max(tmp,ans)
print(ans)

Measured memory_bytes: 8712
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>>name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
inline int scan(){ return getchar(); }
inline void scan(int &a){ scanf("%d", &a); }
inline void scan(unsigned &a){ scanf("%u", &a); }
inline void scan(long &a){ scanf("%ld", &a); }
inline void scan(long long &a){ scanf("%lld", &a); }
inline void scan(unsigned long long &a){ scanf("%llu", &a); }
inline void scan(char &a){ cin >> a; }
inline void scan(float &a){ scanf("%f", &a); }
inline void scan(double &a){ scanf("%lf", &a); }
inline void scan(long double &a){ scanf("%Lf", &a); }
inline void scan(vector<bool> &vec){ for(unsigned i = 0; i < vec.size(); i++) { int a; scan(a); vec[i] = a; } }
inline void scan(string &a){ cin >> a; }
template<class T> inline void scan(vector<T> &vec);
template<class T, size_t size> inline void scan(array<T, size> &vec);
template<class T, class L> inline void scan(pair<T, L> &p);
template<class T, size_t size> inline void scan(T (&vec)[size]);
template<class T> inline void scan(vector<T> &vec){ for(auto &i : vec) scan(i); }
template<class T, size_t size> inline void scan(array<T, size> &vec){ for(auto &i : vec) scan(i); }
template<class T, class L> inline void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template<class T, size_t size> inline void scan(T (&vec)[size]){ for(auto &i : vec) scan(i); }
template<class T> inline void scan(T &a){ cin>>a; }
inline void in(){}
template <class Head, class... Tail> inline void in(Head &head, Tail&... tail){ scan(head); in(tail...); }
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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; }
using Graph = vector<vector<int>>;
/* 4方向への隣接頂点への移動を表すベクトル */
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

const long long INF = 1LL << 60;
int main(){
    INT(N);
    VEC(int,d,N);
    ll ans = 0LL;
    for(int i = 0; i < N; i++){
        for(int j = i + 1; j < N; j++){
            ans += d[i]*d[j];
            }
    }
    cout << ans << endl;   
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[100000],dp[100][100];

int main(){
  cin >> n >> m >> l;
  if(n <= l && l <= m)puts("Yes");
  else puts("No");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
#define MOD_BIG2 998244353
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using std::vector;

#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

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


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

int main() {
    
    string S, T;
    cin >> S >> T;
    cout << T << S << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

int solve()
{
    int n;
    cin >> n;

    vector<ull> v = fetch_vec<ull>(n);
    const ull mod = 10e8 + 7;
    ull sum = 0;

    for (int bit = 0; bit < 60; ++bit)
    {
        int counter = 0;
        ull mult = 1LL << bit;
        for (int i = 0; i < n; ++i)
        {
            if (v[i] & mult)
                ++counter;
        }

        sum  = (sum + mult % mod * counter % mod * (n - counter) % mod) % mod;
    }

    cout << sum << endl;

    return 0;
}

int main()
{
    solve();

    return 0;
}

Measured memory_bytes: 2560
import java.util.*;

public class Main
{

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

		int N = sc.nextInt();

		int [] height;
		height = new int[N];

		int[]dp;
		dp = new int[N];

		//height入力
		for(int i=1;i<=N;i++)
		{
		height[i-1]=sc.nextInt();
		}

		//dp初期化
		for(int i=1;i<=N;i++)
		{
		dp[i-1]=0;
		}
		dp[1]=Math.abs(height[1]-height[0]);

		//dp実行
		for(int j=3;j<=N;j++)
		{
			int k;
			int l;
			k = dp[j-3] + Math.abs(height[j-1]-height[j-3]);
			l = dp[j-2] + Math.abs(height[j-1]-height[j-2]);
			dp[j-1] = min(k,l);
		}
		System.out.println(dp[N-1]);
	}

	//dp更新用の関数定義
	public static int min(int i,int j)
	{
		 return Math.min(i,j);
	}

}

Measured memory_bytes: 59312
package main

import (
  "fmt"
  "strings"
)

func main() {
  var a, b, c string
  
  fmt.Scanf("%s %s %s", &a, &b, &c)
  
  ans := "YES"
  if !strings.HasSuffix(a, b[:1]) {
  	ans = "NO"
  }
  if !strings.HasSuffix(b, c[:1]) {
  	ans = "NO"
  }
  
  fmt.Printf("%s", ans)
}

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

int main(){

	int n, k, a;
	cin >> n >> k;
	map<int,int> m;
	for(int i = 0; i<n;i++){
		cin >> a;
		m[a]++;
	}
	int result = 0;
	vector<int> v;
	for(auto x:m) {
		v.push_back(x.second);
	}
	sort(v.rbegin(),v.rend());
	for(int i = k;i<(int) v.size();i++) result+=v[i];
	cout << result;
}


Measured memory_bytes: 10748
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
int N;
vector<int> v;
int a[100100];
int comp(int a,int b)
{
	if(a==b)return 0;
	if(a<b)return 1;
	else return -1;
}
int main()
{
	cin >> N;
	rep(i,N)cin >> a[i];
	rep(i,N-1)v.pb(comp(a[i],a[i+1]));
	v.erase(unique(all(v)),v.end());
	int h=0,b=0,p=0,m=0,k=0;
	int vs = v.size();
	for(int i=2;i<vs;i++)if(v[i]==-1&&v[i-1]==0&&v[i-2]==1)h++;
	for(int i=2;i<vs;i++)if(v[i]==1&&v[i-1]==0&&v[i-2]==-1)b++;
	for(int i=2;i<vs;i++)if(v[i]*v[i-2]>0&&v[i-1]==0)p++;
	for(int i=1;i<vs;i++)if(v[i]==-1&&v[i-1]==1)m++;
	for(int i=1;i<vs;i++)if(v[i]==1&&v[i-1]==-1)k++;
	printf("%d %d %d %d %d\n",h,b,p,m,k);
	return 0;
}


Measured memory_bytes: 2060
#include<stdio.h>
int main(void)
{
	int n,k,p,i;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&k);
		scanf("%d",&p);
		if(k%p==0){
			printf("%d\n",p);
		}
		else{
			printf("%d\n",k%p);
		}
	}
	return 0;
}


Measured memory_bytes: 2104
#include <stdio.h>
int a, b, c, k;
int main()
{
    int i;
    scanf("%d %d %d %d",&a,&b,&c,&k);
    for (i=0;i<k;i++) {
        if (a>=b&&a>=c) a*=2;
        else if (b>=c&&b>=a) b*=2;
        else c*=2;
    }
    printf("%d",a+b+c);
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long int a , b , c , d , x;
    cin >> a >> b >> x;
    c = b / x;
    d = ( a - 1 ) / x;
    if ( a == 0 ) d = -1;
    cout << c - d;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2147483600;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};




int main(void){
    string S, T;
    cin >> S >> T;
    vector<int> s(S.size());
    vector<int> t(T.size());
    for(int i = 0; i < S.size(); i++){
        s[i] = S[i] - 'a';
    }
    for(int i = 0; i < T.size(); i++){
        t[i] = T[i] - 'a';
    }
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    
    while(s.size() < t.size()){
        s.push_back(-1);
    }
    while(t.size() < s.size()){
        t.push_back(-1);
    }
    
    
    bool l = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] < t[i]){
            l = 1;
            break;
        }else if(s[i] > t[i]){
            l = 0;
            break;
        }
    }
    if(l){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  string s;cin >> s;
  int flag=0;
  if(s[0]=='A') flag++;
  
  int C_cnt=0;
  for(int i=2;i<s.size()-1;i++){
    if(s[i]=='C') C_cnt++;
  }
  if(C_cnt==1) flag++;
  
  int mini=0;
  for(char c:s){
    if(c>='a' && c<='z') mini++;
  }
  if(mini==s.size()-2) flag++;
  
  if(flag==3) cout << "AC" << endl;
  else cout << "WA" << endl;
  return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.conv;
import std.datetime;
import std.numeric;
import std.math;
import std.string;

string my_readln() { return chomp(readln()); }

void main()
{//try{
	auto tokens = split(my_readln());
	auto N = to!string(tokens[0]);

	ulong ans;

	foreach (e; N)
	{
		if (e == '2') ++ans;
	}

	writeln(ans);
	stdout.flush();
/*}catch (Throwable e)
	{
		writeln(e.toString());
	}
readln();*/
}

Measured memory_bytes: 256
//File Name: agc014_A.cpp
  //Created Time: 2017年05月14日 星期日 00时20分41秒
                                   
#include <bits/stdc++.h>
#define LL long long
using namespace std;
LL a,b,c;
int solve(){
	if((a & 1) || (b & 1) || (c & 1)) return 0;
	int ma = 5000000;
	LL aa,bb,cc;
	for(int i(1);i<=ma;++i){
		aa = b / 2 + c / 2;
		bb = a / 2 + c / 2;
		cc = a / 2 + b / 2;
		a = aa,b = bb,c = cc;
		if((a & 1) || (b & 1) || (c & 1))
			return i;
	}
	return -1;
}
int main(){
	cin >> a >> b >> c;
	cout << solve() << endl;
	return 0;
}


Measured memory_bytes: 256
import math


class P:
    def __init__(self, x, y):
        self.x, self.y = x, y

    def __sub__(self, q):
        return P(self.x-q.x, self.y-q.y)

    def length(self):
        return (self.x**2+self.y**2)**.5


a, b, h, m = map(int, input().split())
minutes = 60*h+m
h_deg = minutes/2 % 360
m_deg = minutes*6 % 360
v1 = P(a*math.cos(math.radians(h_deg)), a*math.sin(math.radians(h_deg)))
v2 = P(b*math.cos(math.radians(m_deg)), b*math.sin(math.radians(m_deg)))
print((v1-v2).length())

Measured memory_bytes: 9608
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	int n;
	ll y;
	cin>>n>>y;
	for(int i=0;i<=n;i++){
		if(i*10000>y) break;
		for(int j=0;j<=n-i;j++){
			if(i*10000+j*5000>y) break;
			int k=n-i-j;
			if(10000*i+5000*j+1000*k==y){
				cout<<i<<' '<<j<<' '<<k<<endl;
				return 0;
			}
		}
	}
	cout<<-1<<' '<<-1<<' '<<-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int w,h,n;
  cin >> w >> h >> n;
  int up=h;
  int right = w;
  int left = 0;
  int down = 0;
  rep(i,n){
    int x,y,a;
    cin >> x >> y >> a;
    if(a==1){
      left = max(left,x);
    }
    if(a==2){
      right = min(right,x);
    }
    if(a==3){
      down= max(down,y);
    }
    if(a==4){
      up = min(up,y);
    }
  }
  cout << max(right-left,0)*max(up-down,0) << endl;
}


Measured memory_bytes: 256
s = list(input())
s_len=len(s)//2
s_r=s[::-1]
front=s[:s_len]
back=s_r[:s_len]

i=0
cou = 0
for a in front:
    if back[i] != a:
        back[i]=a
        cou += 1
    i+=1
print(cou)

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> a(N);
  rep(i, N) cin >> a[i];

  double avg;
  rep(i, N) avg += a[i];
  avg /= N;

  double foo = avg - a[0];
  if (foo < 0) foo *= -1;
  long bar = 0;

  rep (i, N) {
    double tmp = avg - a[i];
    if (tmp < 0) tmp *= -1;
    if (tmp < foo) {
      foo = tmp;
      bar = i;
    }
  }

  cout << bar << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100
#define INFTY 2000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, m[MAX][MAX];

int prim(void);

int main() {

  int i, j, e;

  scanf("%d", &n);
  for( i=0; i<n; i++ ) {
    for( j=0; j<n; j++ ) {
      scanf("%d", &e);
      if( e == -1 ) {
	m[i][j] = INFTY;
      }
      else {
	m[i][j] = e;
      }
    }
  }
  printf("%d\n", prim());
  
  return 0;
}

int prim() {

  int i, v, u, minv, sum;
  int d[MAX], p[MAX], color[MAX];

  for( i=0; i<n; i++ ) {
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }
  d[0] = 0;
  while(1) {
    minv = INFTY;
    u = -1;
    for( i=0; i<n; i++ ) {
      if( minv > d[i] && color[i] != BLACK ) {
	u = i;
	minv = d[i];
      }
    }
    if( u == -1 ) {
      break;
    }
    color[u] = BLACK;
    for( v=0; v<n; v++ ) {
      if( color[v] != BLACK && m[u][v] != INFTY ) {
	if( d[v] > m[u][v] ) {
	  d[v] = m[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  sum = 0;
  for( i=0; i<n; i++ ) {
    if( p[i] != -1 ) {
      sum += m[i][p[i]];
    }
  } 
  return sum;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a = 0 , b = 0 , c = 0,sum = 0;
	cin>>a>>b;
	if(a >= 0 && b >= 0)
	{
		cout<<"Positive"<<endl;
	}
	if(a <= 0 && b >= 0)
	{
		cout<<"Zero"<<endl;
	}
	if(a < 0 && b < 0)
	{
		for(int i = a ; i <= b ; i++)
		{
			sum++;
		}
		if(sum % 2 == 0)
		{
			cout<<"Positive"<<endl;
		}
		else
		{
			cout<<"Negative"<<endl;
		}
	}
	return 0;
} 

Measured memory_bytes: 256
def answer():
    N, M = map(int, input().split())
    ab = [list(map(int, input().split())) for i in range(N)]
    ab.sort()
    count = 0
    price = 0
    tmp = 0
    
    while(1):
        if count >= M:
            return price

        else:
            if ab[tmp][1] >=1:
                price += ab[tmp][0]
                ab[tmp][1] -= 1
                count += 1
            else:
                tmp += 1
                price += ab[tmp][0]
                ab[tmp][1] -= 1
                count += 1

print(answer())

Measured memory_bytes: 27756
N = int(input())
S = [list(map(int,input().split())) for _ in range(N)]
S = sorted(S,key=lambda x:x[1])
T = 0
ind = 0
for i in range(N):
    T += S[i][0]
    if T>S[i][1]:
        ind = 1
        break
if ind==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 55264
#include <bits/stdc++.h>
#include <stack>
using namespace std;
int main(){
	int N; cin >> N; 
	pair<long double, long double> P[110] = {}; 
	for(int i = 0; i < N; i++){
		cin >> P[i].first >> P[i].second; 
	}
	long double pi = acos(-1); 
	long double ans = 0; 
	for(int i = 0; i < 200000; i++){
		long double ax = cos(pi * 0.00001 * (long double) i); 
		long double ay = sin(pi * 0.00001 * (long double) i); 
		long double tmpx = 0; long double tmpy = 0; 
		for(int j = 0; j < N; j++){
			if(P[j].first * ax + P[j].second * ay >= 1e-12){
				tmpx += P[j].first; tmpy += P[j].second; 
			}
		}
		ans = max(ans, pow(tmpx * tmpx + tmpy * tmpy, 0.5));
	}
	cout.precision(20); 
	cout << ans << endl; 
}

Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<algorithm>
#define M_PI 3.14159265358979323846
#define ll long long
using namespace std;
ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}
ll lcm(int a, int b) {
	return (ll)a * b / gcd(a, b);
}
int main() {
	int a, b, h, m;
	cin >> a >> b >> h >> m;
	double p = 2.0 * M_PI / 720;
	double q = 2.0 * M_PI / 60;
	int t = h * 60 + m;
	int c=p * t / (2 * M_PI);
	int d=q * t / (2 * M_PI);
	p = p * t - c * (2 * M_PI);
	q = q * t - d * (2 * M_PI);
	if (p > q) {
		double temp = p;
		p = q;
		q = temp;
	}
	double s = min(q - p, (2 * M_PI) + p - q);
	double res = sqrt(1.0*a * a + 1.0*b * b - 2.0*a * b * cos(s));
	cout.precision(15);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
*/

int nCrmod2(int n, int r){
	return n == ( r | (n - r) );
}

ll n,a[1000010];
string s;
ll ma=0;
int sum=0;

int main(void){
	cin>>n;
	cin>>s;
	rep(i,n)a[i] = (s[i]-'0')-1;  // 0,1,2
	rep(i,n)sum += nCrmod2(n-1,i) * (a[i]%2);
	if(sum%2==1){
		cout<<1<<endl;
		return 0;
	}
	rep(i,n)if(a[i]==1){
		cout<<0<<endl;
		return 0;
	}
	rep(i,n)a[i] /= 2;
	sum=0;
	rep(i,n)sum += nCrmod2(n-1,i) * (a[i]%2);
	if(sum%2==1){
		cout<<2<<endl;
	}else{
		cout<<0<<endl;
	}
	return 0;
}

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

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> A(N,0);
  rep(i,K){
    int d;cin>>d;
    rep(j,d){
      int a;cin>>a;a--;
      A[a]++;
    }
  }
  int ans=0;
  rep(i,N){
    if(A[i]==0) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
#define tl 1'000'000'007
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin >> n >> m;
    //2n!m!
    ll ans;
    if(abs(n-m)>1) ans= 0;
    else if(abs(n-m)==1) ans= 1;
    else ans= 2;
    FOR(i,1,n+1){
        ans*= i;
        ans%= tl;
    }
    FOR(i,1,m+1){
        ans*= i;
        ans%= tl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "No" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,A,B,C; cin>>N>>A>>B>>C;
    vector<ll> L(N);
    rep(i,N) cin>>L[i];
    ll ans=INF2;
    rep(i,1<<2*N){
        ll ans2=0;
        ll a=0,b=0,c=0;
        ll an=0,bn=0,cn=0;
        rep(j,N){
            if(i>>(j*2)&1 and i>>(j*2)&2){ ++an; a+=L[j];}
            if(!(i>>(j*2)&1) and i>>(j*2)&2){ ++bn; b+=L[j];}
            if((i>>(j*2)&1) and !(i>>(j*2)&2)){ ++cn; c+=L[j];}
            if(!(i>>(j*2)&1) and !(i>>(j*2)&2)){}
        }
        if(an==0 or bn==0 or cn==0) continue;
        ans2+=(an-1+bn-1+cn-1)*10;
        ans2+=abs(a-A)+abs(b-B)+abs(c-C);
        mini(ans,ans2);
    }
    cout<< ans <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
#include<stdio.h>

#define white 0
#define gray 1
#define black 2

int n,u,hai[100][100];

void dijkstra(void);

int main(){
  int i,j,k,v,c;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      hai[i][j] = 1000000;

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d %d",&v,&c);
      hai[u][v] = c;
    }
  }

  dijkstra();

  return 0;
}

void dijkstra(){
  int i,min,d[100],iro[100] = {0};

  for(i=0;i<n;i++)
    d[i] = 1000000;

  d[0] = 0;
  iro[0] = 1;

  while(1){
    min = 1000000;
    u = -1;
    for(i=0;i<n;i++)
      if(min > d[i] && iro[i] != 2){
	u = i;
	min = d[i];
      }
    if(u == -1)break;
    iro[u] = 2;
    for(i=0;i<n;i++)
      if(iro[i] != 2 && hai[u][i] != 1000000){
	if(d[i] > d[u] + hai[u][i]){
	  d[i] = d[u] + hai[u][i];
	  iro[i] = 1;
	}
      }
  }
  for(i=0;i<n;i++){
    if(d[i] == 1000000)printf("%d -1\n",i);
    else printf("%d %d\n",i,d[i]);
  }

}



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

int main()
{
	int n,k;
	cin >> n >> k;
	int d;
	vector<bool> a(n);
	for(int i = 0;i<k;i++)
	{
		cin >> d;
		for(int j = 0;j<d;j++)
		{
			int x;
			cin >> x;
			x--;
			a[x]=true;
		}
	}
	int ans = 0;
	for(auto i:a)ans+=1^i;
	cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main() {
	double x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << setprecision(10) << sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define DUMP(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<": "<<(x)<<" (L"<<__LINE__<<")"<<endl
using namespace std;
using vint = vector<int>;
using vdouble = vector<double>;
using vstring = vector<string>;
using ll = long long;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    vint cnt(10, 0);
    rep(i, n) {
        if(a[i] >= 3200) { cnt[8]++; continue; }
        rep(j, 8) {
            if(a[i] < 400 * (j + 1)) {
                cnt[j]++;
                break;
            }
        }
    }
    int cnt2 = 0;
    rep(i, 8) {
        if(cnt[i] > 0) cnt2++;
    }
    cout << max(1, cnt2) << " " << (cnt2 + cnt[8]) << endl;
    return 0;
}


Measured memory_bytes: 256
class Array
  def cumsum!(s = 0); map!{|t| s += t } end
end

n, k = gets.to_s.split.map{|t| t.to_i }
a    = gets.to_s.split.map{|t| t.to_i }

if k >= 41
  puts [n] * n * ' '
  exit
end

zeros = [0] * n
ans = []
[k, 40].min.times do |i|
  
  ans = zeros.dup
  a.each_with_index do |t, i|
    
    j = [i - t, 0].max
    ans[j] += 1
    
    j = i + t + 1
    ans[j] += -1 if j < n
  end
  
  ans.cumsum!
  
  a = ans.dup
end

puts ans * ' '

Measured memory_bytes: 80624
N = int(input())
INF = float('inf')
dp = [INF] * 100010
dp[0] = 0

for i in range(1, N+1):
    dp[i] = dp[i-1] + 1
    k = 6
    while i - k >= 0:
        dp[i] = min(dp[i], dp[i-k] + 1)
        k *= 6
    k = 1
    while i - k >= 0:
        dp[i] = min(dp[i], dp[i-k] + 1)
        k *= 9
print(dp[N])

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL INF = 0x3f3f3f3f3f3f3f3fLL;
void spfa(vector<vector<int> > &G, int s, vector<LL> &d) {
    d[s] = 0; queue<int> q; q.push(s); while (q.size()) {
        int p = q.front(); q.pop();
        for (auto &v : G[p]) {
            if (d[p] + 1 < d[v])
                d[v] = d[p] + 1, q.push(v);
        }
    }
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    vector<vector<int> > G(3 * n);
    while (m--) {
        int u, v; cin >> u >> v; u--, v--;
        G[u].push_back(n + v);
        G[n + u].push_back(2 * n + v);
        G[2 * n + u].push_back(v);
    }
    int s, t; cin >> s >> t; s--, t--;
    vector<LL> d(3 * n, INF);
    spfa(G, s, d);
    if (d[t] == INF)
        cout << -1 << '\n';
    else
        cout << d[t] / 3 << '\n';
}


Measured memory_bytes: 19072
#include<bits/stdc++.h>
using namespace  std;
typedef long long LL;
int main()
{
    LL n;
    cin>>n;
    for(int i=sqrt(n);i>=1;i--)
    {
        if(n%i==0)
        {
            cout<<(i-1+n/i-1)<<endl;
            break;
        }
    }
}

Measured memory_bytes: 256
import math
import itertools
n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]
def distance(x1, y1, x2, y2):
    return math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))

dist = 0
cnt = 0
for p in itertools.permutations(range(n)):
    for i in range(n-1):
        dist += distance(xy[p[i]][0], xy[p[i]][1], xy[p[i+1]][0], xy[p[i+1]][1])
    cnt += 1
ans = dist / cnt
print(ans)


Measured memory_bytes: 3064
import sys
def input():
    return sys.stdin.readline()[:-1]
n,k,q=map(int,input().split())
a=[int(input()) for i in range(q)]
li=[q]*n
for i in range(q):
    li[a[i]-1]-=1

for i in range(n):
    if k-li[i]<=0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 49500
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define f(i,a,b) for(ll i=(a);i<(b);i++)
#define frr(i,a,b) for(ll i=(a-1);i>=(b);i--)
#define vi vector<int>
#define de deque<int>
#define del deque<ll>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define mpp map<ll,ll>
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define ln(a) a.length()
#define sz(a) a.size()
#define endl "\n"
int M=1000000007;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    int n;cin>>n;
    double p[n];
    f(i,1,n+1)cin>>p[i];
    double dp[n+1][n+1];
    memset(dp,0,sizeof dp);
    dp[0][0]=1;
    f(i,1,n+1)dp[i][0]=dp[i-1][0]*(1-p[i]);
    f(i,1,n+1)
    {
        f(j,1,i+1)
        {
            dp[i][j]=dp[i-1][j]*(1-p[i])+dp[i-1][j-1]*p[i];
        }
    }
    double sum=0;
f(i,(n+1)/2,n+1)
{
    sum+=dp[n][i];
}
cout<<fixed<<setprecision(10)<<sum<<endl;
}



Measured memory_bytes: 70656
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
#include "dbgtoki.hpp"
#define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i) 
#else
#define DUMP(i)
#endif

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
#define dis distance
#define so sort
#define rev reverse
#define pub push_back
#define sec second
#define fir first

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector <int> > vvi;
const int EPS = 1e-9;
const int MOD = 1e9+7;
const int INF = (1 << 30);

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi A(n);
	REP(i,n){
		int a;
		cin >> a;
		int na = a-i-1;
		A[i] = na;
	}
	so(ALL(A));
	vi Mid;
	if(n % 2 == 0){
		Mid.pub(A[n/2]);
		Mid.pub(A[n/2-1]);
		Mid.pub((A[n/2]+A[n/2-1])/2);
		Mid.pub((A[n/2]+A[n/2-1])/2+1);
		Mid.pub((A[n/2]+A[n/2-1])/2-1);
	}else{
		Mid.pub(A[n/2]);
	}
	ll ans = 10e17;
	for(auto mid : Mid){
		ll mans = 0;
		REP(i,n){
			mans += abs(A[i]-mid);
		}
		if(ans > mans){
			ans = mans;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

typedef struct{
  int from,to;
  ll cost;
}edge;
const int V_MAX = 2510,E_MAX = 5010;
int V,E;
ll P;
vector<edge>es(E_MAX);
vector<vector<int> >G1(V_MAX);
vector<vector<int> >G2(V_MAX);
vector<bool> canmove1(V_MAX,false);
vector<bool> canmove2(V_MAX,false);
vector<ll> d(V_MAX,MAX_I);

//ゴールまで行ける場所
int dfs(int g,vector<vector<int> > &G, vector<bool> &canmove){
  if(canmove[g]) return 0;
  canmove[g] = true;
  for(const int & e : G[g]){
    dfs(e,G,canmove);
  }
  return 0;
}

int bellmanford(int s){
  rep(i,V)d[i] = MAX_I;
  d[s] = 0;
  while(true){
    bool update = false;
    for(const edge &e : es){
      if(!canmove1[e.to] || !canmove2[e.to])continue;
      if(d[e.from] != MAX_I && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from]+e.cost;
        update = true;
      }
    }
    if(!update)break;
  }
  return 1;
}

bool find_negative_loop(){
  rep(i,V)d[i] = 0;
  rep(i,V){
    for(const edge &e : es){
      if(!canmove1[e.to] || !canmove2[e.to])continue;
      if(d[e.from] != MAX_I && d[e.to] > d[e.from] + e.cost){
        d[e.to] = d[e.from]+e.cost;
        if(i==V-1)return true;
      }
    }
  }
  return false;
}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> V >> E >> P;
  rep(i,E){
    int A,B;
    ll C;cin >> A >> B >> C;
    --A;--B;
    es.push_back({A,B,P-C});
    G1[B].push_back(A);
    G2[A].push_back(B);
  }
  dfs(V-1,G1,canmove1);
  dfs(0,G2,canmove2);
  if(find_negative_loop()){
    cout << -1 << endl;
    return 0;
  }
  bellmanford(0);
  cout << max(0ll,-d[V-1]) << endl;
  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
const int N=1000002;
#define all(a) a.begin(),a.end()
bitset<4000000>dp;
 
void solve(int n){
	vector<int> a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	dp[0]=true;
	for(int i=0;i<n;i++){
		dp=dp|dp<<a[i];
	}
	long long  tot=accumulate(all(a),0ll);
	if(tot%2){
		tot++;
	}
	tot/=2;
	for(int i=tot;i<=4000000;i++){
		if(dp[i]){
			cout<<i<<' ';
			return;
		}
	}
}
int main(){
int n;
cin>>n;
solve(n);
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int N;

int main() {
  ll x; cin >>x;
  ll a = 100;
  int res = 0;
  while (a < x){
    a = a * 1.01;
    res++;
  }
  cout <<res <<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
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;}
ll n,a,b;
vector<ll> h;

bool check(ll x){
  ll y = 0;
  rep(i,n){
    ll tmp = h[i];
    tmp -= x*b;
    if(tmp <= 0) continue;
    y += (tmp+a-1)/a;
  }
  if(y > x) return false;
  else return true;
}

int main(){
  cin >> n >> a >> b;
  
  a -= b;
  
  rep(i,n){
    ll tmp; cin >> tmp;
    h.push_back(tmp);
  }
  
  ll l = 0, r = 1000000000 + 5;
  while(r-l>1){
    ll c = (l+r)/2;
    if(check(c)) r = c;
    else l = c;
  }
  
  cout << r << endl;
    
  return 0;
}

Measured memory_bytes: 1400