akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_.first<<", "<<_.second<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;

const int MOD = 1e9+7;
const int INF = 1e9;

int main() {
	string S;
	cin>>S;
	int N = S.size();
	int g = 0, p = 0;
	vector<P> V(N+1);
	V[0] = {0,0};
/*	rep(i,N){
		if(S[i] == 'g')g++;
		else p++;
		V[i+1] = {g,p};
	}*/
	int ans = 0;
	string Sn = "";
	rep(i,N){
		g = V[i].first;
		p = V[i].second;
		if(S[i] == 'g'){
			if(g>p){
				//cout<<'p';
				p++;
				ans++;
			}
			else{
				//cout<<'g';
				g++;
			}
		}
		else{
			if(g>p){
				//cout<<'p';
				p++;
			}
			else {
				//cout<<'g';
				g++;
				ans--;
			}
		}
		V[i+1] = {g,p};
	}
	print(V);

	cout<<ans<<endl;
}

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

int x, y, a, b, c;
vector<int> red, green, colorless;

int32_t main()
{
	cin >> x >> y >> a >> b >> c;
	for(int i = 0; i < a; i++)
	{
		int v;
		cin >> v;
		red.push_back(v);
	}
	for(int i = 0; i < b; i++)
	{
		int v;
		cin >> v;
		green.push_back(v);
	}
	
	for(int i = 0; i < c; i++)
	{
		int v;
		cin >> v;
		colorless.push_back(v);
	}

	// ok
	
	sort(red.rbegin(), red.rend());
	sort(green.rbegin(), green.rend());
	
	while((int)red.size() > x) red.pop_back();
	while((int)green.size() > y) green.pop_back();
	
	sort(colorless.begin(), colorless.end());
	
	while((int)red.size() < x and !colorless.empty())
	{
		red.push_back(colorless.back());
		colorless.pop_back();
	}
	
	while((int)green.size() < y and !colorless.empty())
	{
		green.push_back(colorless.back());
		colorless.pop_back();
	}
	
	priority_queue<int> R, G;
	
	for(int &w : red) R.push(-w);
	for(int &w : green) G.push(-w);
	
	while(!colorless.empty())
	{
		int v = colorless.back();
		colorless.pop_back();

		int a = -R.top();
		R.pop();
		int b = -G.top();
		G.pop();
	
		if(a <= b and v > a)
			a = v;
		else if(a >= b and v > b)
			b = v;
			
		R.push(-a);		
		G.push(-b);		
	}
	
	int ans = 0;
	
	while(!R.empty())
	{
		ans += -R.top();
		R.pop();
	}
	while(!G.empty())
	{
		ans += -G.top();
		G.pop();
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 4852
from collections import Counter

N = int(input())
S = input()
cnt = Counter(S)
total = cnt["R"] * cnt["G"] * cnt["B"]
S = "#" + S

sub = 0
for i in range(1, N-1):
    for j in range(i+1, N):
        k = 2 * j - i
        if k < N + 1:
            if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
                sub += 1

print(total - sub)

Measured memory_bytes: 9472
#include<iostream>
using namespace std;
int main(void){
	int n;
	cin >> n;
	int a,b,c,d;
	a = n/1000; 	n-=a*1000;
	b = n/100; 	n-=b*100;
	c = n / 10; 	n -=c*10;
	d = n;
 
	if(a == b && b ==c){cout << "Yes" << endl; return 0;}
	if(b == c && c ==d){cout << "Yes" << endl; return 0;}
	cout <<"No"<<endl;
 
 
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<stack>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#define maxn 200100
 
using namespace std;
int main()
{
	int n;
	scanf("%d",&n);
	int o=0;
	for(int i=1;i<=n;i++)
	{
		int a;
		scanf("%d",&a);
		if(a!=i)
			o++;
	}
	if(o==0||o==2)
		printf("YES\n");
	else
		printf("NO\n");
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
S = []
for i in range(N):
    S.append(input())
c = Counter(S)

print('AC x ' + str(c['AC']))
print('WA x ' + str(c['WA']))
print('TLE x ' + str(c['TLE']))
print('RE x ' + str(c['RE']))


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int N, M;
  cin >> N >> M;
  vector<vi32> g(N, vi32(N, 1e9));
  rep(i, N) g[i][i] = 0;
  rep(i, M) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    g[a][b] = g[b][a] = c;
  }
  auto h = g;
  rep(k, N) rep(i, N) rep(j, N) amin(h[i][j], h[i][k] + h[k][j]);
  int ans = 0;
  rep(i, N) rep(j, i) {
    if (g[i][j] != 1e9 && g[i][j] != h[i][j]) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    intl ans = m;
    rep(i,m - n + 1){
        ans -= i;
    }
    cout << -1 * ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

ll cal(vector<ll>& A, int n)
{
  ll ret = 0;
  for (int k = 0; k < n; ++k) {
    ret = (ret + (2 * k + 1 - n) * A[k] + MOD) % MOD;
  }
  return ret;
}

int main()
{
  ll N, M; scanf("%lld %lld", &N, &M);
  vector<ll> X(N), Y(M);
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &X[i]);
  }
  for (int i = 0; i < M; ++i) {
    scanf("%lld", &Y[i]);
  }
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());
  ll ans = cal(X, N) * cal(Y, M);
  ans %= MOD;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    t, x = mi()
    print(t / x)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
def make_divisors(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(n // i + i)
            if i != n // i:
                divisors.append(n // i + i)
    divisors.sort()
    return divisors


def main():
    n = int(input())
    divs = make_divisors(n)
    res = divs[0]
    print(res - 2)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3288
from collections import deque
n, m = map(int, input().split())
w = [set() for _ in range(n + 1)]
for _ in range(m):
  u, v = map(int, input().split())
  w[u].add(v)
s, t = map(int, input().split())
l = [[-1, -1, -1] for _ in range(n + 1)] # 頂点までの最短移動回数（余りごとに３つ）

d = deque()
d.append((s, 0, 0))
while d: # qが小さい順に制御されている
  i, q, r = d.popleft() # 頂点番号、商、余り
  for _w in w[i]:
    if _w == t and r == 2: # 終了条件
      print((q + 1) // 3)
      exit()
    if l[_w][(r + 1) % 3] == -1: # 余り考慮での初到達時に、メモとTODO追加
      l[_w][(r + 1) % 3] = q + 1
      d.append((_w, q + 1, (r + 1) % 3))
print(-1)

Measured memory_bytes: 119124
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<string,int> P;


int main(){
  string s,t[210000];
  ll ans=0,count=0,temp=0;
  cin>>s;
  s.push_back('?');
  for(int i=0;i<(int)s.size();i++){
      if(s[i]=='A') t[count].push_back('A');
      else if(s[i]=='B' && s[i+1]=='C'){
          t[count].push_back('D');
          i++;
      }else count++;
  }
  count++;
  for(int i=0;i<count;i++,temp=0){
      for(int j=0;j<(int)t[i].size();j++){
        if(t[i][j]=='A') temp++;
        else if(t[i][j]=='D') ans+=temp;
      }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4356
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD7 1000000007
#define LL_INF 1LL << 60
#define LL_MINF -1LL << 60
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const long double PI = (acos(-1));

template<typename T>
T gcd(T a, T b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);

    ll x, y;
    cin >> x >> y;
    cout << gcd(x, y) << endl;
}



Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

int main () {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  vvi tx(h,vi(w,-1)), ty(h,vi(w,-1));
  rep(y,h) {
    rep(x,w) {
      if (s[y][x] == '.') {
        int cnt = 0;
        for (int i = x; i < w && s[y][i] == '.'; ++i) {
          cnt++;
        }
        for (int i = x; i < x+cnt; ++i) {
          tx[y][i] = cnt;
        }
        x += cnt-1;
      }
    }
  }
  rep(x,w) {
    rep(y,h) {
      if (s[y][x] == '.') {
        int cnt = 0;
        for (int i = y; i < h && s[i][x] == '.'; ++i) {
          cnt++;
        }
        for (int i = y; i < y+cnt; ++i) {
          ty[i][x] = cnt;
        }
        y += cnt-1;
      }
    }
  }

  /*
  puts("\n");
  rep(i,tx.size()) {
    rep(j,tx[i].size()) {
      printf("%d%c", tx[i][j], j==tx[i].size()-1?'\n':' ');
    }
  }
  puts("\n");
  rep(i,ty.size()) {
    rep(j,ty[i].size()) {
      printf("%d%c", ty[i][j], j==ty[i].size()-1?'\n':' ');
    }
  }
  */

  int ans = 0;
  rep(y,h) {
    rep(x,w) {
      ans = max(ans,tx[y][x]+ty[y][x]-1);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 35712
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int solve(){
	int e;
	cin >> e;
	if(e==0)return 1;
	int ans = INF;
	for(int i=0;i*i*i<=e;i++){
		for(int j=0;j*j+i*i*i<=e;j++){
			int k = e-i*i*i-j*j;
			ans = min(ans,i+j+k);
		}
	}
	cout << ans << endl;
	return 0;
}
int main(){
	while(1){
		if(solve())return 0;
	}
}

Measured memory_bytes: 3072
import itertools

nums=[int(input()) for i in range(6)]

a_e=nums[0:5]
k=nums[5]

comb=list(itertools.combinations(a_e, 2))

cnt=0
for c in comb:
  if abs(c[0]-c[1])>k:
    cnt+=1
    
if cnt!=0:
  print(":(")
else:
  print("Yay!")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
#define MOD 1000000007

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> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){return a/GCD(a,b)*b;}

const int INF=1e9;
const double eps=0.0000000001;

int main(){
  
  string s;
  cin >> s;
  sort(s.begin(),s.end());
  bool a=0;
  FOR(i,s.size()-1){
    if(s[i]==s[i+1])a=1;
  }

  if(a){
    cout << "no" << endl;
  }else{
    cout << "yes" << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        if (Integer.valueOf(n.substring(0, 3)) % 111 == 0 ||
            Integer.valueOf(n.substring(1, 4)) % 111 == 0) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
    }
}



Measured memory_bytes: 23380
n=int(input())
xyh=[list(map(int,input().split())) for _ in range(n)]
x0,y0,h0=0,0,0
for x,y,h in xyh:
  if h>0:
    x0,y0,h0=x,y,h
    break
# 頂点を固定して全探索
for cx in range(101):
  for cy in range(101):
    h=h0+abs(cx-x0)+abs(cy-y0)
    flg=True
    for xi,yi,hi in xyh:
      if hi!=max(h-abs(cx-xi)-abs(cy-yi),0):
        flg=False
    if flg:
      print(cx,cy,h)


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

using  namespace  std;

#define PI              acos(-1.0)
#define lcm(a,b)        (a * (b / __gcd(a,b)))
#define en '\n'

#define READ_IN freopen("Input.txt","r",stdin);
#define READ_OUT freopen("Output.txt","w",stdout);


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define trace(x...)
#endif

typedef long long int           ll;
typedef unsigned long long int  llu;


int main()
{
    //READ_IN

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

    ll a,b,x;

    cin >> a >> b >> x;


    if(x>=a)
    {
        x=x-a;
        a=0;


        if(x>=b)
            b=0;
            else
                b=b-x;

    }
    else
    {
        a=a-x;

    }

    cout << a<< " " << b << endl;

    return 0;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000009
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;



int main()
{
int n,k,x,y;
cin>>n>>k>>x>>y;

if(n>=k)
{
    cout<<(k)*x+(n-k)*y<<endl;
}
else
    cout<<n*x<<endl;
 return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#pragma warning( disable:4996 )
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))


int main(void) {
	int x, a;
	scanf("%d %d", &x, &a);
	if (x < a) {
		printf("0\n");
	}
	else {
		printf("10\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

#define ll long long
#define db(x) cout << "> " << #x << " : " << x << endl;

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, m;
	cin >> n >> m;
	
	ll res = (n -m) *100 +(1900*m);
	res *= ((1ll << (m)));
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

int main () {
  ll N, K; cin >> N >> K;
  vector<int> A(N); REP(i,N) cin >> A[i];

  ll p = 0LL;
  FOR(i,0,N-1) {
    FOR(j,i+1,N) {
      if (A[i]>A[j]) p++;
    }
  }
  
  ll q = 0LL;
  REP(i,N) {
    REP(j,N) {
      if (i==j) continue;
      if (A[i]>A[j]) q++;
    }
  }

  ll ans;
  ll c1 = K;
  ll c2 = K*(K-1)/2; c2 %= mod;
  ans = (p*c1+q*c2)%mod;

  cout << ans << endl;

}

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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll(x);cin >> (x);
#define stin(x) str(x);cin >> (x);
#define vllin(x,n) vll(x)(n);FOR(i,0,n-1){cin >> (x)[i];}
#define vllin2(a,b,n) vll(a)(n);vll(b)(n);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i];}
#define vllin3(a,b,c,n) vll(a)(n);vll(b)(n);vll(c)(n);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i] >> (c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >> (x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i] >> (c)[i];}
#define vpl4in(x,n) vpl4(x)((n),mp(0,0));FOR(i,0,n-1){cin >> x[i].fi >> x[i].se;}
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define rFOR(i,b,a) for(ll i=a;i>=b;i--)
#define SORT(x) sort(x.be,x.en)
#define rSORT(x) sort(x.rbegin(),x.rend())
#define say(x) cout << (x);
#define sal(x) cout << (x) << endl;
#define says(x) cout << (x) << (' ');
#define sas cout << (' ');
#define sayR(x) cout << fixed << setprecision(10) << (x);
#define salR(x) cout << fixed << setprecision(10) << (x) << endl;
#define yn(a) cout << ((a) ? "yes" : "no") << endl;
#define Yn(a) cout << ((a) ? "Yes" : "No") << endl;
#define YN(a) cout << ((a) ? "YES" : "NO") << endl;
#define Imp(a) cout << ((a) ? "Possible" : "Impossible") << endl;
#define IMP(a) cout << ((a) ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll MOD = 1000000007;

signed main()
{
    llin(n)
    vllin2(x,y,n)
    ll o=0,g=0;
    FOR(i,0,n-1){
        if((x[i]+y[i])%2==0) g=1;
        else o=1;
    }
    if(o==1&g==1){
        sal(-1)
        return 0;
    }
    sal(32+g)
    ll p=2147483648;
    rFOR(i,0,31){
        say(p)
        p/=2;
        if(i>0) sas
    }
    if(g==1){
        sas
        say(1)
    }
    cout << endl;
    str s("");
    ll pp=2147483648;
    FOR(i,0,n-1){
        s="";
        p=pp;
    FOR(j,0,31+g){
        if(y[i]<=x[i]&y[i]>=-x[i]){
            s.pb('R');
            x[i]-=p;
        }
        else if(y[i]>=x[i]&y[i]<=-x[i]){
            s.pb('L');
            x[i]+=p;
        }
        else if(y[i]<=x[i]&y[i]<=-x[i]){
            s.pb('D');
            y[i]+=p;
        }
        else if(y[i]>=x[i]&y[i]>=-x[i]){
            s.pb('U');
            y[i]-=p;
        }
        if(p>1) p/=2;
    }
    sal(s)
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
long long n, a, b, c, ans;
int main() {
	cin>>n;
	while(n--) {
		cin>>a>>b;
		if(a==b) ans = 2*a-2;
		else {
			c = sqrt(a*b);
			if(c*c==a*b) c--;
			ans = (c*(c+1)>=a*b ? 2*c-2 : 2*c-1);
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

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

#define     endl               "\n"
#define     fast_io            ios::sync_with_stdio(false); cin.tie(0);
#define     file_io            freopen("input.txt", "r", stdin);   \
                               freopen("output.txt", "w", stdout);
#define     all(x)             begin(x), end(x)
#define     debug(x)           cerr <<"Line "<< __LINE__ <<" : "<< #x " = "<< x <<endl;
 
template<typename T, typename TT>
ostream& operator<<(ostream &os, const pair<T, TT> &t) { return os<<"("<<t.first<<", "<<t.second<<")"; }
template<typename T>
ostream& operator<<(ostream& os, const vector<T> &t) { for(auto& i: t) os<<i<<" "; return os; }
 

void rec(int n, bool flag = true) {
	if(n <= 0) {
		return;
	}
	int a;
	cin >> a;
	rec(n-1, false);
	if(n > 1)cout << " ";
	cout << a;
	if(flag) cout << endl;
}

int main(int argc, char** argv) {
    fast_io
   
	int n;
	cin >> n;
	rec(n);
	

    return 0;
}























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

int main(){
	int n,x;	cin>>n>>x;
	vector<int> a(n);	for(int i=0;i<n;i++)cin>>a[i];


	long long ans=0;
	for(int i=0; i+1<n; i++){
		if(a[i]+a[i+1]>x){
			int tmp=a[i]+a[i+1]-x;
			if(a[i+1]>=tmp){
				ans+=tmp;
				a[i+1]-=tmp;
			}else{
				ans+=a[i+1];
				tmp-=a[i+1];
				a[i+1]=0;

				ans+=tmp;
				a[i]-=tmp;
			}
		}
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 640
def main():
    N, x = map(int, input().split())
    if x <= 1 or 2*N-1 <= x:
        print("No")
    else:
        ans = [(x+i+N-1)%(2*N-1)+1 for i in range(2*N-1)]
        print("Yes")
        print(*ans, sep="\n")

if __name__ == "__main__":
    main()

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

int main(){
  int H, W;
  cin >> H >> W;
  char s[H+2][W+2];
  for(int i = 1; i <= H; i++){
    for(int j = 1; j <= W; j++){
      cin >> s[i][j];
    }
  }
  for(int i = 0; i < W+2; i++){
    s[0][i] = '.';
    s[H+1][i] = '.';
  }
  for(int i = 0; i < H+2; i++){
    s[i][0] = '.';
    s[i][W+1] = '.';
  }
  int can = true;
  for(int i = 1; i <= H; i++){
    for(int j = 1; j <= W; j++){
      if(s[i][j] == '#'){
        if(s[i-1][j] == '.' && s[i+1][j] == '.' && s[i][j+1] == '.' && s[i][j-1] == '.'){
          can = false;
        }
      }
    }
  }
  cout << (can? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>

using namespace std;

vector<int> primes;
bool isprime[10001];
int cnt[10001];

int main(){
    int n;

    memset(isprime,true,sizeof(isprime));

    for(int i=2;i<=10000;i++){
        if(isprime[i]){
            primes.push_back(i);
            for(int j=2;i*j<=10000;++j){
                isprime[i*j] = false;
            }
        }
    }

    int sz = primes.size();
    
    for(int i=0;i<sz;i++){
        int tmp=0;
        for(int j=i;j<sz;j++){
            tmp += primes[j];
            if(tmp > 10000) break;
            cnt[tmp]++;
        }
    }

    while(cin >> n && n){
        cout << cnt[n] << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> b(100000,0);
  for(int i = 0; i < n;i++) {
    cin>>a[i];
    b[a[i]]++;
  }
  int ans = 0;
  for(int i = 1; i < 99999; i++){
    ans = max(ans,b[i-1]+b[i]+b[i+1]);
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

double compute( double x[], double y[] ){

  double result = 0;
  for( int j = 1 ; j <= 3 ; j++ ){
    int J = j + 1;
    if( j == 3 ) J = 1;
    result += ( x[j]*y[J] - x[J]*y[j] );
  }
  result = abs(result) / 2;
  return result;
}

double heron(double a,double b,double c){
  double s = (a + b + c) / 2;
  double S = sqrt(s*(s - a)*(s - b)*(s - c) ); //テ」ツδ佚」ツδュテ」ツδウテ」ツ?ョテ・ツ?ャテ・ツシツ湘」ツつ津、ツスツソテァツ板ィ
  return S;
}

int main(void){

  double x[5];
  double y[5];

  while( cin >> x[1] >> y[1] >> x[2] >> y[2] >> x[3] >> y[3] >> x[4] >> y[4] ){

    double area1 = compute(x,y);
 
    double a = sqrt( pow( x[1] - x[2], 2 ) + pow( y[1] - y[2], 2 ) );
    double b = sqrt( pow( x[1] - x[3], 2 ) + pow( y[1] - y[3], 2 ) );
    double c = sqrt( pow( x[3] - x[2], 2 ) + pow( y[3] - y[2], 2 ) );
    double d = sqrt( pow( x[1] - x[4], 2 ) + pow( y[1] - y[4], 2 ) );
    double e = sqrt( pow( x[2] - x[4], 2 ) + pow( y[2] - y[4], 2 ) );
    double f = sqrt( pow( x[3] - x[4], 2 ) + pow( y[3] - y[4], 2 ) );
    double area2 = heron(d,e,a) + heron(d,f,b) + heron(e,f,c);

    if( (float)area1 == (float)area2) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
c;
main(i)
{
  char s[99];
  for(;fgets(s,99,stdin),c=i=!strstr(s,"END OF INPUT");printf("%d\n",c-1))
      for(;s[i]!=0;)
	c=s[i++]-32?c+1:!printf("%d",c);
  
}

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

typedef long long ll;
typedef long double ld;

int a[1000005];
int b[1000005];
int c[1000005];
int d[1000005];

int main(){
    ios_base::sync_with_stdio(false);
    cout.precision(10);
    cout<<fixed;

    int n, m;
    cin >> n >> m;
    for(int i=1; i<=n; i++){
        cin >> a[i] >> b[i];
    }
    for(int i=1; i<=m; i++){
        cin >> c[i] >> d[i];
    }
    for(int i=1; i<=n; i++){
        int mn = 1000000000;
        int res = 0;
        for(int j=1; j<=m; j++){
            if(abs(c[j]-a[i]) + abs(d[j]-b[i]) < mn){
                res = j;
                mn = abs(c[j]-a[i]) + abs(d[j]-b[i]);
            }
        }
        cout << res << "\n";
    }
    return 0;
}


Measured memory_bytes: 6400
S = list(input())
K = int(input())
N = len(S)
for i in range(N):
    if S[i] == 'a':
        continue
    diff = ord('z') - ord(S[i]) + 1
    if diff <= K:
        K -= diff
        S[i] = 'a'
if K != 0:
    K %= 26
    S[i] = chr(ord(S[i]) + K)
print("".join(S))


Measured memory_bytes: 4152
// 5/30
// 2-6-1. 線分状の格子点の個数
// 類題
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;

int gcd(int a, int b) {  // bが常にワル役
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

    vector<int> A(N);
    rep(i, N) cin >> A[i];

    int g = gcd(A[0], A[1]);  // gcd
    if (N == 3) g = gcd(g, A[2]);

    for (int i = 1; i <= g; i++) {
        if (g % i == 0) {
            cout << i << endl;
        }
    }
}




Measured memory_bytes: 3116
a=[list(map(int,input().split())) for _ in range(3)]
for i in range(int(input())):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k]==b:a[j][k]=0
ans="No"

for i in range(3):
    if a[0][i]==a[1][i]==a[2][i]==0:ans="Yes"
    if a[i][0]==a[i][1]==a[i][2]==0:ans="Yes"
    if a[0][0]==a[1][1]==a[2][2]==0:ans="Yes"
    if a[2][0]==a[1][1]==a[0][2]==0:ans="Yes"
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
const int N = 2e5+5;

int n, top, stk[N];
double a[N], b[N], tmp[N];
double s[N], s2[N];

void move(double a[], int x){
	rep(i,x,n) tmp[i-x+1] = a[i];
	rep(i,1,x-1) tmp[i+n+1-x] = a[i];
	tmp[n+1] = a[x];
	rep(i,1,n+1) a[i] = tmp[i];
}

double calc(int l, int r){
	if(r<=l+1) return a[r];
	double suma = (r-l-1.0) / (r-l) * a[l] + 1.0/(r-l) * a[r];
	double sumb = 2.0 * (s2[r-1] - (s2[l] + (r-l-1) * s[l]) ) / (r-l);
	return suma - sumb;
}

bool cmp(int l, int m, int r){
	return calc(l, m) < calc(l, r);
}

int main(){
	scanf("%d",&n);
	rep(i,1,n) scanf("%lf", a+i);
	rep(i,1,n) scanf("%lf", b+i);
	
	int maxi = max_element(a+1, a+n+1) - a;
	move(a, maxi);
	move(b, maxi);
	n++;
	
	rep(i,1,n) s[i] = s[i-1] + b[i];
	rep(i,1,n) s2[i] = s2[i-1] + s[i];
	
	stk[top=1] = 1;
	rep(i,2,n){
		while(top>1 && cmp(stk[top-1],stk[top],i)) --top;
		stk[++top] = i;
	}
	for(;top>1;--top){
		int l = stk[top-1], r = stk[top];
		rep(i,l+1,r-1) a[i] = calc(i-1, r);
	}
	
	n--;
	double ans = 0;
	rep(i,1,n) ans += a[i];
	printf("%.10lf", ans/n);
	return 0;
}

Measured memory_bytes: 12372
# C - Forbidden List

x, n = map(int,input().split())
P = list(map(int,input().split()))

t = -100
a = [0]*300
for p in P:
    a[100+p-1] = 1

d = 0
while True:
    if a[100+x-1-d] == 0:
        t = x-d
        break
    elif a[100+x-1+d] == 0:
        t = x + d
        break
    else:
        d += 1

print(t)


Measured memory_bytes: 9176
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define INF 1200000000


int main(){
    
    long long N,K,cnt=0;
    vector<long long> H(200100);
    cin>>N>>K;
    rep(i,0,N){
        cin>>H.at(i);
    }
    
    sort(H.begin(), H.end());
    reverse(H.begin(), H.end());
    
    rep(i,0,N-K){
        cnt+=H.at(K+i);
    }
    
    cout<<cnt<<endl;
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
using namespace std;

int		main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	double N;
	cin >> N;
	cout << ceil(N / 2) << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,l;
    cin>>n>>l;
    string s[n];
    for(int i=0;i<n;i++)cin>>s[i];
    sort(s,s+n);
    for(int i=0;i<n;i++){
        cout<<s[i];
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;


int main() {
	ll X, t;
	cin >> X >> t;
	X = ((X - t) < 0) ? 0 : X - t;
	cout << X << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

struct UnionFind {
    vector<ll> d;

    UnionFind(ll n){
        d = vector<ll>(n,-1);
    }
    
    ll root(ll x){
        if(d[x] < 0) return x;
        return d[x] = root(d[x]);
    }
    
    bool unite(ll x, ll y){
        x = root(x);
        y = root(y);
        if(x == y) return false;
        if(d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    
    bool same(ll x, ll y){
        return root(x) == root(y);
    }
    
    ll size(ll x){
        return -d[root(x)];
    }
};


int main(void)
{
    ll n,m,ans=0;
    cin>>n>>m;
    UnionFind uf(n);
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        a--; b--;
        uf.unite(a,b);
    }
    rep(i,n) ans=max(ans, uf.size(i));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4796
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
int a,b;
cin>>a>>b;
  int ans=0;
  rep(i,a,b+1){
    if(i/10000==i%10&&(i/1000)%10==(i/10)%10){
     // cout<<i<<endl;
      ans++;
    }
  }
  cout<<ans<<endl;
}

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

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

constexpr int INF = (1 << 30) - 1;
constexpr int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
constexpr int dx[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

template < typename T > T gcd(T a, T b) { return ( b ? gcd(b, a % b) : a ); }
template < typename T > T lcm(T a, T b) { return ( a / gcd(a, b) * b ); }

int N, K;
int rui[4005][4005] = {};

void checkR ( int x, int y )
{
	rui[y][x]++;
	rui[y + K][x]--;
	rui[y][x + K]--;
	rui[y + K][x + K]++;
}

int main()
{
	
	cin >> N >> K;
	for ( int i = 0; i < N; i++ ) {
		int x, y;
		char c;
		cin >> x >> y >> c;
		if ( c == 'B' ) {
			x += K;
		}
		x %= (K * 2), y %= (K * 2);
		
		checkR(x, y);
		checkR(x + K, y + K);
	}
	
	for ( int i = 0; i < K * 4; i++ ) {
		for ( int j = 0; j < K * 4; j++ ) {
			if ( i > 0 ) rui[i][j] += rui[i - 1][j];
			if ( j > 0 ) rui[i][j] += rui[i][j - 1];
			if ( i > 0 && j > 0 ) rui[i][j] -= rui[i - 1][j - 1];
		}
	}
	
	for ( int i = 0; i < K * 4; i++ ) {
		for ( int j = 0; j < K * 4; j++ ) {
			int c = rui[i][j];
			rui[i][j] = 0;
			rui[i % (K * 2)][j % (K * 2)] += c;
		}
	}

	int maxv = 0;
	for ( int i = 0; i < K * 2; i++ ) {
		for ( int j = 0; j < K * 2; j++ ) {
			maxv = max(maxv, rui[i][j]);
		}
	}
	
	cout << maxv << endl;

	return ( 0 );
}


Measured memory_bytes: 62848
n = gets.chop.to_i
a = gets.strip.split.map(&:to_i)

flg = true
cnt = 0

while flg
  a.map! do |i|
    if i %2 == 0
      i/2
    else
      flg = false
      i
    end
  end
  cnt = cnt + 1
end

puts cnt - 1


Measured memory_bytes: 1788
D, N = map(int,input().split())

if D == 0 and N != 100:
    print(N)
if D == 0 and N == 100:
    print(101)
if D == 1 and N != 100:
    print(N*100)
if D == 1 and N == 100:
    print(10100)
if D == 2 and N != 100:
    print(N*10000)
if D == 2 and N == 100:
    print(1010000)


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

int main(){
	ll dp[11][1001]={};
	dp[0][0] = 1;
	for(int i=0;i<=100;i++)
		for(int j=9;j>=0;j--)
			for(int k=0;k<=1000;k++){
			if(i+k>1000)break;
			if(dp[j][k]==0)continue;
			dp[j+1][k+i]  +=dp[j][k];
			}
	int n,s;
	while(1){
	cin>>n>>s;
	if(n==0)break;
	cout<<dp[n][s]<<endl;
	}



	return 0;
}



Measured memory_bytes: 3220
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;

template<class T> inline T sqr(T x) {return x*x;}

struct S {
    int a,b;

};

void solve() {
    int n,m;
    cin >> n >> m;
    int a,b;
    vector<S> ss(m);
    VI imos(n+1);
    REP(i,0,m) {
        cin >> a >> b;
        ss[i].a = a - 1;
        ss[i].b = b - 1;
        imos[a-1]++;
        imos[b]--;
    }
    sort(all(ss), [](auto &l, auto &r){
        return l.b == r.b ?  l.a < r.a : l.b < r.b;
    });
    REP(i,1,n) imos[i] += imos[i-1];
    int r = -1, index = -1, ans = 0;
    while (++index < m) {
        if (ss[index].b < r) continue;
        if (ss[index].a < r) continue;
        /*
        dump(ss[index].a);
        dump(ss[index].b);
        dump(r);
        */
        ++ans;
        r = ss[index].b;
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <list>
#include <cmath>
#include <stack>
#include <iomanip>

using namespace std;
typedef long long ll;
using Pll = pair<ll,ll>;

const ll INF = 1LL<<60;
const ll MOD = 998244353;

//cout << fixed << setprecision(10);

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N),B(N);
    for(int i=0;i<N;i++) cin >> A[i];
    priority_queue<Pll> Q;
    for(int i=0;i<N;i++) {
        cin >> B[i];
        if(B[i]!=A[i])Q.push(Pll(B[i],i));
    }
    bool jg=false;
    for(int i=0;i<N;i++) {
        ll tmp;
        if(i==0){
            tmp=B[0]-(B[N-1]+B[1]);
        }
        else if(i==N-1){
            tmp=B[N-1]-(B[0]+B[N-2]);
        }
        else tmp=B[i]-(B[i-1]+B[i+1]);

        if(tmp>=A[i]) {
            jg = true;
        }
    }
    

    if(jg==false){
        cout << "-1" << endl;
        return 0;
    }
    
    ll ans=0;
    ll ct=0;
    while(!Q.empty()){
        Pll tp = Q.top();
        Q.pop();
        ll idx = tp.second;
        ll tmp;
        if(idx==0){
            tmp=(B[N-1]+B[1]);
        }
        else if(idx==N-1){
            tmp=(B[0]+B[N-2]);
        }
        else tmp=(B[idx-1]+B[idx+1]);

        ll m = ((B[idx]-A[idx])/tmp);
        B[idx] = B[idx]-m*tmp;

        ans+=m;
        if(m==0){
            ct++;
        }
        else ct=0;
        if(ct>=N){
            cout << "-1" << endl;
            return 0;
        }
        if(B[idx]!=A[idx]) {
            Q.push(Pll(B[idx],idx));
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 9584
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable long mod = 10L^^9 + 7L;
long n, m;

void main() {
    scan(n, m);

    if (n < m) swap(n, m);

    if (n == m) {
        long ans = 1;

        foreach (i ; 1 .. n + 1) {
            ans *= (1L * i * i) % mod;
            ans %= mod;
        }

        (ans *= 2) %= mod;

        writeln(ans);
    }
    else if (n == m + 1) {
        long ans = 1;

        foreach (i ; 1 .. n) {
            ans *= (1L * i * i) % mod;
            ans %= mod;
        }

        (ans *= n) %= mod;

        writeln(ans);
    }
    else {
        writeln(0);
    }
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+7;
int a[maxn];
int main(){
    int n;
    cin>>n;
    int maxx=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(maxx-a[i]>1){
            cout<<"No\n";
            return 0;
        }
        if(maxx<=a[i]) maxx=a[i];
    }
    cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 640
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = '';
process.stdin.on('data', function(chunk) {
    lines += chunk;
});
process.stdin.on('end', function() {
    main(lines.split(/\r?\n/));
});
function main(inputs){
  var nums = inputs[0].split(" ");
  var num = nums.join("");

  var check = false;
  for(var i=1; i<=1000; i++){
    if(i * i == num){
      console.log("Yes");
      check = true;
      break;
    }
  }

  if(!check){
    console.log("No");
  }

}

Measured memory_bytes: 7500
#gcdは3.4.3だとfractionsにある
from fractions import gcd

from math import factorial as f

from math import ceil,floor,sqrt

from sys import exit

from copy import deepcopy
import numpy as np

import bisect

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))


def main():
    m,d = mi()
    if d < 22:
        print(0)
        exit()
    cnt = 0
    for t in range(4,m+1):
        for i in range(22,d+1):
            if i % 10 == 1 or i % 10 == 0:
                continue
            if (i // 10) * (i % 10) == t:
                cnt += 1

    print(cnt)


main()


Measured memory_bytes: 22932
#include<cstdio>
using namespace std;

int abs(int a){
    if(a<0)return -a;
    return a;
}
int main(void){
    int x,a,b;scanf("%d %d %d",&x,&a,&b);
    if(abs(x-a)>abs(x-b))printf("B\n");
    else printf("A\n");
    return 0;
}


Measured memory_bytes: 128