akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
#define rev(x) reverse((x) + 1, (x) + n + 1)

using namespace std;

typedef long long ll;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("F.in", "r", stdin);
	freopen ("F.out", "w", stdout);
#endif
}

const int N = 5e3 + 5, M = 205;

int n, m, a[N], b[M][N], L[N], R[N]; ll sum[N][N], pre[N];

void Init(int *a, int *b) {
	static int stk[N], top;
	stk[top = 0] = 0;
	For (i, 1, n) {
		while (top && a[i] > a[stk[top]]) -- top; 
		b[i] = stk[top] + 1; stk[++ top] = i;
	}
}

int main () {

	File();

	n = read(); m = read();

	For (i, 1, n - 1) a[i] = read();
	For (i, 1, n) For (j, 1, m) b[j][i] = read();

	For (i, 1, m) {
		Init(b[i], L); rev(b[i]);
		Init(b[i], R); rev(b[i]); rev(R);
		For (j, 1, n) R[j] = n - R[j] + 1;
		For (j, 1, n) {
			int l = L[j], r = R[j], v = b[i][j];
			sum[l][j] += v; sum[l][r + 1] -= v; sum[j + 1][j] -= v; sum[j + 1][r + 1] += v;
		}
	}

	For (i, 1, n) pre[i] = pre[i - 1] + a[i - 1];

	ll ans = 0;
	For (i, 1, n) For (j, 1, n) {
		sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
		if (i <= j) chkmax(ans, sum[i][j] - (pre[j] - pre[i]));
	}
	printf ("%lld\n", ans);

	return 0;

}

Measured memory_bytes: 199936
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  cout << A[N-1] - A[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
#define all(obj) obj.begin(), obj.end()
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);

const long long INF = 1LL << 60;

using namespace std;

typedef unsigned long long ull;
typedef int long long ll;
constexpr ll bigNum = 1000000007;

// 比較+dpテーブル更新　最大問題
// 更新する方の参照をaに渡すこと.
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
// 比較+dpテーブル更新 最小問題// 更新する方の参照をaに渡すこと.　
// 最小問題なので, 更新される側にある数字が比較されてる数字よりも大きければ更新する.こうすることで, 常に小さいものが選ばれていく.
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
// DPテーブル
long long dp[100010][3];

signed main()
{
    fast;
    int n = 0;
    cin >> n;

    // 入力
    long long happiness[n][3];
    REP(i, n)
    {
        REP(j, 3)
        {
            cin >> happiness[i][j];
        }
    }

    // dpテーブルの初期化
    // 今回は最大化の問題なので, 初期値は0
    REP(i, n)
    {
        REP(j, 3)
        {
            REP(k, 3)
            {
                if (j == k)
                {
                    continue;
                }
                // dpテーブルのi+1日目でどれをとったかでdpテーブルのi日目から派生を伸ばす
                chmax(dp[i + 1][k], dp[i][j] + happiness[i][k]);
            }
        }
    }
    long long ans = 0;
    // 最後に三列のなかでどれが最も大きいかを求める.
    for (int j = 0; j < 3; j++)
    {
        chmax(ans, dp[n][j]);
    }
    cout << ans << endl;
}

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

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n,k;
  cin>>n>>k;
  vector<int>x(n,0),dp(n+1,1000000009);
  int i=0;
  for(;i<n;i++)
    cin>>x[i];
  dp[0]=0;  
  for(i=0;i<n;i++)
  {
    for(int j=1;j<=k;j++)
    {
      if(i+j<n)
        dp[i+j]=min(dp[i+j],dp[i]+abs(x[i]-x[i+j]));
    }
  }
  cout<<dp[n-1]<<"\n";
   /*int n;
    cin>>n;
    int k;
    cin>>k;
    vector<int> h(n);
    for(int& x : h) {
			cin>>x;
    	}
    vector<int> dp(n, 1000000009);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j = i + 1; j <= i + k; ++j) 
            if(j < n) 
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j])); 
    }
	cout<<dp[n-1];*/
  return 0;
}


Measured memory_bytes: 1024
input = list(map(int, input().split()))
N = input[0]
L = input[1]
# 2 <= N <= 200
# -100 <= L <= 100
# flavor = L + i - 1
minimum = -1000
i = 0
flavor = 0
sum = 0

X = 1 - L
if X >= 2 and X <= N:
    for x in range(1,N+1):
        if x != 1 - L:
            flavor = L + x - 1
            sum += flavor
elif X > N:
    for x in range(1,N+1):
        if x != N:
            flavor = L + x - 1
            sum += flavor
else:
    for x in range(1,N+1):
        if x != 1:
            flavor = L + x - 1
            sum += flavor
print(sum)


Measured memory_bytes: 3064
#include <stdio.h>

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

int n;
int M[MAX][MAX] = {0};
int color[MAX] = {0}, d[MAX] = {0}, f[MAX] = {0}, tt;

void dfs_visit(int u) {
	int v;
	color[u] = GRAY;
	d[u] = ++tt;
//	printf("u = %d d[u] = %d\n", u + 1, d[u]);
	for (v = 0; v < n; v++) {
		if (M[u][v] == 0) continue;
//		printf("u = %d, v = %d\n", u + 1, v + 1);
		if ( color[v] == WHITE) {
			dfs_visit(v);
		}
	}
	color[u] = BLACK;
	f[u] = ++tt;
}


void dfs() {
	int u;

	tt = 0;

	for (u = 0; u < n; u++) {
		if (color[u] == WHITE) dfs_visit(u);
	}

	for (u = 0; u < n; u++) {
		printf("%d %d %d\n", u + 1, d[u], f[u]);
	}
}

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

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

	dfs();
	
	return 0;
}

Measured memory_bytes: 636
n, k = map(int,input().split())


MOD=10**9+7
def comb(n,k):
    if n<k:
        return 0
    if n<0 or k<0:
        return 0
    k=min(n-k,k)
    ans=1
    inv=[1]*(k+1)
    if k>=1:
        ans*=(n-k+1)%MOD
    for i in range(2,k+1):
        inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
        ans=ans*(n-k+i)*inv[i]%MOD
    return ans


for i in range(1, k+1):
    ans_i = comb(n-k+1, i) * comb(k-1, i-1)
    print(ans_i % MOD)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	int n2 = 1 << n;
	vector<int> a(n2);
	rep(i, n2) cin >> a[i];
	sort(a.begin(), a.end());
	vector<int> s;
	s.push_back(a.back());
	a.back() = -1;
	rep(i, n) {
		vector<int> p = s;
		sort(p.begin(), p.end());
		int ai = n2 - 1;
		while (p.size() > 0 && ai >= 0) {
			if (a[ai] == -1) {
				--ai;
				continue;
			}
			if (a[ai] < p.back()) {
				s.push_back(a[ai]);
				p.pop_back();
				a[ai] = -1;
			}
			--ai;
		}
		if (p.size() > 0) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 2932
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

ll ch[1002][1002];
queue<pair<ll,ll>>a;
int main() {
	ll h,w;
	cin>>h>>w;
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			char now;
			cin>>now;
			if(now=='.'){
				ch[i][j]=-1;
			}
			else{
				ch[i][j]=0;
				a.push(make_pair(i,j));
			}
		}
	}
	ll dx[4]={0,0,1,-1};
	ll dy[4]={1,-1,0,0};
	ll ans=0;
	while(!a.empty()){
		pair<ll,ll>now=a.front();
		a.pop();
		ll nowy=now.first;
		ll nowx=now.second;
		ll nowc=ch[nowy][nowx];
		for(ll i=0;i<4;i++){
			ll nex=nowx+dx[i];
			ll ney=nowy+dy[i];
			if(nex<0||nex>=w||ney<0||ney>=h){
				continue;
			}
			if(ch[ney][nex]!=-1){
				continue;
			}
			ch[ney][nex]=nowc+1;
			a.push(make_pair(ney,nex));
			ans=max(ans,ch[ney][nex]);
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 24372
import sys

K = int(sys.stdin.readline())
A = list(map(int, sys.stdin.readline().split()))

if A[-1] != 2:
    print(-1)
    sys.exit()

l = 2
r = 2
for i in range(K-2, -1, -1):
    l = ((l - 1) // A[i] + 1) * A[i]
    r = ((r + A[i+1] - 1) // A[i]) * A[i] 

    if l > r:
        print(-1)
        sys.exit()

# print(l, r)
print(l, r + A[0] - 1)

Measured memory_bytes: 20608
import java.util.ArrayList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Scanner;

class Edge {
    int to;
    int cost;

    Edge(int to, int cost) {
        this.to = to;
        this.cost = cost;
    }
}

class Pair implements Comparable<Pair> {
    int dist;
    int index;

    Pair(int dist, int index) {
        this.dist = dist;
        this.index = index;
    }

    public int compareTo(Pair p2) {
        return dist - p2.dist;
    }
}
 
public class Main {
    static final int INF = 2000000000;

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

        int res = 0;
        int[] coin = {1, 5, 10, 25};
        for(int i = coin.length - 1; i >= 0; i--) {
            res += n / coin[i];
            n %= coin[i];
        }

        System.out.println(res);
 
        sc.close();
    }
}


Measured memory_bytes: 26372
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
Int f(Int N, Int a, Int b, Int c, Int A, Int B, Int C)
{
    struct T { double r; Int cost, score; };
    vector<T> V;
    V.emplace_back(T{ (double)A/a, a, A });
    V.emplace_back(T{ (double)B/b, b, B });
    V.emplace_back(T{ (double)C/c, c, C });
    sort(rbegin(V), rend(V), [](auto& a, auto& b){ return a.r < b.r; });
    Int ans = 0;
    for (int i = (V[0].r <= 1 ? 0 : N/V[0].cost); i >= 0; i--) {
        if (i*V[0].score + (N-i*V[0].cost) * max(1.0, V[1].r) < ans) continue;
        for (int j = (V[1].r <= 1 ? 0 : (N-i*V[0].cost)/V[1].cost); j >= 0; j--) {
            int k = (V[2].r <= 1 ? 0 : (N - i*V[0].cost - j*V[1].cost) / V[2].cost);
            int rest = N - i*V[0].cost - j*V[1].cost - k*V[2].cost;
            ans = max(ans, i*V[0].score + j*V[1].score + k*V[2].score + rest);
        }
    }
    return ans;
}
int main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N; cin >> N;
    int gA, sA, bA, gB, sB, bB; cin >> gA >> sA >> bA >> gB >> sB >> bB;
    Int a = f(N, gA, sA, bA, gB, sB, bB);
    Int b = f(a, gB, sB, bB, gA, sA, bA);
    cout << b << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, f, n) for (ll i = (f); i < (ll)(n); i++)
#define repe(i, f, n) for (ll i = (f); i <= (ll)(n); i++)
using namespace std;
using ll = long long;
using GraphI = vector<vector<int>>;
using GraphC = vector<vector<char>>;
using pint = pair<int, int>;

int main() {
  int N;
  cin >> N;
  vector<int> H(N);
  rep(i, 0, N) cin >> H[i];

  int ans = 1;
  rep(i, 1, N) {
    bool ok = true;
    rep(j, 0, i) {
      if (H[i] < H[j]) {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3628
/*
        ***Fresher***
    Md Mahfujur Rahman Khan
    Dept. of CSE
    CSE-28 Batch
    JU-48 Batch
    Jahangirnagar University

*/
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<numeric>
#include<utility>
using namespace std;
#define V_ vector
#define Q_ queue
#define S_ set
#define ST_ stack
#define M_ map
#define DQ_ deque

#define pii pair<ll,ll>
#define pci pair<char,ll>
#define psi pair<string, ll>
#define pis pair<ll,string>
#define pic pair<ll, char>

#define mii map<ll,ll>
#define msi map<string, ll>
#define mis map<ll, string>
#define mib map<ll,bool>
#define msb map<string,bool>

#define vi vector<ll>
#define vs vector<string>

#define ivi vector<ll> :: iterator
#define ivs vector<string> :: iterator
#define imii map<ll,ll> :: iterator
#define imsi map<string,ll> :: iterator
#define imis map<ll, string> :: iterator
#define imib map<ll, bool> :: iterator
#define imsb map<string, bool> :: iterator

#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define F first
#define S second
#define pi 2*acos(0.0)
#define PB(x) push_back(x)
#define PP(x) push(x)
#define RSZ(n) resize(n)
#define POB pop_back()
#define P_ pop()
#define CL_ clear()
#define LEN_ length()
#define SZ_ size()
#define CNT_ count()
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define B_ begin()
#define E_ end()
#define F_ front()
#define t_ top()
#define IN_ insert
#define ER_  erase
#define GT getline
#define NL_   "\n"
#define SP_ " "

#define fr(i, n) for(i = 0; i < n; i++)
#define fe(x, n) for(i = x; i <= n; i++)

#define ul unsigned long long int
#define ll long long int
#define  MAX 250000

bool check(char a, char b)
{
    if(a=='0' && b!='0')
        return true;
    if(a=='1'&& (b=='0'||b=='1'||b=='2'))
        return true;
    return false;
}



int main()
{

   ll n;
   ll t = 0;
   cin >> n;
   while(n)
   {
       n=n/2;
       t++;
   }
cout <<fixed<< setprecision(0)<<(pow(2,t)-1);

return 0;

}


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

map<string, int> s;

string result[200005];

int main(void)
{
	//freopen("abc.in", "r", stdin);
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	string t;
	cin >> n;
	while (n--)
	{
		cin >> t;
		++s[t];
	}
	int cnt = 0;
	for (auto i = s.begin(); i != s.end(); ++i)
	{
		if (n < i->second)
		{
			n = i->second;
			cnt = 0;
			result[cnt++] = i->first;
		}
		else if (n == i->second)
			result[cnt++] = i->first;
	}
	sort(result, result + cnt);
	for (int i = 0; i < cnt - 1; ++i)
		cout << result[i] << endl;
	cout << result[cnt - 1];
}

Measured memory_bytes: 25472
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = long long;
using u32 = unsigned long long;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vstr = vector<string>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  map<i64, i64> m;
  m[0] = 1;
  i32 n;
  cin >> n;
  vi32 a(n + 1);
  rep(i, n) cin >> a[i + 1];
  rep(i, n) a[i + 1] += a[i];
  sort(all(a));
  i64 ans = 0;
  i64 now = a[0], cnt = 1;
  rep(i, n) {
    if (now == a[i + 1]) {
      cnt++;
    } else {
      now = a[i + 1];
      ans += cnt * (cnt - 1) / 2;
      cnt = 1;
    }
  }
  ans += cnt * (cnt - 1) / 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, 0, n) {
        cin >> a[i];
    }
    rep(i, k, n){
        if(a[i-k] < a[i]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4840
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

int N,ans[200005];
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	cin>>N;
	rep(i,N-1){
		int a;cin>>a;
		ans[a]++;
	}
	REP(i,N+1){
		cout<<ans[i]<<"\n";
	}
}


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

using namespace std;

inline long long read(){
   long long w=1,s=0;
   char ch=getchar();
   while(ch<'0'||ch>'9') {if (ch=='-') w=-1;ch=getchar();} 
   while(ch>='0'&&ch<='9')  s=s*10+ch-'0',ch=getchar();
   return s*w;
}

map<string,int>q;

int main(){
    int n=read();
    string s,la;
    cin>>s;
    la=s;
    q[s]=1;
    for(int i=2;i<=n;i++){
        cin>>s;
        if (s[0]!=la[la.size()-1]||q[s]) {cout<<"No";return 0;}
        q[s]=1;
        la=s;
    }
    cout<<"Yes";
    return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define length size()
#define int long long
template<typename T> string join(vector<T> &vec ,const string &sp){
    int si = vec.length;
    if(si==0){
        return "";
    }else{
        stringstream ss;
        rep(i,si-1){
            ss << vec[i] << sp;
        }
        ss << vec[si - 1];
        return ss.str();
    }
}
signed main(void){
    int n;
    cin >> n;
    vector<int> vec(n);
    rep(i,n){
        cin >> vec[i];
    }
    int sum = 0;
    int max = vec[0];
    for(int i=1;i<n;i++){
        if(vec[i]<max){
            sum += max-vec[i];
        }else if(max<vec[i]){
            max = vec[i];
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 4836
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

int main() {
    string s;
    cin >> s;
    auto dp = make_vec_nd((ll)0, s.size()+1, 2);
    dp[s.size()-1][0] = 1;
    dp[s.size()-1][1] = 0;
    for (ll i = s.size() - 2; i >= 0; i--) {
        dp[i][0] = dp[i+1][1] + 1;
        if (s[i] != s[i+1]) {
            dp[i][0] = max(dp[i][0], dp[i+1][0] + 1);
        }
        if (i <= (ll)s.size() - 2) {
            dp[i][1] = dp[i+2][0] + 1;
            if (i+2 < s.size() && s.substr(i, 2) != s.substr(i+2, 2)) {
                dp[i][1] = max(dp[i][1], dp[i+2][1] + 1);
            }
        }
    }
    cout << max(dp[0][0], dp[0][1]) << endl;
}


Measured memory_bytes: 12020
#include <bits/stdc++.h>
using namespace std;
using namespace std;
 
#define ll long long
#define f(i,a,b) for(int i=a;i<b;i++)
#define endl '\n'
#define spc " "
#define pb push_back
#define mp make_pair

int main() 

{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ll s,w;
    cin>>s>>w;
    if(w>=s) cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;

}

Measured memory_bytes: 3648
#include<iostream>


bool is_include(int W, int H, int x, int y, int r) {
  if (0 <= x - r && x + r <= W && 0 <= y - r && y + r <= H) {
    return true;
  } else {
    return false;
  }
}

int main() {
  int W, H, x, y, r;

  std::cin >> W >> H >> x >> y >> r;

  if (is_include(W, H, x, y, r)) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3104
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    int N, Y;
    cin >> N >> Y;
    bool noAns = false; 
    for(int a = 0; a <= N; a++)
    {
        for(int b = 0; b <= N - a; b++)
        {
            if((10000 * a + 5000 * b + 1000 * (N - a -b)) == Y)
            {
                cout << a << " " << b << " " << N - a - b << endl;
                return 0;
            }
            else
            {
                noAns = true;
            }
        }
    }
    // for(int a = 0; a <= N; a++)
    // {
    //     for(int b = 0; b <= N - a; b++)
    //     {
    //         for(int c = 0; c <= N - a - b; c++)
    //         {
    //             if((10000 * a + 5000 * b + 1000 * c) == Y)
    //             {
    //                 cout << a << " " << b << " " << c << endl;
    //                 return 0;
    //             }
    //             else
    //             {
    //                 noAns = true;
    //             }
    //         }
    //     }
    // }

    if(noAns)
    {
    cout << "-1 -1 -1" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
# ITP1_5_C: Print a Chessboard

def make_line(width, is_even)
  line = (is_even ? '#.' : '.#') * width
  line[0, width]
end

while true
  height, width = gets.split.map &:to_i
  break if height == 0 && width == 0

  even_line = make_line width, true
  odd_line  = make_line width, false

  height.times do |n|
    puts( n & 1 == 0 ? even_line : odd_line )
  end
  puts
end

Measured memory_bytes: 8620
def sumDigit(num, sum)
  if num == 0 then return sum end
  d, m = num.divmod(10)
  return sumDigit(d, m + sum)
end

k = gets.to_i

n = 0
while(k > 0)
  temp = Hash.new
  s = n == 0 ? 1 : 100
  (s..999).each{|i|
    j = (i + 1) * (10 ** n) - 1  #ex) 10099....9
    temp[j] = j / sumDigit(i, 9 * n).to_f
  }

  sorted = temp.sort_by {|k, v| [v, k]}
  bef = 0
  sorted.each{|k, v|
    if k - bef > 1 then sorted.reject!{|key, value| bef < key && key < k} end
    bef = k
  }
  sorted.each{|key, value|
    print("#{key}\n")
    k -= 1
    exit if k == 0
  }

  n += 1
end


Measured memory_bytes: 2040
#define _CRT_SECURE_NO_WARNINGS
#define MaxSize 7629395
#include <stdio.h>
#include <stdlib.h>


void insert(unsigned int *D, unsigned int a) {
	unsigned int bitP = a % 32u;
	unsigned int mask = 1u << bitP;

	D[a / 32u] |= mask;
}

int find(unsigned int *D, unsigned int a) {
	unsigned int bitP = a % 32u;
	unsigned int mask = 1u << bitP;

	return (int)((D[a / 32u] & mask) >> bitP);

}

unsigned int conv(char s[]) {
	int i = 0;
	unsigned int a = 0u;
	while (s[i] != '\0') {
		a *= 5;
		if (s[i] == 'A') {
			a += 1u;
		}
		else if (s[i] == 'C') {
			a += 2u;
		}
		else if (s[i] == 'G') {
			a += 3u;
		}
		else {
			a += 4u;
		}
		++i;
	}
	return a;
}

int main() {
	unsigned int *D = (unsigned int *)malloc(sizeof(unsigned int) * MaxSize);
	int i;
	for (i = 0; i < MaxSize; ++i) {
		D[i] = 0u;
	}

	char com[7];
	char s[13];
	int n;
	scanf("%d", &n);
	for (i = 0; i < n; ++i) {
		scanf("%s%s", com, s);
		if (com[0] == 'i') {
			insert(D, conv(s));
		}
		else {
			if (find(D, conv(s))) {
				printf("yes\n");
			}
			else {
				printf("no\n");
			}
		}
	}


	free(D);

	return 0;
}

Measured memory_bytes: 30368
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

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

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N, K; std::cin >> N >> K;
  std::vector<int> p(N); rep(i,N) std::cin >> p[i];
  std::sort( all(p) );
  int ans = 0;
  rep(i,K) ans += p[i];
  std::cout << ans << std::endl;
  return 0;
}



Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int a;cin >> a;
    LL ans = 0;
    ans = a + a*a + a*a*a;
    cout << ans << endl;   
}

Measured memory_bytes: 3672
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <fstream>

using namespace std;
using ll=long long;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REP1(i, n)  for(int i = 1; i <= (int)n; ++i)
#define REPT(i, t, n)  for(int i = t; i <= (int)n; ++i)
#define REPll1(i, n)  for(ll i = 1; i*i < (int)n; ++i)
const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll MOD = 1e9 + 7;
typedef pair<int, int> Pi;

int mx[4] = {0, -1, 0, 1};
int my[4] = {-1, 0, 1, 0};
int X = 100000;

int main() {
    string s, t, a = "";
    cin >> s;
    cin >> t;
    int cnt = 0;
    for (int i = s.length() - 1; i >= 0; i--) {
        bool flag = true;
        REP(j, t.length()) {
            if (i + j >= s.length()) {
                flag = false;
                break;
            }
            if (s[i + j] != t[j] && s[i + j] != '?')flag = false;
        }
        if (flag) {
            cnt++;
            REP(j, t.length()) {
                s[i + j] = t[j];
            }
            break;
        }
    }
    REP(i, s.length()) {
        if (s[i] == '?')s[i] = 'a';
    }
    if (cnt > 0)cout << s << endl;
    else cout << "UNRESTORABLE" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
static const int MAX = 40;

int K;

int main(){
	cin >> K;
	for (int t = 0; t < K; t++){
		int T[MAX][MAX] = { 0 }, x, y, p, x1, x2, y1, y2,
			L[MAX][MAX] = { 0 }, up[MAX][MAX] = { 0 };
		
		cin >> x >> y;
		cin >> p;
		for (int i = 0; i < p; i++){
			cin >> x1 >> y1 >> x2 >> y2;
			if (x1 == x2)up[x1+1][max(y1, y2)+1]=1;
			else L[max(x1, x2) + 1][y1 + 1] = 1;
		}
		for (int i = 1; i <= x+1; i++){
			for (int j = 1; j <= y+1; j++){
				if (i == 1 && j == 1)T[i][j] = 1;
				if (L[i][j] == 0)T[i][j] += T[i - 1][j];
				if (up[i][j] == 0)T[i][j] += T[i][j - 1];
			}
		}
		if (!T[x + 1][y + 1])cout << "Miserable Hokusai!" << endl;
		else cout << T[x + 1][y + 1] << endl;

	}
}

Measured memory_bytes: 1176
vert = [False] * 8
hori = [False] * 8
topright = [False] * (8 * 2 - 1)
topleft = [False] * (8 * 2 - 1)
queens = []
skip_row = []


def put_queen(x, y):
    vert[x] = True
    hori[y] = True
    topright[x + y] = True
    topleft[7 + (x - y)] = True
    queens.append((x, y))


def elim_queen(x, y):
    vert[x] = False
    hori[y] = False
    topright[x + y] = False
    topleft[7 + (x - y)] = False
    queens.remove((x, y))


def is_blank(x, y):
    if not vert[x] and not hori[y] and not topright[x+y] and not topleft[7+(x-y)]:
        return True


def search_blank_in_row(y):
    blanks = []
    for x in range(8):
        if is_blank(x, y):
            blanks.append(x)
    return blanks


def put_queen_in_row(y):
    #print("put_queen_row",y, queens)
    if y == 8:
        return True     # 既にQを7行に置いているので正解に到達
    if y in skip_row:
        return put_queen_in_row(y + 1)   # 前提条件にある列は無視して次の行に行く

    for x in search_blank_in_row(y):
        put_queen(x, y)
        if not put_queen_in_row(y + 1):
            elim_queen(x, y)    # クイーンを置けなかったのでx,yを取り除く
        else:
            return True
    return False    # すべての候補が失敗


def main():
    # prepare
    n = int(input())
    for i in range(n):
        x, y = map(int, input().split())
        put_queen(x, y)
        skip_row.append(y)

    # 8 queen main
    put_queen_in_row(0)

    # draw queens
    board = [list('........') for x in range(8)]
    for q_x, q_y in queens:
        board[q_x][q_y] = 'Q'
    [print(''.join(x)) for x in board]
    return


main()


Measured memory_bytes: 5612
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int p[n+1];
    for(int i=0;i<n;i++)
    {
        cin>>p[i];
    }
    int mn=p[0];
    int ans=1;
    for(int i=1;i<n;i++)
    {
        if(p[i]<=mn)
        {
            mn=p[i];
            ans++;
        }
        else 
            continue;
    }
    cout<<ans<<endl;
}

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


void solve(long long N, long long K, std::vector<long long> p)
{
    sort(p.begin(), p.end());
    long long sum = 0;
    for (int i = 0; i < K; i++) {
        sum += p[i];
    }
    cout << sum << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, K, std::move(p));
    return 0;
}


Measured memory_bytes: 3664
a, b = map(int, input().split())
c = float(str(a) + str(b))
x = 1.0
while(x < int(c) // 2):
    if x == c / x:
        print("Yes")
        break
    if int(x) == (int(c) // 2) - 1:
        print("No")

    x += 1


Measured memory_bytes: 2940
x=int(input())
l,r=0,100000000000000
while r-l>1:
  m=(l+r)//2
  t=m
  cnt=0
  while m>2:
    cnt+=1
    m=(m-1)//2
  if cnt>x:
    r=t
  else:
    l=t
print(l)

Measured memory_bytes: 2940
// RAM RAM

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define mp make_pair
#define arrayin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define N 55

using namespace std;


int evaluate(string a){
	vector<int> v;
	int temp=0;
	for(int i=0;i<a.length();i++){
		if(a[i]=='+'){
			v.pb(temp);
			temp=0;
		}else{
			temp=temp*10+(int)(a[i]-'0');
			if(i==a.length()-1){
				v.pb(temp);
			}
		}
	}
	int res=0;
	for(int x:v){
		res+=(x);
	}
	return res;
}

bool check(string a,int n){
	int cnt=0;
	for(int i=0;i<a.length();i++){
		if(a[i]=='+')
			cnt++;
	}
	if(cnt>n){
		return true;
	}
	return false;
}
set<string> s;
void generate(string a,int idx,int n){
	if(check(a,n) || a[a.length()-1]=='+' || idx>=a.length()){
		return;
	}
	s.insert(a);
	a.insert(idx+1,"+");
	if(a[a.length()-1]=='+') return;
	s.insert(a);
	generate(a,idx+2,n);
	a.erase(a.begin()+idx+1);
	generate(a,idx+1,n);
	return ;
}

int solve(){
	int res=0;
	for(string x:s){
		res+=(evaluate(x));
	}
	return res;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);
    string a;
	cin>>a;
	generate(a,0,a.length()-1);
	cout<<solve()<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	string S, T, U;
	int A, B;
	cin >> S >> T;
	cin >> A >> B;
	cin >> U;
	if(U == S){
		A = A - 1;
		cout << A << " " << B << endl;
	} else {
		B = B - 1;
		cout << A << " " << B << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <vector>

using namespace std;



int main()
{
	int d, s;
	
	while (cin >> d)
	{
		s = 0;
		
		for (int i=d; i<=600-d; i+=d)
		{
			s += i*i * d;
		}
		cout << s << endl;
	}
	
	return 0;
}

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

int main(void){
    int a,b,c;
    int n=0;
    cin >> a >> b >> c ;
    while(c>0){
        c--;
//        cout << "c" << endl;
        n++;
        if(b>0){
            b--;
            n++;
//            cout << "b" << endl;
        }else if(a>0){
            a--;
//            cout << "a" << endl;
        }else{
            break;
        }
    }
    n+=b;
    cout << n << endl;
    return 0;
}

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

using namespace std;

string s;
int a[500100];

int main() {
	cin >> s;
	int n = s.length();
	for (int i = 0; i < n; i++) {
		if (s[i] == '<') {
			a[i + 1] = max(a[i + 1], a[i] + 1);
		}
	}
	for (int i = n - 1; i >= 0; i--) {
		if (s[i] == '>') {
			a[i] = max(a[i], a[i + 1] + 1);
		}
	}
	long long ans = 0;
	for (int i = 0; i <= n; i++) ans += a[i];
	cout << ans << '\n';
}

Measured memory_bytes: 2820
#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"

using ll = long long;
using P = pair<int, int>;

const long long MOD = 1e9+7;

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

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

int main() {
    vector<vector<int>> a(3, vector<int>(3));
    cin >> a;
    int n;
    cin >> n;
    vector<bool> done(101);
    rep(i, n) {
        int b;
        cin >> b;
        done.at(b) = true;
    }

    bool ok = false;
    rep(i, 3) {
        bool all = true;
        rep(j, 3) all &= done.at(a.at(i).at(j));
        ok |= all;
    }

    rep(j, 3) {
        bool all = true;
        rep(i, 3) all &= done.at(a.at(i).at(j));
        ok |= all;
    }

    {
        bool all = true;
        rep(j, 3) all &= done.at(a.at(2 - j).at(j));
        ok |= all;
    }

    {
        bool all = true;
        rep(j, 3) all &= done.at(a.at(j).at(j));
        ok |= all;
    }

    cout << (ok? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using P = pair<ll, ll>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<P> td(n); // first:ネタ second:おいしさ
    for (ll i = 0; i < n; i++)
    {
        cin >> td[i].first >> td[i].second;
    }

    sort(td.begin(), td.end(), [](const auto &a, const auto &b) { return a.second > b.second; });
    ll ans = 0, now = 0;
    map<ll, bool> used;
    priority_queue<ll, vector<ll>, greater<ll>> v;
    for (ll i = 0; i < k; i++)
    {
        now += td[i].second;
        if (!used[td[i].first])
        {
            used[td[i].first] = true;
        }
        else
        {
            v.push(td[i].second);
        }
    }
    ll index = k;
    ans = now + (ll)used.size() * (ll)used.size();
    while (!v.empty() && index < n)
    {
        if (!used[td[index].first])
        {
            now -= v.top();
            v.pop();
            now += td[index].second;
            used[td[index].first] = true;
            ans = max(ans, now + (ll)used.size() * (ll)used.size());
        }
        index++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6140
import sys
#import time
import copy
#from collections import deque, Counter, defaultdict
#from fractions import gcd
#import bisect
#import heapq
#import time

input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.root = [-1]*(n+1)
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def find(self, x):
        if(self.root[x] < 0):
            return x
        else:
            self.root[x] = self.find(self.root[x])
            return self.root[x]
    # 木の併合、入力は併合したい各ノード
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if(x == y):
            return 
        elif(self.rnk[x] > self.rnk[y]):
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if(self.rnk[x] == self.rnk[y]):
                self.rnk[y] += 1
    # xとyが同じグループに属するか判断
    def same(self, x, y):
        return self.find(x) == self.find(y)
    # ノードxが属する木のサイズを返す
    def size(self, x):
        return -self.root[self.find(x)]


n = ri()
d=[tuple(rl())+tuple((i,)) for i in range(n)]

d.sort(key=lambda x: x[0])
edge=[]
for i in range(n-1):
    edge.append((d[i+1][2], d[i][2],d[i+1][0]-d[i][0]))
d.sort(key=lambda x:x[1])
for i in range(n-1):
    edge.append((d[i+1][2], d[i][2],d[i+1][1]-d[i][1]))
edge.sort(key=lambda x: x[2])
res=0
uf = UnionFind(n)
for e in edge:
    if uf.same(e[0], e[1]):
        continue
    uf.unite(e[0], e[1])
    res+=e[2]
print(res)

Measured memory_bytes: 47072
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = gets.to_i
count = 0
(0..a).each do |a|
  (0..b).each do |b|
    (0..c).each do |c|
      count += 1 if 500 * a + 100 * b + 50 * c == x
    end
  end
end
puts count

Measured memory_bytes: 1788
fun main() {
    val k = nextInt()
    if (k < 10) {
        return println(k)
    }
    val lunlun = LongArray(k + 1)
    for (i in 0..9) {
        lunlun[i] = i.toLong()
    }
    var count = 9
    var i = 0
    var p = 1
    while (count < k) {
        if (i > lunlun[p] % 10 + 1 || i > 9) {
            p++
            i = (lunlun[p] % 10).toInt() - 1
            if (i < 0) {
                i = 0
            }
        } else {
            lunlun[++count] = lunlun[p] * 10 + i
            if (count == k) break
            i++
        }
    }
    println(lunlun[k])
}

fun rsp() = readLine()!!.split(" ")
fun rspint() = readLine()!!.split(" ").map { it.toInt() }
fun printYN(isYes: Boolean) = println(if (isYes) "Yes" else "No")
val scanner = java.util.Scanner(System.`in`)
fun next(): String = scanner.next()
fun nextInt(): Int = scanner.nextInt()
fun nextLong(): Long = scanner.nextLong()

fun main(args: Array<String>) = main()

Measured memory_bytes: 31268
#include<bits/stdc++.h>
using namespace std;
int n,k,l,i,f[210000],g[210000],cnt[210000],x,y,a[210000],ii,j;
int Find(int x) {
	if (f[x] == x) return(f[x]); else return (f[x] = Find(f[x]));
}
int gind(int x) {
	if (g[x] == x) return(g[x]); else return (g[x] = gind(g[x]));
}
bool cmp(int o, int p) {
	if (Find(o) == Find(p)) {
		return (gind(o) < gind(p));
	} else return (Find(o) < Find(p));
}
int main() {
	scanf("%d%d%d", &n, &k, &l);
	for (i = 1; i <= n; i++) f[i] = i, g[i] = i,a[i] = i;
	for (i = 1; i <= k; i++) {
		scanf("%d %d", &x, &y);
		int a = Find(x);
		int b = Find(y);
		if (a != b) f[a] = b;
	}
	for (i = 1; i <= l; i++) {
		scanf("%d %d", &x, &y);
		int a = gind(x);
		int b = gind(y);
		if (a != b) g[a] = b;
	}
	sort(a + 1, a + 1 + n, cmp);
	ii = 1;
	while (ii <= n) {
		i = ii;
		while (Find(a[i]) == Find(a[i + 1]) && gind(a[i]) == gind(a[i + 1])) i++;
		for (j = ii; j <= i; j++) cnt[a[j]] = i - ii + 1;
		ii = i + 1;
	}
	for (i = 1; i <= n; i++) cout<<cnt[i]<<" ";
} 

Measured memory_bytes: 3840
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main{
	Scanner sc=new Scanner(System.in);

	int n;
	int[] l, c;
	double[] v;

	double EPS=1e-6;
	int INF=1<<28;

	class taple{
		int m=1;
		int y=1;

		taple(int a, int b){
			m=a;
			y=b;
		}
	}

	void run2(){
		for(;;){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			for(int i=0; i<n; i++){
				l[i]=sc.nextInt();
				c[i]=sc.nextInt();
			}
			int[] x=new int[n];
			int[] lap=new int[n];
			boolean[] end=new boolean[n];
			taple[][] couple=new taple[n][n];
			for(int t=0; t<n; t++){
				lap[t]=c[t];
			}
			for(int i=0; i<n; i++){
				for(int j=0; j<n; j++){
					if(lap[i]>lap[j]){
						int div, mod;
						div=lap[i]/(lap[i]-lap[j]);
						mod=lap[i]%(lap[i]-lap[j]);
						if(mod!=0)
							div++;
						couple[i][j]=new taple(div+1, div);
						couple[j][i]=new taple(div, div+1);
					}
				}
			}
			while(true){
				boolean b;
				//				

			}

		}
	}

	void run(){

		for(;;){
			n=sc.nextInt();
			if(n==0){
				break;
			}
			R[] rs=new R[n];
			for(int i=0; i<n; i++){
				rs[i]=new R();
				rs[i].l=sc.nextInt();
				rs[i].c=sc.nextInt();
				rs[i].v=1.0/rs[i].l;
			}
			// [0:2]
			// 0,1ツづ古ーツ環キツ嘉つ能
			Arrays.sort(rs, new Comparator<R>(){
				@Override
				public int compare(R r1, R r2){
					return (int)((r2.v-r1.v)*100000);
				}
			});

			// ツ優ツ静ヲツ度ツ渉づ可…
			for(int t=1; ; t++){
				double first=INF;
				double end=rs[n-1].x;

				for(int i=0; i<n; i++){
					if(rs[i].goal){
						continue;
					}
					rs[i].x+=rs[i].v;
					first=rs[i].x=Math.min(rs[i].x, first);
					if(rs[i].x+EPS>2){
						rs[i].c--;
						rs[i].x-=2;
						end=rs[i].x=Math.min(rs[i].x, end);
						rs[i].goal=rs[i].c==0;
					}else{
						// first=rs[i].x=Math.min(rs[i].x, first);
					}
				}
				// sort
				Arrays.sort(rs, new Comparator<R>(){
					@Override
					public int compare(R r1, R r2){
						if((Math.abs(r1.x-0)<EPS&&Math.abs(r2.x-0)<EPS)
								||(Math.abs(r1.x-1)<EPS&&Math.abs(r2.x-1)<EPS)){
							// ツスツタツーツトorツ静慊づィツ陛板つオ
							return (int)((r2.v-r1.v)*100000);
						}
						return (int)((r2.x-r1.x)*100000);
					}
				});
/*				println("time="+t);
				for(int i=0; i<n; i++){
					println("i="+i+", x="+rs[i].x+" ,l="+rs[i].l+", c="+rs[i].c
							+", v="+rs[i].v);
				}*/
				int sumC=0;
				for(R r : rs){
					sumC+=r.c;
				}
				if(sumC==0){
					println(t+"");
					break;
				}
			}
		}
	}

	class R{
		int l, c;
		double v, x, r;
		boolean goal;
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		new Main().run();

	}
}

Measured memory_bytes: 12000
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  int a,b,c,d;cin>>a>>b>>c>>d;
  cout << (a-c)*(b-d) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int A[3]={2,3,5};
map<ll,ll> M;
priority_queue<PI,vector<PI>,greater<PI> > q;
ll fy[3];
void gx(ll x,ll y){
	if(M.count(x)){
		if(M[x]>y){
			M[x]=y;
			q.push(mp(y,x));
		}
	}else{
		M[x]=y;
		q.push(mp(y,x));
	}
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int T=read();
	while(T--){
		ll n=read(),ans=1e18;
		For(i,0,2)fy[i]=read(); ll d=read();
		//while(q.size())q.pop(); 
		M.clear();
		q.push(mp(0,n)); M[n]=0;
		while(q.size()){
			PI t=q.top(); q.pop(); //cout<<t.fi<<" "<<t.se<<" "<<M[t.se]<<endl;
			if(t.fi>=ans||M[t.se]<t.fi)continue;
			if(d<=(ans-t.fi)/t.se)ans=t.fi+t.se*d;
			For(i,0,2){
				ll x=t.se+i,y=t.fi+i*d;
				For(o,0,2)if(i*2<=A[o]&&x%A[o]==0)gx(x/A[o],y+fy[o]);
				x=t.se-i; if(x<0)continue;
				For(o,0,2)if(i*2<=A[o]&&x%A[o]==0)gx(x/A[o],y+fy[o]);
			}
		}
		writeln(ans);
	}
}


Measured memory_bytes: 4336
cards = {
        'S': [r for r in range(1,13+1)],
        'H': [r for r in range(1,13+1)],
        'C': [r for r in range(1,13+1)],
        'D': [r for r in range(1,13+1)],
        }
 
n = int(input())
for nc in range(n):
    (s, r) = input().split()
    index = cards[s].index(int(r))
    del cards[s][index]
 
for s in ['S', 'H', 'C', 'D']:
    for r in cards[s]:
        print(s, r)

Measured memory_bytes: 6724
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N,M;

  cin >> N >> M;

  vector<int> a(M), b(M), r(N);

  

  for(int i=0;i<M;i++){
    cin >> a.at(i) >> b.at(i);
  }

  for(int i=0;i<N;i++){
    r.at(i)=0;
    for(int j=0;j<M;j++){
      if(a.at(j)==i+1) r.at(i)++;
      if(b.at(j)==i+1) r.at(i)++;    
    }
  }
  
  for(int i=0;i<N;i++){
  cout << r.at(i) << endl;
  }
 
  return 0;
}

Measured memory_bytes: 256
from sys import stdin 
n,x,y = map(int,stdin.readline().split())
a = []
for _ in xrange(n):
    a.append(int(stdin.readline()))
lo = 0
hi = 10**18 
def solve(tim):
    tot = 0 
    for i in a:
        if i > tim * y:
            rem = i - tim * y 
            tot += rem / (x-y) 
            if rem % (x-y) :
                tot += 1 
    return tot <= tim 
while hi > lo + 1 :
    mid = (lo + hi )/2 
    if solve(mid):
        hi = mid 
    else:
        lo = mid 
for ans in xrange(lo,hi+1):
    if solve(ans):
        break 
print ans

Measured memory_bytes: 5764