akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define MAX 1000000
#define INF (1<<30)
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

class Edge{
  public:
  int t,w;
  Edge(){}
  Edge(int t,int w): t(t),w(w){}
};

vector<vector<Edge> > lis(MAX);
int n,d[MAX];

vector<bool> vis(MAX);
int cnt;

void bfs(int s){
  for(int i=0;i<n;i++) d[i]=INF;
  queue<int> que;
  que.push(s);
  d[s]=0;
  int u;
  while(!que.empty()){
    u=que.front(); que.pop();
    for(int i=0;i<lis[u].size();i++){
      Edge e=lis[u][i];
      if(d[e.t]==INF){
        d[e.t]=d[u]+e.w;
        que.push(e.t);
      }
    }
  }
  return;
}

int main(){
  int s,t,w;
  cin>>n;
  
  //隣接リストの作成
  for(int i=0;i<n-1;i++){
    cin>>s>>t>>w;
    lis[s].emplace_back(t,w);
    lis[t].emplace_back(s,w);
  }
  
  //ここから本番
  //適当な始点sから最も遠い節点tgtを求める。
  bfs(0);
  int maxv=0;
  int tgt=0;
  //節点sから最も遠い節点xを求める。
  for(int i=0;i<n;i++){
    if(d[i]==INF) continue;
    if(chmax(maxv,d[i])){
      tgt=i;
    }
  }

  //tgtから最も遠い節点maxvを求める。
  bfs(tgt);
  maxv=0;
  for(int i=0;i<n;i++){
    if(d[i]==INF) continue;
    chmax(maxv,d[i]);
  }

  cout<<maxv<<'\n';
}




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

int main() {
    int k, n;
    cin >> k >>  n;
    vector<int> a(n);

    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    a.push_back(a[0] + k);
    int tmp = 0;
    for (int i = 0; i < n; i++){
        tmp = max(tmp, a[i + 1] - a[i]);
    }
    cout << k - tmp << endl;

    return 0;
}


Measured memory_bytes: 1792
using namespace std;
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 200010
#define ll long long
int n,m;
int a[N];
struct Node{
	Node *pre,*suc;
	int v,L,R;
	ll s;
	bool f;
} *fir,*lst;
Node *ins(int v,int L,int R,int s,Node *pre,Node *suc){
	Node *nw=new Node;
	*nw=(Node){pre,suc,v,L,R,s,0};
	if (pre) pre->suc=nw;
	if (suc) suc->pre=nw;
	return nw;
}
Node *h[N];
int nh;
bool cmph(Node *son,Node *fa){return son->v>fa->v;}
int L[N],R[N],L_[N],R_[N];
ll calc(int L[],int R[],int k){
	ll sL=0,s=0;
	for (int i=1;i<=k;++i){
		if (i-m+1>0)
			sL+=L[i-m+1];
		s+=(sL+L[i])*R[i];
	}
	return s;
}
ll ans;
int main(){
//	freopen("in.txt","r",stdin);
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i)
		scanf("%d",&a[i]);
	ans=n;
	fir=lst=ins(a[1],1,1,1,NULL,NULL);
	h[nh++]=fir,fir->f=1;
	for (int i=2;i<=n;++i){
		lst=ins(a[i],1,1,1,lst,NULL);
		if (lst->v!=lst->pre->v)
			h[nh++]=lst,lst->f=1;
	}
	make_heap(h,h+nh,cmph);
	while (nh){
		Node *fir=h[0];
		pop_heap(h,h+nh--,cmph);
		if (fir->f==0 || fir->pre && fir->pre->v==fir->v)
			continue;
		int v=fir->v,k=0;
		Node *p=fir,*lst=p;
		for (int i=1;p && p->v==v;++i,p=p->suc)
			L[i]=p->L,R[i]=p->R,++k,lst=p;
		Node *pre=fir->pre,*suc=lst->suc;
		if (pre) pre->suc=NULL;
		if (suc) suc->pre=NULL;
		fir->f=0;
		fir->pre=lst->suc=NULL;
		if (k==1 || k>=m){
			for (Node *p=fir;p && p->v==v;p=p->suc)
				ans-=p->s;
			ans+=calc(L,R,k);
			if (k==1)
				continue;
			int d=k/m;
			memset(L_,0,sizeof(int)*(d+1));
			memset(R_,0,sizeof(int)*(d+1));
			for (int i=m;i<=k;++i)
				R_[i/m]+=R[i];
			for (int i=k-m+1;i>=1;--i)
				L_[d-(k-i+1)/m+1]+=L[i];
			for (int i=d;i>=1;--i)
				suc=ins(v+1,L_[i],R_[i],0,pre,suc);
			suc->f=1;
			suc->s=calc(L_,R_,d);
			h[nh++]=suc;
			push_heap(h,h+nh,cmph);
			continue;
		}
	}
	printf("%lld\n",ans);
	return 0;
}













Measured memory_bytes: 27932
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct E {
    int u, v, w;
};

int main() {
    int l;
    cin >> l;

    int n = 20, m = 0;
    E e[60];
    int o = 10000000;
    int t = l, s = 1, b = 1, c = -o;

    while (1) {
        int r = t % 3;
        for (int i = 0; i < r; i++) {
            e[m++] = { s, n, c };
            c += b;
        }
        t /= 3;

        if (t == 0) {
            s++;
            break;
        }

        for (int i = 0; i < 3; i++) {
            e[m++] = { s, s + 1, b * i };
        }
        s++;
        b *= 3;

        if (t == 1) {
            o += b;
            break;
        }
    }
    n = s;

    cout << n << ' ' << m << endl;
    for (int i = 0; i < m; i++) {
        if (e[i].v > n) e[i].v = n;
        if (e[i].w < 0) e[i].w += o;
        cout << e[i].u << ' ' << e[i].v << ' ' << e[i].w << endl;
    }

    return 0;
}

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

int main()
{
    string O, E;
    cin >> O >> E;
    vector<char> ans(O.size() + E.size());
    for (int i = 0; i < O.size(); i++)
        ans[2 * i] = O[i];
    for (int i = 0; i < E.size(); i++)
        ans[2 * i + 1] = E[i];
    for (int i = 0; i < ans.size(); i++)
        cout << ans[i];
    cout << endl;
    return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n;
string s,t;

signed main() {
    cin >> n >> s >> t;
    rep(i,n) {
        cout << s[i] << t[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
using namespace std;
int main()
{
    int n; cin >> n;
    while (n--) {
        double xa, ya, ra, xb, yb, rb;
        cin >> xa >> ya >> ra >> xb >> yb >> rb;
        double d = hypot(xa-xb, ya-yb);
        int res = 1;
        if (ra > rb) {
            if (d < ra - rb) res = 2;
            else if (d > ra + rb) res = 0;
        }
        else {
            if (d < rb - ra) res = -2;
            else if (d > ra + rb) res = 0;
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int N;
    cin >> N;
    vector<int> A(N);
    rep (i, N) {
        cin >> A[i];
    }
    LL cash = 1000;
    LL share = 0;
    rep(i, N) {
        if (share == 0) {
          if (i < N-1 && A[i] < A[i+1]) {
            share = cash / A[i];
            cash -= share * A[i];
          }
        } else {
          if (i == N-1 || A[i+1] < A[i]) {
              cash += share * A[i];
              share = 0;
          }
        }
    }

    cout << cash << endl;

    return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
int main(){
    int a,b,c,d,x,y;
	while(1){
		scanf("%d %d",&x,&y);
		if(x==0&&y==0)break;
		for(c=1;c<=y;c++){
		    printf("#");
		}
		printf("\n");
		for(b=3;b<=x;b++){
			printf("#");
		    for(a=3;a<=y;a++){
		    	printf(".");
		    }
			printf("#\n");
		}
		for(d=1;d<=y;d++){
		    printf("#");
		}
		printf("\n\n");
	}
			
	return 0;
}

Measured memory_bytes: 2508
def main():
    N = int(input())
    S = input()
    n_E = [0 for _ in range(N+1)]
    n_W = [0 for _ in range(N+1)]
    for i in range(N):
        if S[i] == "E":
            n_E[i+1] = n_E[i] + 1
            n_W[i+1] = n_W[i]
        elif S[i] == "W":
            n_E[i+1] = n_E[i]
            n_W[i+1] = n_W[i] + 1

    count = N
    for i in range(N):
        count = min(count,n_W[i] + (n_E[-1]-n_E[i+1]))

    return count

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 17976
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
//**デバッグ準備**//
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, Npow, divisor, modinv, bitSearch, bitList, dfs, bfs//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 1LL << 60; ll ans = 0; ll z = 0, o = 1;
vl flag, color, D; vll path;
//***********//
int main() {
	cin >> N;
	vl A(N-1);
	vl B(N);
	for (i = 0; i < N-1; i++) { cin >> A[i]; B[A[i] - 1]++; }
	for (i = 0; i < N; i++) {
		cout << B[i] << endl;
	}
}

Measured memory_bytes: 6428
/*
 * Author : Sadi
 * Sun 05/07/2020
 * 16:12:09.14
 */
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int a, b, k;
    cin >> a >> b >> k;
    int upto = min(a, b);
    vector<int> div;
    for(int i = 1; i <= upto; ++i) {
        if(a % i == 0 && b % i == 0) {
            div.push_back(i);
        }
    }
//    cout << div << endl;
    cout << div[div.size() - k] << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <ctype.h>

int main()
{
    int i = 0;
    char str[1201];
    
    gets(str);
    
    while(str[i]){
        if(isupper(str[i])) str[i] = tolower(str[i]);
        else if(islower(str[i])) str[i] = toupper(str[i]);
        i++;
    }
    printf("%s\n", str);
    
    return 0;
}

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

int main() {

  long long A, V, B, W, T;
  
  cin >> A >> V >> B >> W >> T;
  
  if (V > W) {
  	if ((V - W) * T >= abs(A -B)) {
    cout << "YES" << endl;
    } else {
    	cout << "NO" << endl;
    }
  } else {
  	cout << "NO" << endl;
  }
  
    return 0;

}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
const int MAX=1e5+10,MOD=1e9+7;
int F[MAX],ans;
int f(int a,int b,int c)
{
    return a>min(b,c) && a<max(b,c);
}
int main ()
{
    int n;cin>>n;
    for(int i=1;i<=n;i++)cin>>F[i];
    sort(F+1,F+1+n);
    
    int mid = n/2;
    cout<<F[mid+1]-F[mid];
    return 0;
}
/*

*/

Measured memory_bytes: 640
#include<bits/stdc++.h> 
using namespace std;
string word; 
void solve(); 
int main() 
{ 
   ios_base::sync_with_stdio(false);cin.tie(NULL); 
   
   /*#ifndef ONLINE_JUDGE 
   freopen("input.txt", "r", stdin); 
   freopen("error.txt", "w", stderr); 
   freopen("output.txt", "w", stdout); 
   #endif*/ 
   
   int t=1; 

   //cin>>t; 
   while(t--) 
   { 

      solve(); 
      cout<<"\n"; 
   } 
   
   cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl; 
   return 0; 
} 
void solve() 
{ 
      cin >> word;
      if (word.back() == 's'){
         word += "es";
      }
      else {
         word += "s";
      }
      cout << word;
} 

Measured memory_bytes: 3792
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long ans=1e9,num;
  string s,t;
  cin >> s;
  for(int i=0;i<s.size()-2;i++){
    t = s.substr(i,3);
    num=atoi(t.c_str());
    ans=min(ans,abs(753-num));
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

const int MAXN = 3e3 + 10;

int n, T, k, m;

double a[MAXN], dp[MAXN][MAXN];

string s, t;

const int MOD = 1e9 + 7;

int main() {
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];

	double cur = 1;
	for (int i = 0; i <= n; i++) {
		cur *= (1 - a[i]);
		dp[0][i] = cur;
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (i == 1 && j == 1)
				dp[1][1] = a[1];
			else
				dp[i][j] = dp[i - 1][j - 1] * a[j] + dp[i][j - 1] * (1 - a[j]); 

		}
	}

	double ans = 0;
	for (int i = n; i >= (n + 1) / 2; i--)
		ans += dp[i][n];

	cout << setprecision(10) << fixed << ans;
}


Measured memory_bytes: 74332
#include<bits/stdc++.h>
#define Rep(i,a,b) for(register int i=(a);i<=(b);++i)
#define Repe(i,a,b) for(register int i=(a);i>=(b);--i)
#define pb push_back
#define mp make_pair
typedef unsigned long long uint64;
typedef unsigned int uint32;
typedef long long ll;
using namespace std;

namespace IO
{
    const uint32 Buffsize=1<<15,Output=1<<24;
    static char Ch[Buffsize],*S=Ch,*T=Ch;
    inline char getc()
	{
		return((S==T)&&(T=(S=Ch)+fread(Ch,1,Buffsize,stdin),S==T)?0:*S++);
	}
    static char Out[Output],*nowps=Out;
    
    inline void flush(){fwrite(Out,1,nowps-Out,stdout);nowps=Out;}

    template<typename T>inline void read(T&x)
	{
		x=0;static char ch;T f=1;
		for(ch=getc();!isdigit(ch);ch=getc())if(ch=='-')f=-1;
		for(;isdigit(ch);ch=getc())x=x*10+(ch^48);
		x*=f;
	}

	template<typename T>inline void write(T x,char ch='\n')
	{
		if(!x)*nowps++='0';
		if(x<0)*nowps++='-',x=-x;
		static uint32 sta[111],tp;
		for(tp=0;x;x/=10)sta[++tp]=x%10;
		for(;tp;*nowps++=sta[tp--]^48);
		*nowps++=ch;
	}
}
using namespace IO;

inline void file()
{
#ifndef ONLINE_JUDGE
	FILE*WA=freopen("water.in","r",stdin);
	FILE*TER=freopen("water.out","w",stdout);
#endif
}

const int MAXN=2e5+7;

static int n,H,W;

static struct node
{
	int x,y;
	friend bool operator<(node a,node b){return a.x^b.x?a.x<b.x:a.y<b.y;}
}p[MAXN];

static unordered_set<int>G[MAXN];

inline void init()
{
	read(H),read(W),read(n);
	Rep(i,1,n)read(p[i].x),read(p[i].y),G[p[i].x].insert(p[i].y);
	sort(p+1,p+n+1);
}

static int ans;

inline void Chkmax(int&u,int v){u<v?u=v:0;}

static int nps,npx;

inline void solve()
{
	nps=npx=1;
	Rep(i,1,n)
	{
		while(npx<p[i].x-1)
		{
			++npx;
			if(G[npx].find(nps+1)==G[npx].end())++nps;
		}
		if(p[i].y<=nps)cout<<p[i].x-1<<endl,exit(0);
	}
	cout<<H<<endl;
}

int main()
{
    init();
    solve();
    return 0;
}

Measured memory_bytes: 25216
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#define ll long long
using namespace std;
int main()
{
    string s;
    while(cin>>s){
      int n=s.size();
      int num=0;
      for(int i=n-1;i>=0;i--){
        if(s[i]=='B')num++;
        else if(num){
          s[i]='B';
          num--;
        }
      }
      string ans="";
      for(int i=0;i<n;i++)if(s[i]!='B')ans+=s[i];
      cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define test(s) \
  if (!(s))     \
    cout << "Line " << __LINE__ << ": [" << #s << "] is false" << endl;
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

signed main() {
  int X;
  cin >> X;

  repp(i, 1, 360) {
    if (360 * i % X == 0) {
      cout << (360 * i / X) << endl;
      return 0;
    }
  }
}

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

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

Measured memory_bytes: 640
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;


ll divesor_number(ll n) {
  ll res = 0;
    for(ll i=1; i*i<=n; i++) {
        if(n % i == 0) res += 2;
        if(i * i == n) res--;
    }
    return res;
}

int main() {
    int n, res = 0; cin >> n;
    Rep(i, 1, n+1) {
        if(i % 2 == 0) continue;
        if(divesor_number(i) == 8) res++;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb push_back
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    map<string,bool>mymap;
    int n,i;
    string s;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>s;
        mymap[s]=1;
    }
    cout<<mymap.size()<<endl;
}


Measured memory_bytes: 19248
#include<iostream>
using namespace std;
int main(){
	int num[100],n,max=0;
	for(int i=0; i<100; i++){
		num[i] = 0;
	}
	while(cin>>n){
		num[n-1]++;
	}
	for(int i=0; i<100; i++){
		if(max<num[i]){max=num[i];}
	}
	for(int i=0; i<100; i++){
		if(num[i] == max){cout<<i+1<<endl;}
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
using namespace std;
typedef long long ll;
const double eps = 1e-8;

int main() {
	ll a,b,c;
	cin >> a >> b >> c;
	if(c - a - b <= 0) cout <<"No\n";
	else{
		if((c-a-b)*(c-a-b)-4*a*b>0) cout <<"Yes\n";
		else cout<<"No\n";
	}
	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);
		String w = sc.next();
		int count = 0;
		for (int i = 0 ; i < w.length() ; i++) {
			for (int j = 0 ; j < w.length() ; j++) {
				if (w.charAt(i) == w.charAt(j)) {
					count++;
				}
			}
			if (count % 2 != 0) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}

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

using namespace std;

long long n, a, b;

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

    cin >> n >> a >> b;
    if (a % 2 == b % 2)
        return cout << (b - a) / 2, 0;
    return cout << min({b - 1, n - a, a + (b - a - 1) / 2, n - b + 1 + (n - (a + (n - b + 1))) / 2}), 0;
}


Measured memory_bytes: 256
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: i32 = read();

    println!(
        "{}",
        if n % 10 == 0 {
            10
        } else {
            n.to_string()
                .chars()
                .map(|c| c.to_string().parse::<i32>().unwrap())
                .sum::<i32>()
        }
    );
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

#define pb push_back
#define pf push_front
#define pp pop_back
#define sz(a) (int)(a.size())
#define mp make_pair
#define F first
#define S second
#define next _next
#define prev _prev
#define left _left
#define right _right
#define y1 _y1
#define all(x) x.begin(), x.end()
#define what_is(x) #x << " is " << (x)

using namespace std;

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

const int N = (int)1e6 + 123;
const ll INF = (ll)1e18 + 123;
const int inf = (int)1e9 + 123;
const int MOD = (int)1e9 + 7;

void megaRandom() {
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  srand(FOR);
}

int n, l[500];

int main() {
	megaRandom();
	cin >> n;
	for(int i = 1; i <= 2 * n; i ++)
		cin >> l[i];
	n=  2 * n;
	sort(l + 1, l + n + 1);
	int res = 0;
	for(int i = 1; i <= n; i += 2) 
		res += l[i];
	
	 cout << res;
	return 0;  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
int main()
{
    int d ,n ,ans;
    scanf("%d%d",&d,&n);
    if(! d)
    {
        if(n == 100)
            ans = 101;
        else ans = n;
    }
    else if(d == 1)
    {
        if(n == 100)
            ans = 10100;
        else ans = n*100;
    }
    else
    {
        if(n == 100)
            ans = 1010000;
        else ans = n*10000;
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int r,g,b;
    cin>>r>>g>>b;
    int k;
    cin>>k;
    bool rr=false;
    bool r1=false;

    while(g<=r and k!=0)
    {
        g=g*2;
        k--;
    }

    if(g>r)
        rr=true;

    while(b<=g and k!=0)
    {
        b=b*2;
        k--;
    }

    if(b>g)
        r1=true;

    if(rr and r1)
    {
        cout<<"Yes\n";
    }

    else
    {
        cout<<"No\n";
    }

    return 0;



}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,l,r) for (int i=l,i##end=r;i<=i##end;++i)
#define ll long long
using namespace std;
const int P=1e9+7,N=102,X=502;
int f[N][N][X],a[X];
void upd(int &x,int y){ x+=y; x-=x>=P?P:0; }
int main(){
    int n,x; cin>>n>>x;
    rep(i,1,n) cin>>a[i];
    sort(a+1,a+1+n),reverse(a+1,a+1+n);
    f[0][0][0]=1;
    rep(i,0,n-1)
        rep(c,0,i)
            rep(s,c*a[i],x){
                if (s+a[i+1]<=x) upd(f[i+1][c+1][s+a[i+1]],f[i][c][s]);
                upd(f[i+1][c][s],(ll)f[i][c][s]*(s-c*(a[i+1]-1))%P);
                rep(l,1,min(a[i+1],x-s))
                    upd(f[i+1][c][s+l],(ll)f[i][c][s]*(c*2)%P);
                if (!c) continue;
                rep(l,1,min(a[i+1],x-s))
                    upd(f[i+1][c-1][s+l],(ll)f[i][c][s]*(c*(c-1))%P*(a[i+1]-l+1)%P);
            }
    cout<<f[n][1][x]<<endl;
    return 0;
}
/*
4
1
*/


Measured memory_bytes: 18560
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#define input freopen("input.txt","r",stdin)
#define output freopen("output.txt","w",stdout)
#define N 10005
#define LL long long
#define inf 1<<29
#define eps 1e-7
using namespace std;
vector<int>v[100005];
int get_sg(int u,int pre){
    int ret=0;
    for(int i=0;i<v[u].size();i++){
        if(v[u][i]!=pre)
            ret^=(1+get_sg(v[u][i],u));
    }
    return ret;
}
int main(){
    int t,n;
    //input;output;
    while(~scanf("%d",&n))
    {
        for(int i=1;i<=n;i++)
            v[i].clear();
        for(int i=1;i<n;i++){
            int x,y;
            scanf("%d%d",&x,&y);
            v[x].push_back(y);
            v[y].push_back(x);
        }
        if(get_sg(1,-1))
            puts("Alice");
        else
            puts("Bob");
    }
    return 0;
}


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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(void){
    VI n{0,2,5,5,4,5,6,3,7,6};
    int N,M; cin >> N >> M;
    VI A(M); REP(i,M) cin >> A[i];
    SORT(A); REVERSE(A);
    VI dp(N+1,-1); dp[0] = 0;
    REP(i,N){
        REP(j,M) if(i+1-n[A[j]] >= 0 && dp[i+1-n[A[j]]]!=-1) chmax(dp[i+1], dp[i+1-n[A[j]]] + 1);
    }

    string ans = "";
    int now = N;
    RREP(i,dp[N]){
        REP(j,M){
            if(now-n[A[j]]>=0 && dp[now] == dp[now-n[A[j]]]+1){
                ans += '0' + A[j];
                now -= n[A[j]];
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define PI 3.14159265358979323846
#define fi first
#define se second
 
ll mod = 1e9+7;
 
ll max(ll a, ll b ) {
	if(a>b)
		return a;
	else return b;
}
ll min(ll a, ll b ) {
	if(a<b)
		return a;
	else return b;
}
 
ll gcd(ll a, ll b, ll& x, ll& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll x1, y1;
    ll d = gcd(b, a % b, x1, y1);
    x = y1;
    y = x1 - y1 * (a / b);
    return d;
}
ll inv(ll a) {
	ll x, y;
	ll g = gcd(a, mod, x, y);
	x = (x % mod + mod) % mod;
	return x;
}
ll binpow(ll a, ll b, ll m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a%m;
        a = a * a%m;
        b >>= 1;
    }
    return res;
}

int main() {
	ll ttt;
	//cin>>ttt;
	ttt = 1;
	while(ttt--) {
		ll n; cin>>n;
		ll a[n]; for(int i=0; i<n; i++) cin>>a[i];
		ll ans = 0;
		for(int i=1; i<n; i++) {
			if(a[i]<a[i-1]) {
				ans += a[i-1] - a[i];
				a[i] = a[i-1];
			}
		}
		cout<<ans;
 	}	
	return 0;
}


Measured memory_bytes: 5144
#include <iostream>
#include <vector>
#include <stdlib.h>
#include<algorithm>
#define INF 1000000
using namespace std;

int main()
{
	int dp[10][10];
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			dp[i][j] = INF;
		}
	}
	int h, w, ans = 0,buf;
	cin >> h >> w;
	vector<vector<int>> wall(h, vector<int>(w));
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			cin >> dp[i][j];
		}
	}

	for (int k = 0; k < 10; k++) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				if (dp[i][j] > dp[i][k] + dp[k][j]) {
					dp[i][j] = dp[i][k] + dp[k][j];
				}
			}
		}
	}

	for (int i = 0; i < h*w; i++) {
		cin >> buf;
		if (buf != -1) {
			ans += dp[buf][1];
		}
	}
	
	cout << ans;
	return 0;
}

Measured memory_bytes: 384
# abc146_b.py
# https://atcoder.jp/contests/abc146/tasks/abc146_b

# B - ROT N /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 200点

# 問題文
# 英大文字のみからなる文字列 Sがあります。また、整数 Nが与えられます。
# Sの各文字を、アルファベット順で N個後の文字に置き換えた文字列を出力してください。
# ただしアルファベット順で Z の 1個後の文字は A とみなします。

# 制約
#     0≤N≤26
#     1≤|S|≤104
#     Sは英大文字のみからなる

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N
# S

# 出力
# Sの各文字を、アルファベット順で N個後の文字に置き換えた文字列を出力せよ。

# 入力例 1
# 2
# ABCXYZ

# 出力例 1
# CDEZAB

# アルファベット順で Z の 1個後の文字は A であることに注意してください。

# 入力例 2
# 0
# ABCXYZ

# 出力例 2
# ABCXYZ

# 入力例 3
# 13
# ABCDEFGHIJKLMNOPQRSTUVWXYZ

# 出力例 3
# NOPQRSTUVWXYZABCDEFGHIJKLM


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    S = lines[1]
    N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    result = ''
    for char in S:
        result += shift_alp(char, N)

    return [result]


def shift_alp(s, n):
    alp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

    for i in range(26):
        if alp[i] == s:
            return alp[(i+n) % 26]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['2', 'ABCXYZ']
        lines_export = ['CDEZAB']
    if pattern == 2:
        lines_input = ['0', 'ABCXYZ']
        lines_export = ['ABCXYZ']
    if pattern == 3:
        lines_input = ['13', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ']
        lines_export = ['NOPQRSTUVWXYZABCDEFGHIJKLM']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(2)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define all(a) (a.begin(), a.end())

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////
	
void solve() {
	vector<string> words;
	map<string,bool> was_announced;
	int N;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		string s;
		cin >> s;
		if (was_announced.count(s)) {
			cout << "No\n";
			return;
		}
		if (i > 0 && (words.back()[words.back().length()-1] != s[0])) {
			cout << "No\n";
			return;
		}
		was_announced.insert(make_pair(s,true));
		words.pb(s);
	}

	cout << "Yes\n";
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define int long long
using namespace std;

typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);



signed main(){

    int N;
    cin >> N;
    vector<int> a(N);
    readvec(a);
    SORT(a);

    int ans = 0;
    int count = 1;
    int a_tmp = a[0];
    REP(i, N){
        if(i == N - 1 || a[i + 1] != a_tmp){
            if(count >= a_tmp){
                ans += count - a_tmp;
            }else{
                ans += count;
            }
            count = 1;
            a_tmp = a[i + 1];
        }else{
            count++;
        }
    }

    cout << ans;

    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 1024
import java.util.*;
class Main {
     
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        Dice dice = new Dice(stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt(),stdIn.nextInt());
        String a = stdIn.next();
        for(int i = 0; i < a.length(); i++) {
            if(a.charAt(i) == 'N') {
                dice.TurnN();
            }
            else if(a.charAt(i) == 'W') {
                dice.TurnW();
            }
            else if(a.charAt(i) == 'E') {
                dice.TurnE();
            }
            else {
                dice.TurnS();
            }
        }
        System.out.println(dice.Top);
    }
     
     
}
 
class Dice {
    int Top; 
    int Bottom; 
    int N; 
    int S; 
    int W;
    int E; 
    Dice(int a, int b, int c, int d, int e, int f) {
        Top = a;
        S = b;
        E = c;
        W = d;
        N = e;
        Bottom = f;
    }
    public void TurnN() {
        int tmp = Top;
        Top = S;
        S = Bottom;
        Bottom = N;
        N = tmp;
    }
    public void TurnW() {
        int tmp = Top;
        Top = E;
        E = Bottom;
        Bottom = W;
        W = tmp;
    }
    public void TurnE() {
        int tmp = Top;
        Top = W;
        W = Bottom;
        Bottom = E;
        E = tmp;
    }
    public void TurnS() {
        int tmp = Top;
        Top = N;
        N = Bottom;
        Bottom = S;
        S = tmp;
    }
     
}


Measured memory_bytes: 26264
// #include <iostream>
#include <bits/stdc++.h>
// https://beta.atcoder.jp/contests/arc098/submissions/2567080
// https://beta.atcoder.jp/contests/arc098/submissions/2563485

using namespace std;

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

    long n;
    cin >> n;
    // char s[n];
    string s;
    // scanf("%s", &s);
    cin >> s;
    long right_e = 0;
    // for (long i = 0; i < n; i++) if (s[i] == 'E') right_e++;
    for (long i = 1; i < n; i++) right_e += (s[i] == 'E');
    // for (long i = 1; i < n; i++) if (s[i] == 'E') right_e++;
    long min_count = right_e;
    long left_w = 0;
    for (long i = 1; i < n; i++) {
    // for (long i = 1; i < n; i++) {
        if (!min_count) break;
        right_e -= s[i] == 'E';
        right_e += s[i - 1] == 'W';
        min_count = min(min_count, right_e + left_w);
        //     if (s[i] == 'E') {
        //     right_e--;
        // } else {
        //     right_e++;
        // }
        // if (s[i ] == 'W') right_e++;
        // if (s[i -1] == 'W') left_w++;
        // min_count = min(min_count, right_e);
    }
    cout << min_count << '\n';
    
    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    string s;
    cin >> s;
    if (s == "Sunny") {
println("Cloudy");
    }
    else if (s == "Cloudy") {
println("Rainy");
    }
    else {
println("Sunny");
    }
    return 0;
}

Measured memory_bytes: 3588
S = int(input())

if S < 3:
    print(0)
    exit()

ans = [0 for _ in range(2001)]

ans[3] = 1
ans[4] = 1
ans[5] = 1

for i in range(6, S+1):
    ans[i] = ans[i-3] + ans[i-1]

print(ans[S] % 1000000007)


Measured memory_bytes: 9204
#include <iostream>

using namespace std;
int n;
int a[35];

int main(){
    a[0]=1;
    a[1]=1;
    a[2]=2;
    for(int i=3;i<31;i++) a[i]=a[i-3]+a[i-2]+a[i-1];
    while(cin>>n&&n){
        cout<<((a[n]+9)/10+364)/365<<endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
#define N 200005
int a,b,ans,A[N],n,an,la;
int main() {
	scanf("%d",&n);
	for(int i=1; i<=n; i++) {
		scanf("%d",&A[i]);
		if(A[i]>an)la=an,an=A[i];
		else if(A[i]>la)la=A[i];
	}
	for(int i=1; i<=n; i++) {
		if(A[i]==an)printf("%d\n",la);
		else printf("%d\n",an);
	}
	return 0;
}

Measured memory_bytes: 2432
// execute g++ main.cpp -std=c++14 -I C:\Users\naoya\Desktop\code\Atcoder
#include<bits/stdc++.h>
//#include<atcoder/all>
typedef long long ll;
typedef long double ld;
using namespace std;
//using namespace atcoder;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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


char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    ll n, a, b; cin >> n >> a >> b;
    vector<ll> hlis(n);
    REP(i, 0, n){cin >> hlis[i];}
    sort(ALL(hlis));
    ll left = 0, right = 1e10;
    while(right - left > 1){
        vector<ll> cp = hlis;
        ll mid = (right + left) / 2;
        //cout << mid << endl;
        ll have = mid;
        REP(i, 0, n){
            have -= (max(0LL, cp[i] - (mid * b)) + (a-b-1)) / (a-b);
        }
        if(have < 0){
            left = mid;
        }else{
            right = mid;
        }
    }
    ll have = left;
    REP(i, 0, n){
        have -= (max(0LL, hlis[i] - (left * b)) + (a-b-1)) / (a-b);
    }
    if(have < 0){
        cout << right << endl;
        return 0;
    }else{
        cout << left << endl;
        return 0;
    }
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

#define ff first
#define ss second
#define pb push_back
#define sz size()
#define mp make_pair

const int N = 2005;
const int MOD = 1e9 + 7;

pair<int, int> A[N];
ll dp[N][N];
int n;

ll call(int i, int L){

  if(i == n) return 0;
  if(dp[i][L] != -1)return dp[i][L];
  int R = n - 1 - (i - L);
  // cout << L << ' ' << R << endl;
  ll ret = 1LL * A[i].ff * abs(L - A[i].ss) + call(i + 1, L + 1);
  if(L != R)ret = max(ret, 1LL * A[i].ff * abs(R - A[i].ss) + call(i + 1, L));
  return dp[i][L] = ret;
}

int main() {

  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> A[i].ff;
    A[i].ss = i;
  }
  sort(A, A + n, greater<pii>());
  memset(dp, -1, sizeof dp);
  cout << call(0, 0) << endl;
  return 0;
}

Measured memory_bytes: 35204
l, r = gets.split.map &:to_i
if r-l>=673
  p 0
  exit
end
ans = Float::INFINITY
(l...r).each do |_i|
  i = _i%2019
  (_i+1..r).each do |j|
    m = i*j%2019
    ans = m if m < ans
    if ans==0
      p 0
      exit
    end
  end
end
p ans


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

const int N = 1e6 + 5;

int main(){
    ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0);
    int n , k;
    cin >> n >> k;
    int arr[n];
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }

    sort(arr , arr + n);
    ll ans = 1e18;
    for(int i = 0 ; i < n - k + 1 ; i ++) {
        ans = min(ans , 1ll*arr[i + k - 1] - arr[i]);
    }
    cout << ans;
}


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

int main() {
    int N,i,k=100;
    cin >> N;

    for(i=0;i<N;i++){
        int a,l=0;
        cin >> a;
        while (a%2 == 0){
            a /= 2;
            l++;
        }

        if(k > l){
            k = l;
        }
    }

    cout << k << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int MAX = 100001;
struct S{
    struct D{
        string s;
        int t;
    };
    D dat[MAX];
    int head, tail;
    S(){
        head=tail=0;
    }
    void enqueue(D x){
        dat[tail]=x;
        if(tail+1==MAX) tail=0;
        else ++tail;
    }
    D dequeue(){
        D x=dat[head];
        if(head+1==MAX) head=0;
        else ++head;
        return x;
    }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,Q;
    cin>>N>>Q;
    S q;
    S::D d;
    for(int i=0;i<N;++i){
        cin>>d.s>>d.t;
        q.enqueue(d);
    }
    int elapse=0;
    while(q.head!=q.tail){
        d=q.dequeue();
        if(d.t>Q){
            d.t=d.t-Q;
            q.enqueue(d);
            elapse+=Q;
        }else{
            cout<<d.s<<' '<<d.t+elapse<<endl;
            elapse+=d.t;
        }
    }
}

Measured memory_bytes: 7040
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
const ll mod=1e9+7;
const ll inf=1<<29;

const int M=10000;

int n,c;

int main(){
	cin>>n>>c;
	vvi dp(c+1,vi(M+1,-inf));
	dp[0][0]=0;
	for(int i=0;i<n;i++){
		int A,B,C;
		cin>>A>>B>>C;
		vvi DP=dp;
		for(int j=0;j<=c-C;j++) for(int k=0;k<=M;k++){
			int tmp=dp[j][k];
			if(max(tmp+A,k+B)<=M) DP[j+C][max(tmp+A,k+B)]=max(DP[j+C][max(tmp+A,k+B)],min(tmp+A,k+B));
			if(max(tmp+B,k+A)<=M) DP[j+C][max(tmp+B,k+A)]=max(DP[j+C][max(tmp+B,k+A)],min(tmp+B,k+A));
		}
		dp=DP;
	}
	int res=0;
	for(int i=0;i<=c;i++) for(int j=0;j<M;j++) res=max(res,dp[i][j]);
	cout<<res<<endl;
}

Measured memory_bytes: 10812
#include<stdio.h>

int main(){
	char a,b,c;
	int x,y,z;

	scanf("%c%c%c",&a,&b,&c);

	x = a - '0';
	y = b - '0';
	z = c - '0';

	if(x == 7){
		printf("Yes");
	}
	else if(y == 7){
		printf("Yes");
	}
	else if(z == 7){
		printf("Yes");	
	}
	else{
		printf("No");
	}

	return 0;
}


Measured memory_bytes: 1644
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int H, A;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> H >> A;

	int ans = (H + A - 1) / A;
	cout << ans << endl;
}







Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

int main() {
	bool flag = false;
	for (int X; cin >> X&&X;) {
		if (flag)cout << endl;
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int sum = a * 10 + b * 50 + c * 100 + d * 500;
		int Y = sum - X;

		int A, B, C, D;
		D = Y / 500;
		Y -= D * 500;
		C = Y / 100;
		Y -= C * 100;
		B = Y / 50;
		Y -= B * 50;
		A = Y / 10;
		Y -= A * 10;
		a -= A;
		b -= B;
		c -= C;
		d -= D;
		if (a > 0)cout << "10 " << a << endl;
		if (b > 0)cout << "50 " << b << endl;
		if (c > 0)cout << "100 " << c << endl;
		if (d > 0)cout << "500 " << d << endl;
		flag = true;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。

int main(){
      cin.tie(0);
      ios::sync_with_stdio(false);
      /*rep0(i,8){
            rep0(j,8) cout<<board[i][j]<<" ";
            cout<<endl;
      }*/
      deque<int> deq;
      int n;
      cin>>n;
      int p[n];
      rep0(i,n){
            cin>>p[i];
      }
      int pos=0;
      string ans;
      int ok=true;
      rep0(i,n){
            if(pos<p[i]){
                  int addd=p[i]-pos;
                  rep1(j,addd){
                        ans+='(';
                  }
                  for(int k=pos+1;k<=p[i];k++){
                        deq.push_back(k);
                  }
                  ans+=')';
                  deq.pop_back();
                  pos=p[i];
            }
            else{
                  int b=deq.back();
                  if(b!=p[i]) ok=false;
                  ans+=')';
                  deq.pop_back();
            }
      }
      //cout<<ans<<endl;
      if(ok){
            cout<<ans<<endl;
      }
      else{
            cout<<":("<<endl;
      }

      return 0;
}


Measured memory_bytes: 3952