akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
 
using namespace std;
 
 template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
const double EPS=0.00001;
const LL mod=998244353;
bool chk(PII a,PII b,PII c){
    return ((b.first - a.first) * (c.second - a.second) - (b.second - a.second) * (c.first - a.first))==0;
}

int main(){
    int N;cin>>N;
    vector<PII>xy(N);
    set<vector<PII>>st;
    REP(i,N){
        cin>>xy[i].first>>xy[i].second;
    }
    LL res=N+1;
    REP(i,N)FOR(j,i+1,N){
        LL cnt=2;
        vector<PII>pi;
        pi.PB(xy[i]);pi.PB(xy[j]);
        REP(k,N)if(k!=i&&k!=j){
            if(chk(xy[i],xy[j],xy[k])){
                cnt++;pi.PB(xy[k]);
            }
        }
        SORT(pi);
        if(st.find(pi)==st.end()){
            LL tmp=1;
            REP(ii,cnt)tmp=tmp*2LL%mod;
            res+=tmp-cnt-1LL;
            res%=mod;
            st.insert(pi);
        }
    }
    LL res2=1LL;
    REP(i,N)res2=res2*2LL%mod;
    cout<<(res2-res+mod)%mod<<endl;
    return 0;
}


Measured memory_bytes: 2176
n = int(input())
s = "SHCD"
used = [[0] * 13 for i in range(4)]
for i in range(n):
    a, b = input().split()
    used[s.find(a)][int(b) - 1] = 1
for i in range(4):
    for j in range(13):
        if used[i][j] == 0:
            print(s[i], j + 1)


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

int main(){
    vector<int> city(5);
    int k;
    for(int i = 0; i < 5; i++){
        cin >> city[i];
    }
    cin >> k;

    for(int i = 0; i < 4; i++){
        for(int j = i + 1; j < 5; j++){
            if(city[j] - city[i] > k){
                cout << ":(" << endl;
                return 0;
            }
        }
    }

    cout << "Yay!" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
int main(){
    int s, w;
    cin >> s >> w;
    if(s <= w) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
// greater<int>()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x%y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;


int main() {

	int a, b, c;
	cin >> a >> b >> c;
	int ans = 0;
	for (int i = a; i <= b; i++)
	{
		if (c % i == 0) {
			ans++;
		}
	}

	cout << ans << endl;
}



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

int main()
{
    char s[10],t[10],u[10];
    int a,b;
    scanf("%s %s",s,t);
    scanf("%d %d",&a,&b);
    scanf("%s",u);
    if(strcmp(u,s)==0)
    {
        a--;
    }
    else if(strcmp(u,t)==0)
    {
        b--;
    }
    printf("%d %d",a,b);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int N = 100;
int count = 0;

void BubbleSort(int A[], int n){

  int k, l, tmp;

  for(k = 0; k <= n-1; k++){
    for(l = n-1; l >= k+1; l--){
      if(A[l] < A[l-1]){
        tmp = A[l];
        A[l] = A[l-1];
        A[l-1] = tmp;
        count++;
      }
    }
  }
}

int main(){

  int i, j, n;
  int A[N+1];

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf("%d", &A[i]);
  }

  BubbleSort(A, n);

  for(j = 1; j <= n; j++){
    if(j > 1){printf(" ");
  }
    printf("%d", A[j-1]);
  }

  printf("\n");
  printf("%d\n", count);

  return 0;
}

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

int main (){
	char input1[100];
	char input2[100];
	char input3[100];
	scanf ("%[^ ] %[^ ] %[^\n]",input1,input2,input3);getchar();
	printf ("%c%c%c\n",input1[0],input2[0],input3[0]);
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--ModInt
//-------------------------------------------------
const ::std::uint_fast64_t MOD = 998244353;

class mint
{
private:
    using value_type = ::std::uint_fast64_t;
    value_type n;
public:
    mint():n(0){}
    mint(::std::int_fast64_t _n):n(_n<0 ? MOD-(-_n)%MOD : _n%MOD){}
    mint(const mint &m):n(m.n){}

    friend ::std::ostream& operator<<(::std::ostream &os, const mint &a){
		return os << a.n;
	}
    friend ::std::istream& operator>>(::std::istream &is, mint &a){
        value_type temp; is>>temp;
        a = mint(temp);
        return is;
    }

    mint& operator+=(const mint &m){n+=m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator-=(const mint &m){n+=MOD-m.n; n=(n<MOD)?n:n-MOD; return *this;}
    mint& operator*=(const mint &m){n=n*m.n%MOD; return *this;}
    mint& operator/=(const mint &m){return *this*=m.inv();}
    mint& operator++(){return *this+=1;}
    mint& operator--(){return *this-=1;}

    mint operator+(const mint &m) const {return mint(*this)+=m;}
    mint operator-(const mint &m) const {return mint(*this)-=m;}
    mint operator*(const mint &m) const {return mint(*this)*=m;}
    mint operator/(const mint &m) const {return mint(*this)/=m;}
    mint operator++(int){mint t(*this); *this+=1; return t;}
    mint operator--(int){mint t(*this); *this-=1; return t;}

    bool operator==(const mint &m) const {return n==m.n;}
    bool operator!=(const mint &m) const {return n!=m.n;}
    mint operator-() const {return mint(MOD-n);}

    mint pow(value_type b) const {
        mint ret(1), m(*this);
        while(b){
            if (b & 1) ret*=m;
            m*=m;
            b>>=1;
        }
        return ret;
    }

    mint inv() const {return pow(MOD-2);}
};

mint dp[3030][3030];

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,S; cin>>N>>S;
    vi a(N);
    rep(i,N) cin>>a[i];

    dp[0][0]=1;
    rep(i,N)rep(j,S+1){
        dp[i+1][j] += dp[i][j];
        if (j>=a[i]) dp[i+1][j] += dp[i][j-a[i]]/2;
    }
    // rep(i,N+1){
    //     rep(j,S+1){
    //         cout<<dp[i][j]<<" ";
    //     }cout<<endl;
    // }
    cout<<dp[N][S]*mint(2).pow(N)<<endl;
    return 0;
}


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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int N, M;
vector<int> A, B, isRoot;
vector<vector<int>> graph;
vector<int> ans, homon;
int root;

int main(){
  cin >> N >> M;
  A.resize(N+M-1), B.resize(N+M-1);
  graph.resize(N);
  isRoot.resize(N, 0);
  REP(i, N+M-1){
    cin >> A[i] >> B[i];
    A[i]--, B[i]--;
    graph[A[i]].push_back(B[i]);
    isRoot[B[i]]++;
  }
  REP(i, N){
    if(isRoot[i]==0){
      root = i;
      break;
    }
  }
  ans.resize(N, -1);
  ans[root] = 0;
  homon.resize(N, 0);
  
  queue<int> que;
  que.push(root);
  while(!que.empty()){
    int node = que.front();
    que.pop();
    REP(i, graph[node].size()){
      int nx = graph[node][i];
      homon[nx]++;
      if(homon[nx] == isRoot[nx]){
        que.push(nx);
        ans[nx] = node + 1;
      }
    }
  }

  REP(i, N){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 8192
#include <stdio.h>
#include <math.h>
int main(void){
    
    int n;
    int d;
    int x[999];
    int loop;
    int a;
    int b;
    int sansyo;
    int dbl;
    double dis;
    int disi;
    int ans = 0;
    
    scanf("%d%d", &n, &d);
    
    loop = n * d;
    
    for(int p=1; p<=loop; p++){
        
       scanf("%d", &x[p]);
        
    }
    
    for(int i=1; i<n; i++){
        
        for(int j=i+1; j<=n; j++){
            
            dis = 0;
            
            for(int k=1; k<=d; k++){
                
                sansyo = i - 1;
                sansyo *= d;
                sansyo += k;
                a = x[sansyo];
                
                sansyo = j - 1;
                sansyo *= d;
                sansyo += k;
                b = x[sansyo];
                
                dbl = a - b;
                
                dbl *= dbl;
                dis += dbl;
                
            }
            
            disi = sqrt(dis);
            dis = sqrt(dis);
            //printf("debug i=%d j=%d  %f - %d\n", i, j, dis, disi); //debug
            dis -= disi;
            
            
            if(dis==0){
                
                ans += 1;
                
            }
            
        }
        
    }
    
    printf("%d", ans);
    
    return 0;
    
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define maxn 100005
#define INF 99999999
int n, root, Ans, ans, C[maxn], mark[maxn];
int degree[maxn], dp1[maxn], dp2[maxn];
int val[maxn];

int read()
{
	int x = 0, k = 1;
	char c; c = getchar();
	while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); }
	while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return x * k;
}

struct edge
{
    int cnp, to[maxn * 2], last[maxn * 2], head[maxn];
    edge() { cnp = 1; }
    void add(int u, int v)
    {
        to[cnp] = v, last[cnp] = head[u], head[u] = cnp ++;
        to[cnp] = u, last[cnp] = head[v], head[v] = cnp ++;
    }
}E1;

void dfs(int u, int fa)
{
	mark[u] = C[u];
	for(int i = E1.head[u]; i; i = E1.last[i])
	{
		int v = E1.to[i];
		if(v == fa) continue;
		dfs(v, u);
		if(!mark[v]) ++ degree[u], ++ degree[v];
		mark[u] &= mark[v];
	}
}

void dfs2(int u, int fa)
{
	int mx1 = 0, mx2 = 0; bool flag = 0;
	Ans += degree[u];
	if((degree[u] + C[u]) & 1) val[u] = 0;
	else val[u] = 2, ++ Ans;
	for(int i = E1.head[u]; i; i = E1.last[i])
	{
		int v = E1.to[i];
		if(v == fa || mark[v]) continue;
		flag = 1; dfs2(v, u);
		ans = max(ans, max(dp1[v] + mx2 + val[u], dp2[v] + mx1 + val[u]));
		mx1 = max(dp1[v], mx1), mx2 = max(dp2[v], mx2);
	}
	dp1[u] = mx1 + val[u], dp2[u] = flag ? mx2 + val[u] : -INF;
}

int main()
{
	n = read();
	for(int i = 1; i < n; i ++)
	{
		int x = read(), y = read();
		E1.add(x, y);
	}
	for(int i = 1; i <= n; i ++)
	{
		char c; cin >> c;
		if(c == 'B') C[i] = 1;
		else root = i; 
	}
	if(!root) { puts("0"); return 0; }
	dfs(root, 0); dfs2(root, 0);
	printf("%d\n", Ans - ans);
	return 0;
}

Measured memory_bytes: 12416
using System;

namespace AtCoderABC133B
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;

            string[] s = Console.ReadLine().Split(' ');

            int N = int.Parse(s[0]);
            int D = int.Parse(s[1]);

            int[][] X = new int[N][];

            for (int i = 0; i < N; i++)
            {
                X[i] = new int[D];

                s = Console.ReadLine().Split(' ');

                for(int j=0;j<D;j++)
                {
                    X[i][j] = int.Parse(s[j]);
                }
            }

            for(int i=0;i<N;i++)
            {
                for(int j=i+1;j<N;j++)
                {
                    int sum = 0;
                    for(int n=0;n<D;n++)
                    {
                        sum += (X[i][n] - X[j][n]) * (X[i][n] - X[j][n]);
                    }

                    int sum2 = (int)Math.Sqrt(sum);

                    if (sum == sum2 * sum2)
                        ans++;
                }
            }

            Console.WriteLine(ans.ToString());
        }
    }

}


Measured memory_bytes: 13268
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 100001
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
char a[66],b[66];
int main()
{
    //std::ios::sync_with_stdio(false);
    scanf("%s", a), scanf("%s", b);
    int la = strlen(a), lb = strlen(b);
    int len = max(la, lb);
    for(int i=0;i<len;i++)
    {
        if(i<la) putchar(a[i]);
        if(i<lb) putchar(b[i]);
    }
    puts("");
    //system("pause");
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int a, b, sum, i;

	while(scanf("%d %d", &a, &b)!= EOF){
		sum = a + b;
		for(i=0; sum!=0; i++){
			sum /= 10;
		}
		printf("%d\n", i);
	}	
	return 0;
}		

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<int,int>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e18)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
#define YesNo(a) cout<<((a)?"Yes":"No")<<endl;
#define YESNO(a) cout<<((a)?"YES":"NO")<<endl;



int main(){
	
	string s;
	cin >> s;
	bool len,num,big,sml;
	len=num=big=sml=false;
	FOR(i,0,s.size()){
		if(i>=5)len=true;
		if(s[i]<='9'&&s[i]>='0')num=true;
		if(s[i]<='z'&&s[i]>='a')sml=true;
		if(s[i]<='Z'&&s[i]>='A')big=true;
	}
	if(len&&num&&big&&sml){
		cout << "VALID" << endl;
	}else{
		cout << "INVALID" << endl;
	}

}



Measured memory_bytes: 3196
#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
  long long A, B, K;
  std::cin >> A >> B >> K;
  for (int k = 0; k < K; ++k) {
    A /= 2;
    B += A;
    std::swap(A, B);
  }
  if (K % 2 == 1)
     std::swap(A, B);
  std::cout << A << ' ' << B << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

enum FACE { TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT };
class dice {
private:
	int num[6];

	void roll(FACE a, FACE b, FACE c, FACE d) {
		int tmp = num[a];
		num[a] = num[b];
		num[b] = num[c];
		num[c] = num[d];
		num[d] = tmp;
	}

public:
	dice() {
		memset(num, 0, sizeof(num));
	}

	bool check() {
		vector<bool> used(7, false);
		for(int i = 0; i < 6; ++i) {
			if(num[i] == 0 || used[num[i]])
				return false;
			used[num[i]] = true;
		}

		return num[TOP] + num[BOTTOM] == 7 && num[FRONT] + num[BACK] == 7 && num[LEFT] + num[RIGHT] == 7;
	}

	int& operator[](FACE f) { return num[f]; }
	void north() { roll(TOP, BACK, BOTTOM, FRONT); }
	void south() { roll(TOP, FRONT, BOTTOM, BACK); }
	void east() { roll(TOP, LEFT, BOTTOM, RIGHT); }
	void west() { roll(TOP, RIGHT, BOTTOM, LEFT); }
};

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

dice die;
int f[5][5];
bool visited[5][5];

void search(int x, int y) {
	die[TOP] = f[y][x];
	visited[y][x] = true;

	for(int i = 0; i < 4; ++i) {
		const int nx = x + dx[i], ny = y + dy[i];
		if(nx < 0 || ny < 0 || nx >= 5 || ny >= 5)
			continue;

		if(visited[ny][nx] || !f[ny][nx])
			continue;

		switch(i) {
		case 0: die.east(); break;
		case 1: die.west(); break;
		case 2: die.south(); break;
		case 3: die.north(); break;
		}

		search(nx, ny);

		switch(i) {
		case 0: die.west(); break;
		case 1: die.east(); break;
		case 2: die.north(); break;
		case 3: die.south(); break;
		}
	}
}


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

	int n;
	cin >> n;

	while(n--) {
		for(int i = 0; i < 5; ++i)
			for(int j = 0; j < 5; ++j)
				cin >> f[i][j];

		bool ok = false;
		int cnt = 0;
		for(int i = 0; i < 5; ++i)
			for(int j = 0; j < 5; ++j)
				if(f[i][j])
					++cnt;

		if(cnt != 6)
			goto finish;

		die = dice();
		memset(visited, false, sizeof(visited));
		for(int i = 0; i < 5; ++i) {
			for(int j = 0; j < 5; ++j) {
				if(f[i][j]) {
					search(j, i);
					goto loop_escape;
				}
			}
		}

	loop_escape:;

		ok = die.check();

	finish:;
		cout << (ok ? "true" : "false") << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1196
MOD = 10**9+7
list_size = 10**6

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(1,list_size):
	f_list[i] = f_list[i-1]*i % MOD

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(-2, -list_size-1, -1):
	f_r_list[i] = ((f_r_list[i+1] * (list_size + 1 + i)) % MOD)

def comb(n,r):
    if n < r:
        return 0
    if n==0 or r == 0 or n == r:
        return 1
    return (((f_list[n] * f_r_list[n - r]) % MOD) * f_r_list[r]) % MOD

def P(n,r):
    if n < r:
        return 0
    if r == 0 or n == 0:
        return 1
    return (f_list[n] * f_r_list[n - r]) % MOD

N,M = map(int,input().split())
ans = 0
for S in range(N+1):
    hoge = P(M,S)*(P(M-S,N-S)**2)*comb(N,S)    
    if S%2 == 1:
        hoge *= -1
    ans += hoge

print(ans%MOD)

Measured memory_bytes: 94952
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int ans;

int main() {
	vector<int> A{0,0,0};

	cin >> A[0] >> A[1] >> A[2];

	sort(A.begin(),A.end());

	//cout << A[0] << A[1] << A[2];


 	ans = A[2]-A[1];

 	A[0] += A[2]-A[1];
 	A[1] = A[2];

	if ((A[2]-A[0])%2==0) {
		ans += (A[2]-A[0])/2;
	} else {
		ans += (A[2]-A[0])/2+2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int a, b;
	int n;
	cin >> a >> b >> n;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			b += a / 2;
			a /= 2;
			}
		else{
			a += b / 2;
			b /= 2;
			
		}
	}
	cout << a <<' '<< b << endl;
}
	

Measured memory_bytes: 256
import sys

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, C, K] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
    T = []
    for i in range(N):
        input_raw = read_func().strip().split()
        T.append(int(input_raw[0]))
    T.sort()
    bus_count = 0
    first_time = T[0]
    people_count = 0
    for i in range(N):
        if T[i] <= first_time + K:
            people_count += 1
            if people_count >= C:
                bus_count += 1
                people_count = 0
                if i + 1 < N:
                    first_time = T[i + 1]
        else:
            bus_count += 1
            first_time = T[i]
            people_count = 1

##            if i < N - 1:
##                people_count = 1
##            else:
##                people_count = 0
    bus_count += people_count/C + (0 if people_count % C == 0 else 1)
    print bus_count



if __name__ == '__main__':
    main()

Measured memory_bytes: 8956
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    public static void Main( )
    {
        int N = int.Parse( Console.ReadLine( ) );
        int score = 400;
        int ans = 8;

        while ( true )
        {
            score += 200;
            if ( N < score )
            {
                Console.WriteLine( ans.ToString( ) );
                return;
            }
            ans--;
        }

    }


}

Measured memory_bytes: 27528
object Main {
  def main(args: Array[String]) {
    val sc = new java.util.Scanner(System.in)
    val n = sc.nextInt
    val z = sc.nextInt
    val w = sc.nextInt
    val an = List.fill(n)(sc.nextInt)

    val ans = if (an.length == 1) {
      Math.abs(an.head - w)
    } else {
      val a = Math.abs(an.last - w)
      val b = Math.abs(an.last - an(an.length - 2))
      if (a > b) a else b
    }

    println(ans)
  }
}


Measured memory_bytes: 31588
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<stack>
#include<queue>
#include<iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<deque>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

using namespace std;

#define DBG cerr << '!' << endl;
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)
#define MOD 1000000007

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int s;cin >> s;
	
	ll ans = 0;
	int cou = 1;
	int tc = 1,tnxt = 10,tp = 1;
	int uc = 1,unxt = 10,up = 1;
	
	if(cou == s)
	{
		ans++;
	}

		
	while(uc < 9999999)
	{
		while(cou < s)
		{
			tc++;
			if(tc == tnxt)
			{
				tnxt *= 10;
				tp++;
			}
			cou += tp;
			if(cou == s)
			{
				ans++;
			}
		}
		
		while(cou >= s && uc < 9999999)
		{
			cou -= up;
			uc++;
			if(uc == unxt)
			{
				unxt *= 10;
				up++;
			}
			if(cou == s)
			{
				ans++;
			}
		}
	}
	//cout << ans << endl;
	/*
	for(int i = 1;i <= s/8;i++)
	{
		if(s % i == 0)
		{
			int tmp = s / i;
			ll num1 = 1;
			ll num2 = 1;
			REP(j,tmp-1)num2 = (num2 * 10)%MOD;
			cout << tmp << ' ' << num2 << endl;
			num1 = num2*10%MOD;
			num1 = (num1 - num2 + MOD ) % MOD;
			num1 = (num1 - i + MOD ) % MOD;
			ans = (ans + num1)%MOD;
		}
		ans = (ans + 1) % MOD;
	}
	*/
	
	ll num2 = 1;
	up = 0;
	for(int i = s/8;i >= 1;i--)
	{
		if(s % i == 0)
		{
			int tmp = s / i;
			while(up < tmp-1)
			{
				num2 = (num2 * 10)%MOD;
				up++;
			}
	//		cout << tmp << ' ' << num2 << endl;
			ll num1 = num2*10%MOD;
			num1 = (num1 - num2 + MOD ) % MOD;
			num1 = (num1 - i + MOD ) % MOD;
			ans = (ans + num1)%MOD;
		}
		ans = (ans + 1) % MOD;
	}

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

Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def update(i, k):
    if k == 0:
        dp[i][k] = dp[i-1][0] * (1-P[i-1])
    elif k == i:
        dp[i][k] = dp[i-1][k-1] * P[i-1]
    else:
        dp[i][k] = dp[i-1][k-1] * P[i-1] + dp[i-1][k] * (1-P[i-1])


N = int(input())
P = list(map(float, input().split()))

dp = [[0 for _ in range(i+1)] for i in range(N+1)]
dp[0][0] = 1

for i in range(1, N+1):
    for k in range(i+1):
        update(i, k)

print(sum(dp[N][(N+1)//2:]))


Measured memory_bytes: 149896
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy,bisect
from operator import itemgetter

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time, copy
from operator import itemgetter

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces


N, H = na()
maxA = -1
bbb = []
for i in range(N):
    a, b = na()
    maxA = max(maxA, a)
    bbb.append(b)
bbb.sort(reverse=True)
ct = 0
now = 0
for i in range(N):
    if bbb[i] <= maxA:
        break
    now += bbb[i]
    ct += 1
    if now >= H:
        print(ct)
        sys.exit()

res = H - now
if res % maxA == 0:
    print(ct + res // maxA)
else:
    print(ct + res // maxA + 1)

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

int n;
int k;
int heights[100005];
ll memo[100005];

ll dp(int idx){
    ll &res = memo[idx];
    if(res != -1){
        return res;
    }
    if(idx == n - 1){
        return res = 0;
    }
    res = 1e10;
    for(int i = 1; i <= k && i + idx < n; i++ ){
        res = min(res, dp(idx + i) + abs(heights[idx] - heights[idx + i]));
    }
    return res;
}
int main(){
    memset(memo, -1, sizeof memo);
    scanf("%d%d", &n, &k);
    for(int i = 0; i < n; i++){
        scanf("%d", &heights[i]);
    }
    printf("%lld", dp(0));
}


Measured memory_bytes: 11188
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N = int(input())
aa = inpl()
aa.sort(reverse = True)
bef = 0
ss = []

for a in aa:
	if bef == a:
		ss.append(a)
		if len(ss) == 2:
			print(ss[0]*ss[1])
			sys.exit()
		bef = 0
	else:
		bef = a

print(0)

Measured memory_bytes: 15452
#include <bits/stdc++.h>
using namespace std;
const int N=1e6;
int n,m;

vector<vector<int>>v;
int vis[N],cnt[N],col[N];
int ch=0;
void dfs(int u ){
for(int i=0;i<v[u].size();i++){
	int x=v[u][i];
	if(col[x]==-1){
		col[x]=!col[u];
		cnt[col[x]]++;
		dfs(x);
	}
	else if(col[x]==col[u]){
		ch=1;
		return;
	}
	
}
	
}
int main() {
	scanf("%d%d",&n,&m);
	v.resize(n+1);
	for(int a,b, i=0;i<m;i++){
		scanf("%d%d",&a,&b);
		v[a].push_back(b);
		v[b].push_back(a);
}
	memset(col,-1,sizeof col);
		col[1]=1;
		cnt[1]++;
		dfs(1);
if(ch){
	long long ans=1LL*n*(n-1);
	ans/=2;
	ans-=m;
	cout<<ans;
}
	else{
	cout<<1LL * cnt[1] * cnt[0]-m<<endl;
	
	}
	return 0;
}

Measured memory_bytes: 10112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if(s[0]==s[1] && s[1]!=s[2] && s[2]==s[3])
        puts("Yes");
    else
        puts("No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

ll factmod(ll a,ll b,ll m) {
  if(a<b)return 0;
  ll s=1;
  while(a>=b){
    s = s*a % m;
    a -= 1;
  }
  return s;
}

int main(){

  ll n,k;
  cin >> n >> k;

  vector<vector<ll>> G(n);
  // ll nokori[n]={};//各ノードにたいして、まだ色を塗っていないノードがいくつつながっているか
  for(int i=0;i<n-1;i++){
    ll a,b;
    cin >> a >> b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
    // nokori[a-1]++;
    // nokori[b-1]++;
  }


  vector<bool> seen(n,false);//色を塗ったかどうか
  seen[0]=true;
  queue<ll> q;
  q.push(0);
  ll m=k;//0の塗り方はk通り

  while(!q.empty()){
    ll a=q.front();
    q.pop();
    ll b=0;
    for(int i=0;i<G[a].size();i++){
      if(seen[G[a][i]])continue;
      seen[G[a][i]]=true;
      q.push(G[a][i]);
      m=m*(k-(G[a].size()-b))%mod;
      b++;
    }
    if(G[a].size()+1>k){
      m*=0;
      break;
    }
  }

  cout << m << endl;



}

Measured memory_bytes: 10340
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

int gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll beki(ll a, ll b) {
	ll tmp = 1;
	REP(i, b) tmp *= a;
	return tmp;
}

int N;
int H[100010];
int ans = 0;

int main() {
	cin >> N;
	REP(i, N) cin >> H[i];
	
	int tmp = 0;
	REP(i, N - 1) {
		//右が左の高さ以下である
		if (H[i + 1] <= H[i]) {
			tmp++;
			ans = max(tmp, ans);
		}
		else {
			tmp = 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#pragma _attribute_((optimize("-O2")))
#pragma comment(linker, "/STACK:102400000,102400000")

#include <iostream>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <cstdio>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <string>
#include <sstream>
#include <time.h>
#include <complex>
#include <iomanip>
#define Endl endl

//#define Local

using namespace std;

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

	//freopen("input1.txt","r",stdin);
	//freopen("output1.txt","w",stdout);

	int n;
	cin>>n;
	vector<int> all;
	all.push_back(0);
	for(int i=0;i<n;i++)
	{
		int tmp;
		cin>>tmp;
		all.push_back(tmp);
	}
	all.push_back(0);
	long long ans=0;
	for(int i=1;i<=n+1;i++)
		ans+=abs(all[i]-all[i-1]);
	for(int i=1;i<=n;i++)
		cout<<ans+abs(all[i+1]-all[i-1])-abs(all[i]-all[i-1])-abs(all[i+1]-all[i])<<endl;


#ifdef Local
	cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
#endif
	return 0;
}


Measured memory_bytes: 1784
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author shadowreaper810
 */

#include <iostream>
#include <fstream>

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

#define int long long
#define pb push_back
#define mp make_pair

const int MOD = 1000000007;

class AFrog1 {
public:
    void solve(std::istream& in, std::ostream& out) {
        int n;
        in>>n;
        int arr[n+1];
        for(int i=1;i<=n;i++)
            in>>arr[i];
        int dp[n+5];
        dp[0]=0;
        arr[0]=0;
        dp[1]=0;
        dp[2]=abs(arr[2]-arr[1]);
        for(int i=3;i<=n;i++)
        {
            dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i-2]-arr[i]));
        }

        out<<dp[n];
    }
};

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    AFrog1 solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}

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

int main(void)
{
    int N, max=0, temp;
    scanf("%d", &N);
    int p[N];
    for(int i;i<N;i++){
        scanf("%d", &p[i]);
        if(p[i] > max) max = p[i];
    }
    
    for(int i=0;i<N;i++){
        temp += p[i];
        
    }
    printf("%d",temp-max/2);
}

Measured memory_bytes: 384
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    input_raw = read_func().strip().split()
    A = [int(input_raw[i]) for i in range(N)]

    pre_stat = 999
    count = 1
    for i in range(N - 1):
        if A[i] < A[i + 1]:
            stat = 1
        elif A[i] > A[i + 1]:
            stat = -1
        else:
            stat = 0
        if pre_stat != 999 and stat != 0:
            if stat != pre_stat:
                count += 1
                pre_stat = 999
        elif stat != 0:
            pre_stat = stat
    print count

if __name__ == '__main__':
    main()

Measured memory_bytes: 15012
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*};
use superslice::*;
fn main() {
    input! {
        r: i64,
    }
    let r = r as f64;
    println!("{}", r * 2. * std::f64::consts::PI);
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    set<string> S;
    rep(i, N) {
        string s;
        cin >> s;
        S.insert(s);
    }
    cout << (S.size() == 4 ? "Four" : "Three") << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <cstring>
#define N 100000
using namespace std;

int main() {
  int k;
  cin >> k ;
  int cnt1=0;
  int cnt2=0;
  for(int i=1;i<=k;i++)
  {
    if(i%2==0)
    cnt1++;
    if(i%2!=0)
    cnt2++;
  }
  cout << cnt1*cnt2 << endl;



  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
long long int MAX(long long int a,long long int b)
{
    if(a>=b)
    return a;
    else
    return b;
}
int main()
{
    long long int n;
    scanf("%lld",&n);
    long long int a[n];
    for(int i=0;i<n;i++)
    scanf("%lld",&a[i]);
sort(a,a+n);
long long int l=a[n-1]; //left
long long int r=l;             // right
long long int i=0,j=n-2;
long long int sum=0;
while(i<j){
        int li=abs(l-a[i]),ri=abs(r-a[i]);
        int lj=abs(l-a[j]),rj=abs(r-a[j]);
        if(li>ri||lj>rj){ //left side
                if(li>lj){
                        sum+=li;
                        l=a[i++];
                }else{
                        sum+=lj;
                        l=a[j--];
                }
        }else{
                if(ri>rj){
                        sum+=ri;
                        r=a[i++];
                }else{
                        sum+=rj;
                        r=a[j--];
                }
        }
}
sum+=MAX(abs(l-a[i]),abs(r-a[i]));
cout<<sum<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int n,m;
  string s;
  cin >> n >> m >> s;
  int cnt = 0;
  rep(i,n+1){
    if(s.at(i) == '1') cnt++;
    else cnt = 0;
    if(cnt == m){
      cout << -1 << endl;
      return 0;
    }
  }
  vector<int> step(n+1,1e9);
  step.at(n) = 0;
  int pos = n;
  int d = 1;
  while(pos > 0){
    int tmp = pos;
    rep(i,m){
      tmp--;
      if(s.at(tmp) == '1') continue;
      step.at(tmp) = d;
      pos = tmp;
      if(tmp == 0){
        pos = 0;
        break;
      }
    }
    d++;
  }
  //vector<int> path(1,0);
  int p = step.at(0);
  int id = 0;
  for(int i=1;i<=n;i++){
    if(s.at(i) == '1') continue;
    if(step.at(i) == p) continue;
    cout << i - id << " ";
    p = step.at(i);
    id = i;
  }
  cout << endl;
  //rep(i,n+1) cout << step.at(i) << endl;
}

Measured memory_bytes: 1024
//#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ll long long
#define ld long double
#define pi pair<int,int>
#define pd pair<ld,ld>
#define ft first
#define sd second
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define FOR(i,a,b) for(int i=(a); i<=(b);i++)
#define F(i,a,b) FOR(i,(a),(b)-1)
#define REV(i,a,b) for(int i=(a); i>=(b);i--)
#define VI vector<int>
#define VPI vector<pi>
#define VPD vector<pd>
#define PI 3.14159265
#define all(x) (x).begin(), (x).end()
#define sz(a) (int)((a).size())
#define int long long

template<class TH> void _dbg(const char *sdbg, TH h){cerr<<sdbg<<"="<<h<<"\n";}
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
	while(*sdbg!=',')cerr<<*sdbg++;cerr<<"="<<h<<","; _dbg(sdbg+1, a...);
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
mt19937 r(chrono::steady_clock::now().time_since_epoch().count());
int rand_range(int a, int b)
{
	assert(a<=b);
	return a+r()%(b-a+1);
}
const long long K = 1000;
const long long KK = K*K;
const long long MIL = KK*K;
const long long INF = MIL*MIL;
const long long MOD = MIL+7;
const long long N = 2e6 + 10, M=10;

void solve(){
    int n;
    cin>>n;
    vector<string> v(n);
    F(i,0,n)
        cin>>v[i];
    F(i,0,n)
        sort(all(v[i]));
    sort(all(v));
    int pom = 1, res = 0;
    F(i,1,n) {
        if(v[i] == v[i-1]){
            pom++;
            continue;
        } else {
            res += (pom * (pom - 1)) / 2;
            pom = 1;
        }
    }
    res += (pom * (pom-1))/2;
    cout<<res<<"\n";
}

int32_t main()
{
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	//ios_base::sync_with_stdio(0);
	//cin.tie(0);
	//cout.tie(0);
	cerr.tie(0);
	cout<<setprecision(9)<<fixed;
	cerr<<setprecision(6)<<fixed;
	int test = 1, f;
    //cin>>test;
	F(_test, 0, test){
        //cout<<"Case #"<<_test + 1<<": ";
		solve();
//		if(_test == 1)
//            return 0;
	}
}
/*
1
WSSWW
*/


Measured memory_bytes: 7296
#include<stdio.h>
char s[50][51];
int w,h,x[]={0,1,0,-1,0};
int F(int i,int j,char c)
{
	if(i<0||j<0||i>=h||j>=w)return 0;
	if(s[i][j]==(c=='W'?'B':'W'))return -99999;
	if(s[i][j]!='.')return 0;
	s[i][j]='!';
	return 1+F(i+1,j,c)+F(i-1,j,c)+F(i,j+1,c)+F(i,j-1,c);
}
int main()
{
	int i,j,k,p,q,r;
	while(scanf("%d%d",&w,&h),w)
	{
		for(i=0;i<h;++i)scanf("%s",s[i]);
		for(p=q=i=0;i<h;++i)for(j=0;j<w;++j)
		{
			if(s[i][j]=='B')
				for(k=0;k<4;++k)
				{
					r=F(i+x[k],j+x[k+1],'B');
					if(r>0)p+=r;
				}
			if(s[i][j]=='W')
				for(k=0;k<4;++k)
				{
					r=F(i+x[k],j+x[k+1],'W');
					if(r>0)q+=r;
				}
		}
		printf("%d %d\n",p,q);
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    static final String[] WORDS = { "dream", "dreamer", "erase", "eraser" };

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

        String S = sc.next();

        System.out.println(solve(S) ? "YES" : "NO");

        sc.close();
    }

    static boolean solve(String S) {
        int length = S.length();
        while (length != 0) {
            boolean matched = false;
            for (String word : WORDS) {
                if (isSuffix(S, length, word)) {
                    length -= word.length();
                    matched = true;
                }
            }

            if (!matched) {
                return false;
            }
        }

        return true;
    }

    static boolean isSuffix(String S, int length, String word) {
        return length >= word.length() && IntStream.range(0, word.length())
                .allMatch(i -> S.charAt(length - word.length() + i) == word.charAt(i));
    }
}

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

int main() {
	cin.sync_with_stdio(false); cin.tie(nullptr);
	int k, n; cin >> k >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	vector<int> diff(n);
	for (int i = 0; i < n; ++i)
		diff[i] = (a[(i + 1) % n] - a[i] + k) % k;
	sort(diff.begin(), diff.end());
	cout << k - diff.back() << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    string a,b;
    cin>>a>>b;
    a+=b;
    int n = stoi(a);
    rep(i,1000){
        if(i*i==n){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
INF = 10**18

dp0 = 0
dp1 = -INF
dp2 = -INF

for i, a in enumerate(A):
    if i % 2 == 0:
        dp1 = max(dp1, dp0)
        dp0 += a
        dp2 += a
    else:
        dp2 = max(dp2, dp1)
        dp1 += a

if N % 2 == 1:
    print(max(dp1, dp2))
else:
    print(max(dp0, dp1))


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

class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(
            Solve(Console.ReadLine(), Console.ReadLine()
            ));
    }

    static string Solve(params string[] args)
    {
        var nums = args[1].Split(' ').Select(s => int.Parse(s)).OrderByDescending(n => n).ToList();
        var queue = new Queue<int>();
        nums.ForEach(n => queue.Enqueue(n));

        var sumA = 0;
        var sumB = 0;
        while (queue.Any())
        {
            if (queue.Any()) sumA += queue.Dequeue();
            if (queue.Any()) sumB += queue.Dequeue();
        }

        return (sumA - sumB).ToString();
    }
}

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

#define f first 
#define s second 
#define pb push_back               
#define mp make_pair 

using namespace std;                    

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int N = (int)1e5 + 123, mod = (int)1e9 + 7, inf = (int)1e9;

vector< int> g[N];
int n, k, a[N], ans;
int dfs(int v){
	int mx = 0;
	for(auto to : g[v]){
		int x = dfs(to) + 1;
		if(x == k && v != 1)
			ans++;	
		else
			mx = max(mx, x);

	}
	return mx;
}
int main(){    
	cin >> n >> k;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	if(a[1] != 1 )
		a[1] = 1, ans ++;
	for(int i = 2; i <= n; i++)
		g[a[i]].pb(i);
	dfs(1);
	cout << ans;
	return 0;
}


Measured memory_bytes: 10752
#include<stdio.h>

int main()
{
  int n, h, i, j, k, l, m, Q[100], Z[100];
  int G[100][100];
  scanf("%d", &n);
  
  for(i = 0; i < 101; i++ ) {
    Z[i] = -1;
    Q[i] = 0;
  }
  
  for( i = 0; i < n; i++){
    scanf("%d", &G[i][0]);
    scanf("%d", &G[i][1]);
    for( j = 2; j < 2 + G[i][1]; j++){
      scanf("%d", &G[i][j]);
    }
  }
  
  m = 0; 
  h = 0; 
  Q[h] = 1;
  Z[1] = 0;
  for( i = 0; i < n; i++){
    k = Q[m];
    l = G[k - 1][1];
    
    for( j = 0; j < l; j++){
      if( Z[ G[k - 1][2 + j] ] == -1 ){
        h++;
        Q[h] = G[k - 1][2 + j];
        Z[ G[k - 1][2 + j] ] = Z[ Q[m] ] + 1;
      }
    }
    m++;
    if( Q[m] == 0 ) i = i + n;
  }
  
  for(i = 1; i <= n ; i++){
    printf("%d %d\n", i, Z[i] );
  }
  
  return 0;
}

Measured memory_bytes: 632
// マージソート (p.152 ~ p.157)

#include<iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000

int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right) {
  int n1 = mid - left;
  int n2 = right - mid;
  for ( int i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( int i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1] = R[n2] = SENTINEL;
  int i = 0, j = 0;
  for ( int k = left; k < right; k++ ) {
    cnt++;
    if ( L[i] <= R[j] ) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

void mergeSort(int A[], int n, int left, int right) {
  if ( left+1 < right ) {
    int mid = (left + right) / 2;
    mergeSort(A, n, left, mid);
    mergeSort(A, n, mid, right);
    merge(A, n, left, mid, right);
  }
}

int main() {
  int A[MAX], n, i;
  cnt = 0;

  cin >> n;
  for ( i = 0; i < n; i++ ) cin >> A[i];

  mergeSort(A, n, 0, n);

  for ( i = 0; i < n; i++ ) {
    if ( i ) cout << " ";
    cout << A[i];
  }
  cout << endl;

  cout << cnt << endl;

  return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265359

int main(void)
{
	int ans;
	string s;

	while (true)
	{
		cin >> s;
		if (s == "0")
			break;

		ans = 0;
		rep(i, s.length())
		{
			ans += s[i] - '0';
		}
		cout << ans << endl;
	}
}



Measured memory_bytes: 3144
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
int M = 1000000007;
bool prime[1001];
int p_fac[1001];

void shieve(){
  for(int i=0;i<=1000;i++) prime[i] = true;

  prime[0] = false;
  prime[1] = false;
  for(int i=2;i<=1000;i++){
    for(int j=2*i;j<=1000;j+=i){
      prime[j] = false;
    }
  }
}
void factoring(int n){
  int k=1;
  while(k<=n){
    if(prime[k] && n%k==0){
      p_fac[k]++;
      n /= k;
    }else{
      k++;
    }
  }
}
int main(){
  shieve();
  int N;
  cin >> N;

  for(int i=0;i<=1000;i++) p_fac[i] = 0;

  for(int i=1;i<=N;i++){
    factoring(i);
  }

  ll ans = 1;
  for(int i=1;i<=N;i++){
    ans = (ans*(p_fac[i]+1))%M;
  }
  cout << ans <<endl;

  return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lsb(x) (x & (-x))
#define ll long long
#define ull unsigned long long
#define uint unsigned int


#if 0
const int MOD = (int) ;

inline int lgput(int a, int b) {
    int ans = 1;
    while(b > 0) {
        if(b & 1) ans = (1LL * ans * a) % MOD;
        b >>= 1;
        a = (1LL * a * a) % MOD;
    }
    return ans;
}

inline void mod(int &x) {
    if(x >= MOD)
        x -= MOD;
}

inline void add(int &x, int y) {
    x += y;
    mod(x);
}

inline void sub(int &x, int y) {
    x += MOD - y;
    mod(x);
}

inline void mul(int &x, int y) {
    x = (1LL * x * y) % MOD;
}

inline int inv(int x) {
    return lgput(x, MOD - 2);
}
#endif


#if 0
int fact[], invfact[];

inline void prec(int n) {
    fact[0] = 1;
    for(int i = 1; i <= n; i++) {
        fact[i] = (1LL * fact[i - 1] * i) % MOD;
    }
    invfact[n] = lgput(fact[n], MOD - 2);
    for(int i = n - 1; i >= 0; i--) {
        invfact[i] = (1LL * invfact[i + 1] * (i + 1)) % MOD;
    }
}

inline int comb(int n, int k) {
    if(n < k) return 0;
    return (1LL * fact[n] * (1LL * invfact[k] * invfact[n - k] % MOD)) % MOD;
}
#endif

using namespace std;




int main() {
#ifdef HOME
    ifstream cin("A.in");
    ofstream cout("A.out");
#endif
    ll n, a, b;
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    cin >> n >> a >> b;

    if(a % 2 == b % 2) {
        cout << llabs(b - a) / 2;
    }
    else {
        auto get = [&](ll a, ll b) -> ll {
            return a + (b - a - 1) / 2;
        };
        cout << min(get(a, b), get(n - b + 1, n - a + 1));
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
int main(){
	long long n;cin>>n;
	long long ans=0;
	for(long long i=n;i>0;i--){
		if(i*i<=n){
			ans=i*i;
			break;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256