akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
	cin >> s;
	if (s == "Sunny")
		cout << "Cloudy";
	if (s == "Cloudy")
		cout << "Rainy";
	if (s == "Rainy")
		cout << "Sunny";
	cout << endl;
	fclose(stdin);
	fclose(stdout);
	return 0;	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a, b, c, n;
string s;



int main()
{
   cin>>a>>b;
  if(a<10&&b<10)
    cout<<a*b<<endl;
  else
    cout<<-1<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include "atcoder/all"
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
const ll mod = 1e9 + 7;
int main() {
  string s;
  cin >> s;

  if (s.back() == 's') {
    cout << s + "es" << endl;
  } else {
    cout << s + "s" << endl;
  }
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(n) for (ll i = 0; i < n; ++i)
#define rep2(i, n) for (ll i = 0; i < n; ++i)
#define rep3(i, a, b) for (ll i = a; i < b; ++i)
#define rep4(i, a, b, c) for (ll i = a; i < b; i += c)
#define erep(n) for (ll i = 0; i <= n; ++i)
#define erep2(i, n) for (ll i = 0; i <= n; ++i)
#define erep3(i, a, b) for (ll i = a; i <= b; ++i)
#define erep4(i, a, b, c) for (ll i = a; i <= b; i += c)
#define rrep(i, a, b) for (ll i = a; i > b; --i)
#define rrep2(i, a, b, c) for (ll i = a; i > b; i -= c)
#define errep(i, a, b) for (ll i = a; i >= b; --i)
#define errep2(i, a, b, c) for (ll i = a; i >= b; i -= c)
#define print(a) cout << a << endl;
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define cin(x) cin >> x;
const ll MOD = 1000000007;
inline int newline() { putchar('\n'); return 0; }

int main() {
    double h, a;
    cin(h);
    cin(a);

    print(ceil(h / a));
    return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)

int p[7][7] = {
	{0, 1, 3, 4, 5, 8, 9},
	{1, 2, 4, 5, 6, 9, 10},
	{3, 4, 7, 8, 9, 12, 13},
	{4, 5, 8, 9, 10, 13, 14},
	{5, 6, 9, 10, 11, 14, 15},
	{8, 9, 12, 13, 14, 16, 17},
	{9, 10, 13, 14, 15, 17, 18}
};

string c;

int main() {
	while (cin >> c, c != "#") {
		bool ans = true;
		
		for_(bit,0,(1<<19) && ans) {
			int f = 0, b = 0;
			
			for_(i,0,7) {
				int t = 0;
				for_(j,0,7) if (bit & (1 << p[i][j])) t |= 1 << j;
				if (c[t] - '0') f |= (1 << i);
				if (i == 3) b = c[t] - '0';
			}
			
			ans &= !(b == 1 && c[f] == '0') && !(b == 0 && c[f] == '1');
		}
		
		if (ans) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N;
map<ll, int> mp;

int main(void){
    
    scanf("%d", &N);
    for(int i = 0; i < N; ++i){
        ll a; scanf("%lld", &a);
        ++mp[a];
    }
    
    int ans = 0;
    for(auto m : mp) if(m.second % 2 == 1) ++ans;
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<string>

using namespace std;

int main(){

    int n, m;
    cin >> n >> m;

    vector<priority_queue<int, vector<int>, greater<int> > > pq(n);
    vector<pair<int, int> > li(m);
    map<int, int> all;
    for (int i = 0; i < m; ++i)
    {
        int p, y;
        cin >> p >> y;

        pq[p-1].push(y);
        li[i] = make_pair(p, y);

    }
    int top;
    for (int i = 0; i < n; ++i)
    {
        int j = 1;
        while (!pq[i].empty())
        {
            top = pq[i].top();
            all.insert(make_pair(top, j));
            pq[i].pop();
            ++j;
        }
    }

    for (int i = 0; i != li.size();++i){
        string f, s;
        //pの出力
        f = to_string(li[i].first);

        s = to_string(all[li[i].second]);

        for (int j = f.size(); j < 6;++j){
            cout << "0";
        }
        cout << f;
        for (int j = s.size(); j < 6;++j){
            cout << "0";
        }
        cout << s << endl;
    }

    return 0;
}

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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;

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




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




void printv(vint &v){
  for(auto e:v) cout<<e<<" ";
  cout<<endl;
}


int main() {


  cout<<fixed<<setprecision(10);

  ll n; cin>>n;
  vint a(n); rep(i,n) cin>>a[i];

  sort(ALL(a));
  bool f = true;

  rep(i,n-1){
    if(a[i] == a[i+1]){
      f = false;
      break;
    }
  }


  if(f) puts("YES");
  else puts("NO");

}

//


Measured memory_bytes: 1792
from collections import deque
N, K = map(int, input().split())

A = list(map(int, input().split()))

loop = deque([0])
teleported = [False] * N

loop_start = 0
loop_end = []

while True:
    i = loop[len(loop) - 1]
    if teleported[i]:
        loop_end = [i, A[i] - 1]        
        break
    teleported[i] = True
    loop.append(A[i] - 1)

cnt = [0] * (N)

for i in range(len(loop)):
    cnt[loop[i]] += 1
    if cnt[loop[i]] == 2:
        loop_end[0] = i
        cnt[0] = loop[i]

loop_start = loop.index(cnt[0])
loop_end = loop_end[0]
loop = list(loop)
loop_2 = loop[loop_start:loop_end]

if K < loop_start:
    print(loop[K] + 1)

else:
    ans = loop_2[(K - loop_start) % len(loop_2)] + 1
    print(ans)

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

using namespace std;

int nbpierres;
int pierres[100000];
int bestscore[100000];

signed main()
{
    ios::sync_with_stdio(false);
    cin>>nbpierres;
    for(int i = 0 ; i < nbpierres ; i ++)
    {
        cin>>pierres[i];
    }
    for(int i = nbpierres-1 ; i >=0 ; i--)
    {
        int mini = 1<<30;
        if(i+1<nbpierres)
        {
            mini = min(mini,bestscore[i+1]+abs(pierres[i]-pierres[i+1]));
        }
        if(i+2<nbpierres)
        {
            mini = min(mini,bestscore[i+2]+abs(pierres[i]-pierres[i+2]));
        }
        bestscore[i]=(mini == 1<<30 ? 0 : mini);
    }
    cout<<bestscore[0];
}


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

int main()
{
	int n;cin>>n;
	n%=10;
	if(n==2||n==4||n==5||n==7||n==9)cout<<"hon"<<endl;
	else if(n==0||n==1||n==6||n==8)cout<<"pon"<<endl;
	else cout<<"bon"<<endl;
	return 0;
}

Measured memory_bytes: 3552
#include <stdio.h>

int main()
{
    int d;
    scanf("%d",&d);

    if(d==25){
        printf("Christmas\n");
    }
    else if(d==24){
        printf("Christmas Eve\n");
    }
    else if(d==23){
        printf("Christmas Eve Eve\n");
    }
    else {
        printf("Christmas Eve Eve Eve\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
using namespace std;
 
typedef long long LL;
 
int main () {
	LL n,m;
	while (scanf("%lld %lld",&n,&m) != EOF) {
		LL L=0,R=1e12 + 1;
		while (R-L!=1) {
			LL mid=(L+R)>>1;
			LL need_n = mid-n;
			LL tmp=m;
			if (need_n > 0) {
				tmp -= 2*need_n;
			}
			if (tmp >= mid*2) L=mid;
			else R=mid;
		}
		printf("%lld\n",L);
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
	string a, b;
	int c;

	cin >> a >> b;
	a += b;
	c = atoi(a.c_str());

	for (int i = 1; i < 330; i++) {
		if (i * i == c) {
			printf("Yes");
			return 0;
		}
	}

	printf("No");

    return 0;
}



Measured memory_bytes: 256
l=input()
n=len(l)
i=0
ans=0
while i<n:
	j=0
	if l[i]=='R':
		c=0
		while i+j<n and l[i+j]==l[i]:
			c+=1	
			j+=1 
		ans=max(ans,c)
		i+=j
	else:
		i+=1
print(ans)

Measured memory_bytes: 9120
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main(){

	//3<=n<=10^5\
	//N guusuu

	int n = 0;
	cin >> n;

	//int p[10^5];
	vector<int> v;
	
	for (int i = 0; i < n; i++){
		//cin >> p[i];
		int tmp;
		cin >> tmp;
		v.push_back(tmp);
	}

	//for (int i = 0; i < n; i++){
	//	cout << v[i] << endl;
	//}

	std::sort(v.begin(), v.end(), std::greater<int>());

	//for (int i = 0; i < n; i++){
	//	cout << v[i] << endl;
	//}

	//int count = 0;

	//for (int i = 0; i < n; i++){
	//	;
	//}

	cout << v[(n / 2)-1] - v[n / 2] << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 892
while(True):
    H, W = map(int, input().split())
    if(H == W == 0):
        break
    str = ""
    for i in range(W):
        if(i % 2 == 0):
            str += "#"
        else:
            str += "."
    str2 = ""
    for i in range(W):
        if(i % 2 == 0):
            str2 += "."
        else:
            str2 += "#"
    for i in range(H):
        if(i % 2 == 0):
            print(str)
        else:
            print(str2)
    print()

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> m(h);
  for(int i = 0; i < h; i++) cin >> m.at(i);
  
  int ans = 0;
  vector<int> dx = {0, 0, -1, 1};
  vector<int> dy = {1, -1, 0, 0};
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(m.at(i).at(j) == '#') continue;
      queue<pair<int, int>> bfs;
      bfs.push({j, i});
      int cnt = -1;
      vector<vector<int>> check(h, vector<int>(w));
      check.at(i).at(j) = 1;
      while(bfs.size() > 0){
        cnt++;
        queue<pair<int, int>> next;
        while(bfs.size() > 0){
          next.push(bfs.front());
          bfs.pop();
        }
        while(next.size() > 0){
          int x = next.front().first, y = next.front().second;
          next.pop();
          for(int k = 0; k < 4; k++){
            int nx = x + dx.at(k), ny = y + dy.at(k);
            if(nx < 0 || ny < 0 || nx >= w || ny >= h) continue;
            if(m.at(ny).at(nx) == '#') continue;
            if(check.at(ny).at(nx)) continue;
            check.at(ny).at(nx) = 1;
            bfs.push({nx, ny});
          }
        }
      }
      ans = max(ans, cnt);
    }
  }
  
  cout << ans << endl;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  vll a(n); rep(i,n) cin>>a[i];
  
  ll ans=0;
  
  ll sum=0;
  rep(i,n){
    if(a[i]==0){
      ans+=sum/2;
      sum=0;
    }else{
      sum+=a[i];
    }
  }
  ans+=sum/2;
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3996
import sys
def solve():
    sys.setrecursionlimit(1000000)
    input = sys.stdin.readline
    N, Q = map(int, input().split())
    tree = [[] for i in range(N)]
    counter = [0] * N
    arrived = [False] * N
    for i in range(N-1):
        a, b = map(int, input().split())
        tree[a-1].append(b-1)
        tree[b-1].append(a-1)
    
    for i in range(Q):
        p, x = map(int, input().split())
        counter[p-1] += x
    
    arrived[0] = True
    adder(0, counter, tree, arrived)

    print(*counter)

def adder(ind, counter, tree, arrived):
    for i in tree[ind]:
        if arrived[i]:
            continue
        counter[i] += counter[ind]
        arrived[i] = True
        adder(i, counter, tree, arrived)
    if not tree[ind]:
        return

if __name__ == '__main__':
    solve()


Measured memory_bytes: 232496
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;
int main(){
	int n;cin >> n;
	vector<int> a(n);
	int tot = 0;
	rep(i,n){
		cin >> a[i];
		tot += a[i];
	}
	int av1 = tot/n;
	int av2 = tot/n+1;
	int sum1=0,sum2=0;
	rep(i,n){
		sum1 += (a[i]-av1)*(a[i]-av1);
		sum2 += (a[i]-av2)*(a[i]-av2);
	}
	cout << min(sum1,sum2) << endl;

} 
 

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
static const int MAX = 200000;
 
int main() {
    int N, R[MAX];
    cin >> N;
    for(int i = 0; i < N; i++)   cin >> R[i];
    int maxv = -2000000000;
    int minv = R[0];
    for(int i = 1; i < N; i++){
        maxv = max(maxv, R[i]-minv);
        minv = min(minv, R[i]);
    }
    cout << maxv << endl;
    return 0;
}



Measured memory_bytes: 3896
import sys
input = sys.stdin.readline

N,M = list(map(int,input().split()))
H = list(map(int,input().split()))
flag = [1]*N
for i in range(M):
    A,B = list(map(int,input().split()))
    if H[A-1] < H[B-1]:
        flag[A-1]=0
    elif H[B-1] < H[A-1]:
        flag[B-1] =0
    else:
        flag[A-1]=0
        flag[B-1]=0
print(sum(flag))


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

using namespace std;

int a,b;

int main()
{
	scanf("%d%d",&a,&b);
	if(a>b)
	    swap(a,b);
	for(int i=1;i<=b;i++)
	    printf("%d",a);
	printf("\n");
	return 0;
} 

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

int main() {
  int N,M;
  cin >> N >> M;
  int ac = 0;
  int wa = 0;
  map<int,int> ac_check;
  map<int,int> wa_cnt;
  for (int i = 0; i<M;i++) {
    int p;
    string S;
    cin >> p >> S;
    if ((S == "WA") && (ac_check[p] != 111)) { //不正解かつまだ正解してない
      wa_cnt[p]++;
    }
    
    
    else if ((S == "AC") && (ac_check[p] != 111)) { //正解かつまだ正解してない
      ac_check[p] = 111; //pを正解したとする
      ac++;
    }
  }
  
  for (int i = 1; i< N+1;i++) {
    if (ac_check[i] == 111) {
      wa += wa_cnt[i];
    }
  }
  
  cout << ac << " " << wa << endl;
  
}


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

int main()
{
	int n,c;
	c = 1;
	cin >> n;
	int d[100];

	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	for (int j = 0; j < n - 1; j++) {
		for (int k = j + 1; k < n; k++) {
			if (d[k] > d[j]) {
				int tmp = d[k];
				d[k] = d[j];
				d[j] = tmp;
			}
		}
	}
	for (int l = 0; l < n-1; l++) {
		if (d[l] != d[l + 1]){
			c += 1;
		}
	}
	cout << c << endl;
}

Measured memory_bytes: 256
x = int(input())
if 400 <= x and x < 600:
    print(8)
elif x < 800 :
    print(7)
elif x < 1000:
    print(6)
elif x < 1200:
    print(5)
elif x < 1400:
    print(4)
elif x < 1600:
    print(3)
elif x < 1800:
    print(2)
else :
    print(1)

Measured memory_bytes: 9176
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
#define dupli(a) a.erase(unique(all(a)),a.end())
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vvvvi=vector<vvvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const ll INF=1001001001;
const ll mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll h1,m1,h2,m2,k;cin>>h1>>m1>>h2>>m2>>k;
    out(max(0ll,(h2-h1)*60+m2-m1-k));
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int main() {
	ll N; cin >> N;
	ll l = 1, r = 112345;
	while (r - l > 1) {
		ll m = (l + r) / 2;
		if (m * m <= N) l = m;
		else r = m;
	}
	cout << l * l << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

int main() {
    int N, A, B, C;
    std::cin >> N >> A >> B >> C;

    std::vector<std::string> s(N);
    for (int i = 0; i < N; i++) {
        std::cin >> s[i];
    }

    std::vector<int> v = {A, B, C};
    std::vector<char> ans(N);

    for (int k = 0; k < N; k++) {
        auto f = [&](int i, int j) {
            v[i]++;
            v[j]--;
            ans[k] = i + 'A';
        };

        int i = s[k][0] - 'A', j = s[k][1] - 'A';

        if (v[i] == 0 && v[j] == 0) {
            std::cout << "No\n";
            return 0;
        }

        if (v[i] == 0) 
            f(i, j);
        else if (v[j] == 0 || k == N - 1)
            f(j, i);
        else {
            if (s[k] == "AB") {
                if (s[k + 1] == "AC")
                    f(i, j);
                else
                    f(j, i);
            }
            else {
                if (s[k + 1] == "AB")
                    f(i, j);
                else
                    f(j, i);
            }
        }
    }

    std::cout << "Yes\n";
    for (int i = 0; i < N; i++)
        std::cout << ans[i] << "\n";
}

Measured memory_bytes: 6424
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int a,b;
   cin >> a >> b;
   if(a-2*b < 0) cout << 0 << endl;
   else cout << a-2*b << endl;




   return 0;
}

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

using namespace std;

int main()
{
    int N;
    string S;
    cin >> N >> S;

    int cnt =0;
    for(int i=0; i<N-2; i++){
        if(S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C')
            cnt++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 3608
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)



int main(){
	int x,a;
	cin >> x >> a;
	if(x<a) cout << "0\n";
	else cout << "10\n";
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
  int i,a=0,b=0,c=0;
  string s;
  cin >> s;
  for (i=0;i<s.size();i++){
    if (s[i]=='a') a++;
    else if (s[i]=='b') b++;
    else c++;
  }
  if (max({a,b,c})-min({a,b,c})>=2) cout << "NO" << endl;
  else cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 512
#include<iostream>
using namespace std;
typedef unsigned long long ull;
int main(){
	int shape[7]={0x0303,0x01010101,0x0f,
		0x010302,0x0603,0x020301,0x0306};
	char c;
	int ans;
	while(cin>>c){
		ull mass=c-'0';	
		for(int i=1;i<64;i++){
			cin>>c;
			if(c=='1')mass |= (ull)1<<i; 
		}
		for(int i=0;i<64;i++){
			for(int j=0;j<7;j++){
				if((mass>>i&shape[j])==shape[j])ans=j;
			}
		}
		cout<<(char)(ans+'A')<<endl;
	}
	return 0;
}

Measured memory_bytes: 1128
#include<stdio.h>
int main() {
    int a,b,i,j;
    
    while(1) {
        scanf("%d%d",&a,&b);
        
        if(a==0&&b==0){
            break;
        }
        
        for(i=1;i<=a;i++) {
            for(j=1;j<=b;j++) {
                if(j%2==1) {
                    if(i%2==1)
                        printf("#");
                    else 
                        printf(".");
                        }
                else { if(i%2==1)
                            printf(".");
                        else 
                            printf("#");
                      } 
                
            } 
            printf("\n");
            
            
        } 
        printf("\n");
        
        
    } 
    
    return 0; 
    
} 



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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
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;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
char tr(char c){
  int a = c - 'A';
  int b = c - 'a';
  if(0 <= a && a < 26) return (char)(a + 'a');
  return c;
}
//-----------------------------------------

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  string s;
  cin >> s;
  int cnt = 0;
  while(1){
    string t;
    cin >> t;
    if(t == "END_OF_TEXT") break;
    int n = SZ(t);
    REP(i,n){
      t[i] = tr(t[i]);
    }
    if(s==t) cnt++;
  }
  cout << cnt << endl;




  return 0;
}



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

int selectionSort(std::vector<int>& a, int n){
    int minj, tmp, cnt;
    cnt = 0;
    for(int i = 0;  i < n; i++){
        minj = i;
        for(int j = i; j < n; j++){
            if(a[j] < a[minj]){
                minj = j;
            }
        }
        tmp = a[i];
        a[i] = a[minj];
        a[minj] = tmp;
        if(i != minj){
            cnt++;
        }
    }
    return cnt;
}

void displayVector(std::vector<int> a, int n){
    for(int i = 0; i < n; i++){
        std::cout << a[i];
        if(i != n-1){
            std::cout << " ";
        }
    }
    std::cout << std::endl;
}

int main(void){
    int n, cnt;
    scanf("%d", &n);
    std::vector<int> a(n);
    for(int i = 0; i < n; ++i){
        scanf("%d", &a[i]);
    }
    cnt = selectionSort(a, n);
    displayVector(a, n);
    std::cout << cnt << std::endl;
    
    return 0;
}


Measured memory_bytes: 3220
#include <cstring>
#include <iostream>
using namespace std;
const int MAX_WH = 100;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

int w, h;
int sx, sy, gx, gy;
int col;
int field[MAX_WH + 1][MAX_WH + 1];

bool solve(int x, int y) {
	if (x == gx && y == gy) return true;
	field[x][y] = -1;
	for (int i = 0; i < 4; i++) {
		int nextX = x + dx[i];
		int nextY = y + dy[i];
		if (0 < nextX && nextX <= w && 0 < nextY && nextY <= h && col == field[nextX][nextY]) {
			if (solve(nextX, nextY)) return true;
		}
	}
	return false;
}

int main () {
	while (cin >> w >> h, w || h) {
		memset(field, 0, sizeof(field));
		cin >> sx >> sy >> gx >> gy;
		int n;
		cin >> n;
		for (int i = 0; i < n; i++) {
			int c, d, x, y;
			cin >> c >> d >> x >> y;
			if (d == 0) {
				for (int i = 0; i < 2; i++) {
					for (int j = 0; j < 4; j++) {
						field[x + j][y + i] = c;
					}
				}
			}
			else {
				for (int i = 0; i < 4; i++) {
					for (int j = 0; j < 2; j++) {
						field[x + j][y + i] = c;
					}
				}
			}
		}
		col = field[sx][sy];
		cout << (solve(sx, sy) ? "OK" : "NG") << endl;
	}
	return 0;
}

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

int main(){
	int N, min = 0, max = 0, input;
	cin >> N;
	cin >> min;
	cin >> input;
	if (min > input) {
		max = min;
		min = input;
	}
	else if (min <= input) max = input;
	if (N != 2) {
		for (int i = 2; i < N; i++) {
			cin >> input;
			if (min > input) min = input;
			if (max <= input) max = input;
		}
	}
	cout << max - min << endl;
	system("pause");
}

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

char H[1050000][14]; 
int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}
 
int h1(int key){
  return key % 1050000;
}
int h2(int key){
  return 1 + (key % (1050000-1));
}
int find(char str[]){
  long long key, i, h;
  key = getKey(str);
  while(1){
    h = (h1(key) + i * h2(key)) % 1050000;
    if(strcmp(H[h], str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
    i++;
  }
  return 0;
}
int insert(char str[]){
  long long key, i, h;
  key = getKey(str);
  while(1){
    h = (h1(key) + i * h2(key)) % 1050000;
    if(strcmp(H[h], str) == 0) return 0;
    else if(strlen(H[h]) == 0){
      strcpy(H[h], str);
      return 0;
    }
    i++;
  }
  return 0;
}
int main(){
  int i, n, h;
  char str[14], com[9];
  for ( i = 0; i < 1050000; i++ ) H[i][0] = '\0';    
  scanf("%d", &n);   
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);  
    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }
 
  return 0;
}


Measured memory_bytes: 16140
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7;

int main(int argc, char const *argv[])
{
    ll n, m;
    cin >> n >> m;
    if (n == 1 && m == 1)
    {
        cout << 1 << endl;
    }
    else if (n == 1)
    {
        cout << max(0ll, m - 2) << endl;
    }
    else if (m == 1)
    {
        cout << max(0ll, n - 2) << endl;
    }
    else
    {
        cout << (n - 2) * (m - 2) << endl;
    }
    return 0;
}


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

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n';)s+=c;return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;if((c=gcu())=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
	_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

int main() {
	array<array<int, 4001>, 4> dp {};
	dp[0].fill(1);
	for(int i: range(3))
		for (int j: range((i + 1) * 1000 + 1))
			for (int k: range(1001))
				dp[i + 1][j + k] += dp[i][j];
	for (int n; scan(n);)
		outl(dp[3][n]);
}


Measured memory_bytes: 2688
N, Y = map(int,input().split())
for i in range(N + 1):
  for j in range(N - i + 1):
    if Y == 1000*i + 5000*j + 10000*(N - j - i):
      print(N - j - i, j, i)
      exit(0)
print(-1,-1,-1)

Measured memory_bytes: 9132
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	string s;
	bool a = 0;
	cin >> s;
	for (int i = 0; i <= s.size(); i++) {
		if (s[i] == 'A' && s[i + 1] == 'C') a = 1;
	}
	cout << (a?"Yes":"No");
	return 0;
}



Measured memory_bytes: 256
X = str(input())
alist = ["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"]
for i in range(30):
  if X == alist[i]:
    print(alist[i+1])
    break



Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int k,n,ans,tmp=0,mx=0;
    cin >> k >> n;
    vector<int> vec(n);
    rep(i,n){
        cin >> vec.at(i);
        if(i)tmp=vec.at(i)-vec.at(i-1);
        mx=max(mx,tmp);
    }
    tmp=vec.at(0)-vec.at(n-1)+k;
    mx=max(tmp,mx);
    cout << k-mx << endl;
}


Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			int s = 0;
			int e = n - 1;
			Console.WriteLine(s);
			string ss = cin.Next();
			if (ss == "Vacant") {
				return;
			}

			Console.WriteLine(e);
			string es = cin.Next();
			if (es == "Vacant") {
				return;
			}

			int next = (s + e) / 2;
			for (int i = 0; i < 18; i++) {
				Console.WriteLine(next);
				string rep = cin.Next();
				if (rep == "Vacant") {
					return;
				}

				if (((next - s + 1) % 2 == 0 && ss == rep)
					|| ((next - s + 1) % 2 == 1 && ss != rep)) {
					e = next;
					es = rep;
				} else {
					s = next;
					ss = rep;
				}

				next = (s + e) / 2;
			}
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

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

int main(){
    int N;
    std::cin >> N;
    std::vector< std::pair< int , int > > AB(N);
    for(int i=0; i<N; i++){
        std::cin >> AB[i].second >> AB[i].first;
    }
    
    std::sort(AB.begin(), AB.end());
    int time = 0;
    for(int i=0; i<N; i++){
        time += AB[i].second;
        if(time > AB[i].first){
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    
    std::cout << "Yes" << std::endl;
    
    return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
//最小公倍数
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N; cin >> N;
    vector<ll> f(N+1,0);
    ll out = 0;
    /*
    for(int j=1;j<=N;j++){
        for(int i=1;i<=N;i++){
            if(i%j==0) out++;
        }
    }*/
    for(int i=1;i<=N;i++){
        ll Y = N/i;
        out += Y*(Y+1)*i/2;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 81316
import java.util.*;
import java.io.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int sum = 0;
		int[] arr = new int[n];
		for(int i = 0;i<arr.length;i++) {
			arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);

		for (int i = 0; i < k; i++) {
			sum += arr[i];
		}
		System.out.println(sum);

	}

}


Measured memory_bytes: 38732
#include<stdio.h>
int main(void){
	long long int n,m,x,y;
	scanf("%lld %lld",&n,&m);
	if(n>=m) printf("%lld\n",m/2);
	else{
		x=(m-n*2)/4+n;
		printf("%lld\n",x);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

static uint64_t gcd(uint64_t a, uint64_t b)
{
	uint64_t temp;

	if (a < b) {
		temp = a;
		a = b;
		b = temp;
	}

	uint64_t r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

static uint64_t lcm(uint64_t a, uint64_t b)
{
	uint64_t temp, _gcd;

	if (a < b) {
		temp = a;
		a = b;
		b = temp;
	}

	_gcd = gcd(a, b);

	uint64_t sho_a = a / _gcd;
	uint64_t sho_b = b / _gcd;
	return sho_a * sho_b * _gcd;
}

static int64_t _count(int64_t value, int64_t C, int64_t D, int64_t lcm)
{
	return (value / C) + (value / D) - (value / lcm);
}

int main()
{
	int64_t A, B, C, D;
	cin >> A >> B >> C >> D;

	int64_t _lcm = lcm(C, D);

	cout << (B - A + 1 - (_count(B, C, D, _lcm) - _count(A - 1, C, D, _lcm))) << endl;

	return 0;
}


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

namespace atcoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var buffer = Console.ReadLine().Split();
            var N = int.Parse(buffer[0]);
            var M = int.Parse(buffer[1]);
            var H = new List<int>();
            var list = new List<int>();
            foreach (var v in Console.ReadLine().Split())
            {
                H.Add(int.Parse(v));
                list.Add(0);
            }

            for (int i = 0; i < M; i++)
            {
                buffer = Console.ReadLine().Split();
                var a = int.Parse(buffer[0]) - 1;
                var b = int.Parse(buffer[1]) - 1;

                list[a] = Math.Max(list[a], H[b]);
                list[b] = Math.Max(list[b], H[a]);
            }

            var ans = 0;
            for (int i = 0; i < N; i++)
                ans += H[i] > list[i] ? 1 : 0;

            Console.WriteLine(ans);
        }
    }
}


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

int main() {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    vector<string> a = {"dream", "dreamer", "erase", "eraser"};

    for (int i = 0; i < 4; i++) {
        reverse(a.at(i).begin(), a.at(i).end());
    }

    while (!s.empty()) {
        if (s.substr(0, 5) == a.at(0) || s.substr(0, 5) == a.at(2)) {
            s.erase(0, 5);
        }

        else if (s.substr(0, 7) == a.at(1)) {
            s.erase(0, 7);
        }

        else if (s.substr(0, 6) == a.at(3)) {
            s.erase(0, 6);
        }

        else {
            break;
        }
    }

    if (s.empty()) {
        cout << "YES" << endl;
    }

    else {
        cout << "NO" << endl;
    }
}

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

int main() {
int a,b;
cin>>a>>b;
if(a==b)
cout<<"Draw"<<endl;
else if(a==1)
cout<<"Alice"<<endl;
else if(b==1)
cout<<"Bob"<<endl;
else if(a>b)
cout<<"Alice"<<endl;
else if(a<b)
cout<<"Bob"<<endl;
return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int d[4];
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b),a+b){
		int ret=999999999;
		for(int i=1;i*i<=a;i++){
			if(a%i==0){
				d[0]=i;
				d[1]=a/i;
				for(int j=1;j*j<=b;j++){
					if(b%j==0){
						d[2]=j;
						d[3]=b/j;
						std::sort(d,d+4);
						int val=0;
						for(int k=0;k<3;k++)val+=(d[k+1]-d[k])*(d[k+1]-d[k]);
						ret=min(ret,val);
						d[0]=i;
						d[1]=a/i;
					}
				}
			}
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<cstring>
#include<cstdlib>
using namespace std;
int n,m,s;char a[100][100];
int main()
{
  cin>>n>>m;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)
      cin>>a[i][j];
  for(int i=1;i<=n;i++)
  {
    for(int j=1;j<=m;j++)
      if(a[i][j]=='.')
      {
      	s=0;
        for(int k=max(1,i-1);k<=min(n,i+1);k++)
          for(int l=max(1,j-1);l<=min(m,j+1);l++)
            if(a[k][l]=='#')s++;
        cout<<s;
      }
      else cout<<'#';
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys
import itertools
from operator import itemgetter #sortedの対象を決めたい
from fractions import gcd #最大公約数
from math import ceil, floor, sqrt, isinf #小数点切り上げ、切り捨て、平方根
from copy import deepcopy #参照で影響されないコピー
from collections import Counter, deque #要素ごとの出現回数、双方向アクセス可能データ型
import heapq
import numpy as np
from functools import reduce
sys.setrecursionlimit(200000)

input = sys.stdin.readline
# template

def retmax(a, b):
    if a > b:
        return a
    else:
        return b

def main():
    n = int(input())
    a = [list(map(int, input().split())) for _ in range(n)]

    dp = np.zeros([3, n+1])

    for i, a_l in enumerate(a):
        for j in range(3):
            for k in range(3):
                if j != k:
                    dp[k, i+1] = retmax(dp[k, i+1], dp[j, i] + a_l[k])

    print(int(np.max(dp[:, n], axis=0)))


if __name__ == "__main__":
    main()



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

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;

	vector<pair<long long, int>> v(N);
	for (auto &x : v) {
		cin >> x.first >> x.second;
	}
	sort(v.rbegin(), v.rend());

	long long ans = 0;
	while (M > 0) {
		auto &t = v.back();
		int x = min(M, t.second);
		ans += x * t.first;
		M -= x;
		v.pop_back();
	}
	cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int x;
  cin >> x;
  if(x) cout << 0;
  else cout << 1;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
#include <bitset>
using namespace std;

int main() {
        int n, m;
        scanf("%d%d", &n, &m);
        vector<vector<int>> g(n);
        vector<vector<bool>> forb(n, vector<bool> (n, false));
        for (int i = 0; i < m; i ++) {
                int a, b;
                scanf("%d%d", &a, &b);
                a --, b --;
                forb[a][b] = true;
                forb[b][a] = true;
        }
        for (int i = 0; i < n; i ++) {
                for (int j = i + 1; j < n; j ++) {
                        if (!forb[i][j]) {
                                g[i].push_back(j);
                                g[j].push_back(i);
                        }
                }
        }
        vector<bool> used(n);
        vector<int> color(n, -1);
        int white_cnt = 0, black_cnt = 0;
        function<bool (int, int, int)> dfs = [&](int u, int prev, int c) {
                used[u] = true;
                color[u] = c;
                if (c == 1) white_cnt ++;
                else black_cnt ++;
                for (auto v : g[u]) if (v != prev) {
                        if (color[v] == -1) {
                                if (!dfs(v, u, 1 - c)) return false;
                        } else if (color[v] != 1 - c) {
                                return false;
                        }
                }
                return true;
        };
        vector<pair<int, int>> hoge;
        for (int i = 0; i < n; i ++) {
                if (!used[i]) {
                        white_cnt = 0;
                        black_cnt = 0;
                        if (!dfs(i, -1, 0)) {
                                printf("-1\n");
                                return 0;
                        }
                        hoge.emplace_back(white_cnt, black_cnt);
                }
        }
        bitset<1000> creatable;
        creatable[0] = 1;
        for (int i = 0; i < (int) hoge.size(); i ++) {
                int a, b;
                tie(a, b) = hoge[i];
                creatable = (creatable << a) | (creatable << b);
        }
        // cerr << creatable << endl;
        int ans = 100000000;
        for (int i = 0; i < n; i ++) {
                if (creatable[i]) {
                        ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
                }
        }
        printf("%d\n", ans);
        return 0;
}



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

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

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

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

    cout << count << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
int main()
{
  char s[11],t[11],*str;
  int l;
  scanf("%s",s);
  scanf("%s",t);
  l=strlen(s);
  if(strncmp(s,t,l)== 0)
    puts("Yes");
  else
    puts("No");
  return 0;
}

Measured memory_bytes: 2108