akhauriyash/Code-Regression huggingface dataset:
// IOI 2021
#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 2e9;
const ll MOD = 998244353;//1e9 + 7;
 
////////////////////////////////////////////////////////////////////

const int N = 1e5 + 5;

int DP[2][N];
vector<int> G[N];

void DFS(int v, int p = 0) {
	for (int u : G[v]) if (u != p) DFS(u, v), DP[0][v] += max(DP[0][u], DP[1][u]);
	for (int u : G[v]) if (u != p) DP[1][v] = max(DP[1][v], DP[0][v] - max(DP[0][u], DP[1][u]) + DP[0][u] + 1);
}

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));

	int n; cin >> n;
	for (int i = 1; i < n; i++) {
		int v, u; cin >> v >> u;
		G[v].push_back(u);
		G[u].push_back(v);
	}
	DFS(1);
	int mx = max(DP[0][1], DP[1][1]);
	if (n % 2 == 0 && 2 * mx == n) cout << "Second" << endl;
	else cout << "First" << endl;

	return 0;
}


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

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

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

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

int main(){
    int N; cin >> N;
    vector<int> A(N,0);
    for(int i=1;i<N;i++){
        int x; cin >> x;x--;
        A[x]++;
    }
    for(int i=0;i<N;i++){
        cout << A[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 4052
#include<iostream>
#include<vector>

using namespace std;

int main()
{
  int N,M,i,count=0,max=0;
  cin >> N >> M;

  if((N > 100) || (M > 100)) return -1;

  vector<double> a(N);
  for(i=0;i<N;i++) {
    cin >> a[i];
    if((a[i] > 1000) || (a[i] < 1)) return -1;
    max = max + a[i];
  }

  for(i=0;i<N;i++){
    if(a[i]*4*M >= max) count = count + 1;
  }

  if(count >= M) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
#define ANS cout<<ans<<'\n'
#define YES cout<<"YES\n"
#define NO cout<<"NO\n"
#define Yes cout<<"Yes\n"
#define No cout<<"No\n"
const ld pi = 3.14159265358979323846;
ll MOD = 1e9 + 7;
//ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans; 
}
void solve()
{
    int i,n,k;
    cin>>n>>k;
    int a[n];
    fo(i,n)
    {
        cin>>a[i];
    }
    ll cost[n];
    cost[0]=0;
    for(i=1;i<n;i++)
    {
        cost[i]=pow(10,9);
    }
    for(i=1;i<min(n,k);i++)
    {
        for(int j=0;j<i;j++)
        {
            cost[i]=min(cost[i],cost[j]+abs(a[i]-a[j]));
        }
    }
    for(i=k;i<n;i++)
    {
        for(int j=i-k;j<i;j++)
        {
            cost[i]=min(cost[i],cost[j]+abs(a[i]-a[j]));
        }
    }
    cout<<cost[n-1]<<nl;

       
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    ll TC = 1;
    //cin>>TC;
    while(TC--){
        solve();
    }
}


Measured memory_bytes: 4836
/*-****************************************-*/

#define USE_CPP11

#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>

#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <bitset>
#ifdef USE_CPP11
# include <unordered_set>
# include <unordered_map>
# include <array>
# include <valarray>
#endif // USE_CPP11

#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>

using namespace std;

/*-****************************************-*/

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

/*-****************************************-*/

#define mp make_pair

#define sz_array(a) (sizeof(a) / sizeof((a)[0]))

#define all(a) (a).begin(),(a).end()
#define r_all(a) (a).rbegin(), (a).rend()

#define exists(container, elem) ((container).find(elem) != (container).end())

/*-****************************************-*/

template<typename T> T MinAssign(T &a, T b) {
    if (a > b)
        a = b;
    return a;
}

template<typename T> T MaxAssign(T &a, T b) {
    if (a < b)
        a = b;
    return a;
}

template<typename T, size_t size> void Fill(void *ptr, T value) {
    fill((T *)ptr, (T *)ptr + size / sizeof(T), value);
}

/*-****************************************-*/

static const double EPS = 1e-10;
static const double PI = acos(-1.0);
static const int INF = 1 << 28;

/*-****************************************-*/

#ifdef DEBUG
#define ANSWER_PREFIX() cout << "[[ Answer ]] "
#else
#define ANSWER_PREFIX()
#endif // DEBUG

/*-****************************************-*/

//////////////////////////////////////////////////
//////////////////////////////////////////////////
//////////////////////////////////////////////////

constexpr int MaxN = 100000 + 10;
int n;
ll A[MaxN], B[MaxN];

int main() {
    cin >> n;

    for (size_t i = 0; i < n; i++) {
        cin >> A[i] >> B[i];
    }

    ll ans = 0;
    for (ll i = n - 1; i >= 0; i--) {
        ll add = B[i] - (A[i] + ans) % B[i];
        if (add == B[i]) {
            add = 0;
        }

        ans += add;
    }

    ANSWER_PREFIX();
    cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();

            long[] L = new long[87];
            L[0] = 2;
            L[1] = 1;
            for (int i = 2; i < L.length; i++) {
                L[i] = L[i - 1] + L[i - 2];
            }

            System.out.println(L[N]);
        }
    }
}


Measured memory_bytes: 27052
#include <bits/stdc++.h>
typedef long long lnt;
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int main() {
	lnt n, m, s = 1;
	read(n), read(m);
	for (lnt i = 2; i*i <= m; i++) {
		lnt c = 0;
		while (m%i == 0)
			m /= i, c++;
		while (c >= n)
			c -= n, s *= i;
	}
	if (n == 1) s *= m;
	return printf("%lld\n", s), 0;
}


Measured memory_bytes: 256
import sys

def main():

    # sys.stdin = open('input153c.txt')

    n, k = map(int, input().split())
    h = list(map(int, input().split()))

    h.sort(reverse=True)
    ans = 0

    for i in range(k, n):
        ans += h[i]

    print(ans)

if __name__ == '__main__':
    main()



Measured memory_bytes: 26180
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}

int main(){
    int a;
    in(a);
    if(a>='a'&&a<='z')out(2);
    else if(a>='A'&&a<='Z')out(1);
    else out(0);
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int n,m,cc,u[N],v[N],hd[N],vv[N],d[N],vis[N];
struct E{int v,nxt;}e[N<<1];
void add(int u,int v){e[++cc]=(E){v,hd[u]};hd[u]=cc;e[++cc]=(E){u,hd[v]};hd[v]=cc;}
void dfs(int x)
{
	vv[x]=1;
	for(int i=hd[x];i;i=e[i].nxt)
	{
		int y=e[i].v;if(vv[y])continue;
		vis[i>>1]=1;dfs(y);
	}
}
void dfs2(int x)
{
	vv[x]=0;
	for(int i=hd[x];i;i=e[i].nxt)
	{
		int y=e[i].v;if(!vv[y])continue;
		dfs2(y);if(!d[y])vis[i>>1]=i&1,d[x]^=1;else vis[i>>1]=(i&1)^1,d[y]^=1;
	}
}
int main()
{
	scanf("%d%d",&n,&m);cc=1;
	if(m&1){puts("-1");return 0;}
	for(int i=1;i<=m;i++){scanf("%d%d",&u[i],&v[i]);add(u[i],v[i]);}
	dfs(1);for(int i=1;i<=m;i++)if(!vis[i])d[u[i]]^=1;dfs2(1);
	for(int i=1;i<=m;i++)if(!vis[i])printf("%d %d\n",u[i],v[i]);else printf("%d %d\n",v[i],u[i]);
	return 0;
}

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

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

	vector<long long> x(N);

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

	long long ans = 300'000'000;

	for (int i = 0; i < N - K + 1; i++)
	{
		long long pos = 0, neg = 0;
		if (x[i] < 0)     neg = -1 * x[i];
		if (x[i + K - 1] > 0) pos = x[i + K - 1];
		long long tmp = neg + pos + min(neg, pos);
		ans = min(tmp, ans);
	}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll n;
  cin >> n;
  cout << "Christmas";
  for (ll i = 25; i > n; i--) {
    cout << " Eve";
  }
  cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int N,i;
    int count = 0;
    scanf("%d",&N);
    for(i = 1 ; i <= N ; i++){
        if(i%2 == 1){
            count++;
        }
    }
    printf("%lf\n",(double)count/N);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin>>n;
	int pre_max;
	cin>>pre_max;
	for(int i = 0; i < n-1; i++) {
		int h;
		cin>>h;
		if(pre_max-h>=2) {
			cout << "No" << endl;
			return 0;
		}
		pre_max = max(pre_max,h);
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 256
a=list(map(int,input().split()))
cnt=0
tmp=[0]*3

while a[0]%2==0 and a[1]%2==0 and a[2]%2==0:
  if a[0]==a[1]==a[2]:
    cnt=-1
    break
  else:
    tmp[0]=a[1]//2+a[2]//2
    tmp[1]=a[0]//2+a[2]//2
    tmp[2]=a[0]//2+a[1]//2
    a[0],a[1],a[2]=tmp[0],tmp[1],tmp[2]
  cnt+=1
print(cnt)

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>>A(H+2,vector<char>(W+2, '#'));
  
  for(int i=1; i<H+1; i++){
    for(int j=1; j<W+1; j++){
      cin >> A.at(i).at(j);
    }
  }
  
  for(int i=0; i<H+2; i++){
    for(int j=0; j<W+2; j++){
      cout << A.at(i).at(j);
    }
    cout << endl;
  }
}


Measured memory_bytes: 3592
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
                      
using namespace std;
                      
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
                      
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}

#define int long long
#define ghost signed
#define left left228
#define right right228
#define prev prev228
#define list list228
#define next next228

const int N = 100 * 1000 + 228;

vector<int> g[N];
int x[N], y[N];
vector<int> xx[N], yy[N];
bool used[N];
vector<int> xc, yc;
int cnt = 0;

void dfs(int v) {
	used[v] = 1;
	++cnt;
	xc.push_back(x[v]);
	yc.push_back(y[v]);
	for (int to : g[v]) {
		if (!used[to]) {
			dfs(to);
		}
	}
}

ghost main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	int n;
	cin >> n;
	int mxx = 0, mxy = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> x[i] >> y[i];
		xx[x[i]].push_back(i);
		yy[y[i]].push_back(i);
		uax(mxx, x[i]), uax(mxy, y[i]);
	}
	for (int X = 1; X <= mxx; ++X) {
		for (int i = 0; i < (int)xx[X].size() - 1; ++i) {
			g[xx[X][i]].push_back(xx[X][i + 1]);
			g[xx[X][i + 1]].push_back(xx[X][i]);
		}
	}
	for (int Y = 1; Y <= mxy; ++Y) {
		for (int i = 0; i < (int)yy[Y].size() - 1; ++i) {
			g[yy[Y][i]].push_back(yy[Y][i + 1]);
			g[yy[Y][i + 1]].push_back(yy[Y][i]);
		}
	}
	int res = 0;
	for (int i = 1; i <= n; ++i) {
		if (!used[i]) {
			xc.clear();
			yc.clear();
			cnt = 0;
			dfs(i);
			sort(xc.begin(), xc.end());
			sort(yc.begin(), yc.end());
			xc.erase(unique(xc.begin(), xc.end()), xc.end());
			yc.erase(unique(yc.begin(), yc.end()), yc.end());
			res += (int)xc.size() * (int)yc.size() - cnt;
		}
	}
	cout << res << '\n';
    return 0;
} // kek;








Measured memory_bytes: 20076
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
long double dp[302][302][302]={};//dp[i][j][k]=3枚ある皿がk種類、2枚ある皿がj種類、1枚ある皿がi種類あるとき、そのすべての皿が無くなるまでの操作回数の期待値
int main(){
	int N;
	scan(N);
	int kosu[4]={};
	rep(i,N){
		int a;
		scan(a);
		kosu[a]++;
	}
	rep(k,N+1){
		rep(j,N+1){
			rep(i,N+1){
				if(i+j+k>0){
					dp[i][j][k]=1;
					if(i!=0){
						dp[i][j][k]+=dp[i-1][j][k]*(long double)i/N;//寿司1個の皿を選ぶ確率=i/N
					}
					if(j!=0){
						dp[i][j][k]+=dp[i+1][j-1][k]*(long double)j/N;
					}
					if(k!=0){
						dp[i][j][k]+=dp[i][j+1][k-1]*(long double)k/N;
					}
					dp[i][j][k]*=(long double)N/(i+j+k);//寿司の乗っている皿を選ぶまでにかかる回数=N/(i+j+k)
				}
			}
		}
	}
	prin(std::setprecision(11)<<dp[kosu[1]][kosu[2]][kosu[3]]);
	return 0;
}


Measured memory_bytes: 430336
#include <iostream>

bool isLeap(int y)
{
	if (y%4 != 0) return false;
	if (y%100 == 0) {
		if (y%400 == 0) return true;
		else return false;
	}
	return true;
}

int main()
{
	int a,b;
	bool first_data = true;
	while (true) {
		std::cin >> a >> b;
		
		if (a==0 && b==0) break;
		
		if (first_data) first_data = false;
		else std::cout << std::endl;
		
		bool exists = false;
		for (int year=a; year<=b; year++) {
			if (isLeap(year)) {
				exists = true;
				std::cout << year << std::endl;
			}
		}
		if (!exists) std::cout << "NA" << std::endl;
		
	}
	return 0;
}

	



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

int N;

int main(){
  
  cin >> N;
  
  if(N % 2) N -= 7;
  while(N > 0){
    if(N % 4) N -= 14;
    else N = 0;
  }
  
  if(N) cout << "No" << endl;
  else  cout << "Yes" << endl;
}

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

using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ldouble = long double;
 
const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


int main()
{
    string n;
    cin >> n;

    ll c = 1;
    ll res = 1;
    for (ll i = 1; i < 4; i++)
    {
        if (n[i] == n[i - 1])
        {
            c++;
        }
        else
        {
            res = max(res, c);
            c = 1;
        }
        
    }
    res = max(res, c);
    println((res >= 3 ? "Yes" : "No"));
}

Measured memory_bytes: 3548
a, b = map(int, input().split())
menor_t, menor_c = 1000, 1000
index = 0
for i in range(a):
    c, t = map(int, input().split())
    if t <= b:
        if c < menor_c:
            menor_c = c
        index = i + 1
if index == 0:
    print('TLE')
else:
    print(menor_c)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <map>
#include <algorithm>
#include <queue>
#include <cstdio>

using namespace std;

int main(){
    string str, strt;
    cin >> str >> strt;
    bool ans = true;
    for(int i=0; i<str.size(); i++){
       if(str[i] != strt[i]){
         ans = false;
       }
    }

    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3624
import sys
from bisect import bisect_left as bi_l
from collections import defaultdict

s, t = sys.stdin.read().split()
l = len(s)
s *= 2

def main():
    for c in t:
        try:
            s.index(c)
        except:
            return -1
    
    d = defaultdict(list)
    for i in range(l*2):
        d[s[i]].append(i)
    
    for c in d:
        d[c].sort()
    
    j = 0
    cnt = 0
    for c in t:
        k = bi_l(d[c], j)
        j = d[c][k]
        if j >= l:
            j -= l
            cnt += 1
        j += 1
    ans = l * cnt + j

    return ans
    
if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 12652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstring>
#include <cstdio>

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main(void){
  LL n, m;
  cin >> n >> m;

  vector<LL> x(m);
  rep(i, m) cin >> x[i];

  if (n >= m) {
    cout << 0 << endl;
    return 0;
  }

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

  vector<LL> diff(m-1);
  rep(i, m-1) diff[i] = x[i+1] - x[i];

  sort(diff.begin(), diff.end(), greater<LL>());

  LL non_visited = 0;
  rep(i, n-1) non_visited += diff[i];

  cout << x[m-1] - x[0] - non_visited << endl;

  return 0;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<map>
using namespace std;
string s;
int l;
bool fc,flag;
int main()
{
	cin>>s;
	l=s.size();
	for(int i=0;i<l;i++)
	{
		if(i==0)
		if(s[i]!='A')
		{
			puts("WA");
			return 0;
		}
		if(s[i]=='C'&&(fc==1||(i==1||i==l-1)))
		{
			puts("WA");
			return 0;
		}
		if(s[i]=='C'&&i>=2&&i<=l-2&&fc==0)
			fc=1;
		if(s[i]!='C'&&s[i]>='A'&&s[i]<='Z'&&i!=0)
		{
			puts("WA");
			return 0;
		}
	}
	if(fc==0)
		puts("WA");
	else
		puts("AC");
	return 0;
}


Measured memory_bytes: 256
X,Y=map(int,input().split())
ans=[]
x=X
y=Y
if x<=y:
    ans.append(y-x)
x*=-1
if x<=y:
    ans.append(y-x+1)
y*=-1
if x<=y:
    ans.append(y-x+2)
x*=-1
if x<=y:
    ans.append(y-x+1)
print(min(ans))


Measured memory_bytes: 38356
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll i;
  ll a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cin>>i;
  cout<<a[i-1];
  return 0;
}

Measured memory_bytes: 256
S = list(input())
front = int(S[0])*10 + int(S[1])
back = int(S[2])*10 + int(S[3])

if 1 <= front and front <= 12 and 1 <= back and back <= 12:
    print("AMBIGUOUS")
elif 1 <= front and front <= 12:
    print("MMYY")
elif 1 <= back and back <= 12:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 3060
people, snack = map(int, input().split())

have_list = [1 for _ in range(people)]

for i in range(snack):
  d = int(input())
  if d == 1:
    person = int(input())
    have_list[person-1] = 0
  else:
    for person in map(int, input().split()):
      have_list[person-1] = 0
      
print(sum(have_list))


Measured memory_bytes: 67584
n = int(input())
alst = list(map(int, input().split()))
divisor_lst = [[0] for _ in range(n)]
ans = []
for i in range(2, n + 1):
    for k in range(i * 2, n + 1, i):
        divisor_lst[k - 1].append(i - 1)
for i in range(n - 1, -1, -1):
    if alst[i] == 1:
        for j in divisor_lst[i]:
            alst[j] += 1
            alst[j] %= 2
        ans.append(i + 1)
print(len(ans))
print(*ans)

Measured memory_bytes: 93900
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;


int main() {
	int n; cin >> n;
	vector<int> x(n), y(n), h(n);
	for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> h[i];
	for (int cx = 0; cx <= 100; cx++) {
		for (int cy = 0; cy <= 100; cy++) {
			int hi = -1;
			bool flag = true;
			for (int i = 0; i < n; i++) {
				if (h[i] == 0) continue;
				int hj = h[i] + abs(cx - x[i]) + abs(cy - y[i]);
				flag &= hi == -1 || hi == hj;
				hi = hj;
			}
			for (int i = 0; i < n; i++) {
				int hj = max(hi - abs(cx - x[i]) - abs(cy - y[i]), 0);
				flag &= h[i] == hj;
			}
			if (flag) {
				cout << cx << " " << cy << " " << hi << endl;
				return 0;
			}
		}
	}

	return 0;
}


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

using ll = long long;
using namespace std;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  for(int i(0);i<N;i++) cin>>A[i];
  int cnt(0);
  for(int i(1);i<N-1;i++){
    if((A[i-1] < A[i] && A[i] < A[i+1]) ||( A[i-1] > A[i] && A[i] > A[i+1])) cnt++;
  }
  cout << cnt << endl;
  return 0;
}


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

int x,y,gx,gy;

int main(){
    cin>>x>>y;
    if(x==2){
        gx=1;
    }else if((x==4)||(x==6)||(x==9)||(x==11)){
        gx=2;
    }else{
        gx=3;
    }

    if(y==2){
        gy=1;
    }else if((y==4)||(y==6)||(y==9)||(y==11)){
        gy=2;
    }else{
        gy=3;
    }

    if(gx==gy){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
using namespace std;
	int h,w;
	int c[10][10];
	int d[10];
	bool used[10];
void dijkstra(int s){
	fill(d,d+10,10000);
	fill(used,used+10,false);
	d[s]=0;
	while(true){
		int v=-1;
		for(int u=0;u<10;u++){
			if((!used[u])&&(v==-1||d[u]<d[v])){v=u;}
		}
		if(v==-1){break;}
		used[v]=true;
		for(int u=0;u<10;++u){
			d[u]=min(d[u],d[v]+c[v][u]);
		}
	}
}
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	cin >>h>>w;
	int a[h][w];
	int ans=0;
	for(int i=0;i<10;++i){
		for(int j=0;j<10;++j){
			cin >>c[j][i];
		}
	}
	dijkstra(1);
	for(int i=0;i<h;++i){
		for(int j=0;j<w;++j){
			cin >>a[i][j];
			if(a[i][j]!=-1){ans+=d[a[i][j]];}
		}
	}
	cout <<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 384
from collections import defaultdict

n, k = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
shukei = defaultdict(int)
# AiからAjまでの和→SA[j]-SA[i-1]
# SA[j]-SA[i-1]=j-(i-1)
# 今回はkで割ったあまりなのでaccumulateは使わず自力
S = [0] * (n + 1)
T = [0] * (n + 1)
for i in range(1, n + 1):
    S[i] = S[i - 1] + A[i - 1]
    S[i] %= k
    T[i] = S[i] - i
    T[i] %= k
# i>=1, i<jで同じ値になっている組み合わせを探せば良い。
# kで割ったあまりなので、要素数j−(i-1)がkより小さくないといけない
ans = 0
if k > n + 1:
    for i in range(n + 1):
        shukei[T[i]] += 1
    for key, num in shukei.items():
        ans += num * (num - 1) // 2
else:
    shukei = defaultdict(int)
    for i in range(k):
        shukei[T[i]] += 1
    for key, num in shukei.items():
        ans += num * (num - 1) // 2
    for i in range(k, n + 1):
        j = i - k
        shukei[T[j]] -= 1
        temp = T[i]
        num = shukei[temp]
        ans += num
        shukei[temp] += 1
print(ans)


Measured memory_bytes: 49000
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.BufferedReader;

public class Main {
	public static void main(String[] args) throws IOException{
		final BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=Integer.parseInt(br.readLine());
		int[][] x=new int[1001][1001];
		int line;
		for(int i=0;i<n;i++){
			line = 0;
			String str1=br.readLine();
			String str2=br.readLine();
			
			for(int j=1;j<=str1.length();j++){
				for(int k=1;k<=str2.length();k++){
					char a=str1.charAt(j-1);
					char b=str2.charAt(k-1);
					if(a==b) x[j][k]=x[j-1][k-1]+1;
					else x[j][k]=Math.max(x[j-1][k],x[j][k-1] );
					line=Math.max(line, x[j][k]);
				}
				
			}
			System.out.println(line);
		}
		br.close();
	}
}

Measured memory_bytes: 26372
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <iostream>
#include <algorithm>
using namespace std;

int main()
{
	int r;
	while(scanf("%d", &r) != EOF)
	{
		if(r < 1200)
			printf("ABC\n");
		else if(r >= 1200 && r < 2800)
			printf("ARC\n");
		else
			printf("AGC\n");
	}
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import heapq

def main():
    N,M = map(int,input().split())
    INF = 10**15
    root = [[] for _ in range(N)]
    for i in range(N-1):
        root[i+1].append((0,i))
    for _ in range(M):
        l,r,c = map(int,input().split())
        root[l-1].append((c,r-1))
    
    dist = [INF for _ in range(N)]
    q = [(0,0)]
    dist[0] = 0
    while q:
        d,now = heapq.heappop(q)
        if dist[now] < d:
            continue
        for cost,fol in root[now]:
            _d = d+cost
            if dist[fol] > _d:
                dist[fol] = _d
                heapq.heappush(q,(_d,fol))

    if dist[-1] == INF:
        print(-1)
    else:
        print(dist[-1])

if __name__ == "__main__":
    main()


Measured memory_bytes: 43900
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();

//		System.out.println("x="+x);
//		System.out.println("y="+y);
//		System.out.println("z="+z);
//
		
		int a = x-z;
//		System.out.println("a="+a);
		
		int sum = a / (y+z);
		System.out.println(sum);
	}

}


Measured memory_bytes: 23124
#include <iostream>
using namespace std;
int main(void){
    int x, y, z;
    int i;
    int cnt = 0;
    
    cin >> x >> y >> z;
    
    i = z;
    while(x >= i){
        i += y + z;
        if(i <= x)   cnt++;
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000






int main(){
	vector<pair<long long, int> >a;
	bool used[N][2];
	int n, k;
	long long x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d", &n);
	f(i, n){
		used[i][0] = false;
		used[i][1] = false;
		scanf("%lld %lld", &x, &y);
		a.push_back(make_pair(x, i));
		a.push_back(make_pair(y, i + n));
	}
	sort(a.begin(), a.end());
	f(i, n){
		ans += a[i].first;
		x = a[i].second;
		if (x < n)used[x][0] = true;
		else used[x - n][1] = true;
	}
	x = 0;
	y = 0;
	z = 0;
	f(i, n){
		if (used[i][0] && used[i][1])z++;
		else if (used[i][0] && !used[i][1])x++;
		else if (used[i][1] && !used[i][0])y++;
	}
	if (z > 0){
		printf("%lld\n", ans);
		return 0;
	}
	if ((x == 0) | (y == 0)){
		printf("%lld\n", ans);
		return 0;
	}
	if (abs(a[n].second - a[n - 1].second) == n){
		x = min(a[n].first - a[n - 2].first, a[n + 1].first - a[n - 1].first);
		ans += x;
	}
	else{
		ans += (a[n].first - a[n - 1].first);
	}

	printf("%lld\n", ans);


	return 0;
}

Measured memory_bytes: 6756
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
#if __cplusplus >= 201103L
#include <chrono>
using namespace std::chrono;
#endif
using namespace std;
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
#ifdef LOCAL
#define prln(x) (cout << #x << ' ' << x << endl)
#define pr(x) (cout << #x << ' ' << x << ' ' )
#define prv(x) (cout << x << ' ')
#else
#define prln(x) 
#define pr(x)
#define prv(x)
#endif
#define clr(x) memset((x), 0, sizeof((x)))
#define clr1(x) memset((x), -1, sizeof((x)))
#define endl "\n"
#define pi acos(-1)
#define rep(i, st, ed) for (int i = (st); i <= (ed); ++i)
#define rep0(i, st, ed) for (int i = (st); i < (ed); ++i)
#define per(i, st, ed) for (int i = (st); i >= ed; --i)
template<class T> void _sf(T &x) {cin >> x;}
void _sf(int &x) {scanf("%d", &x);}
void _sf(ll &x) {scanf("%lld", &x);}
void _sf(double &x) {scanf("%lf", &x);}
void _sf(char &x) {scanf(" %c", &x);}
void _sf(char *x) {scanf("%s", x);}
void sf() {}
template <class T, class...U> void sf(T & head, U&... tail) { _sf(head); sf(tail...);}
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int read() {
    int x = 0, f = 1;
    char ch = getchar();
    while (ch < '0' || ch > '9') {
        if (ch == '-') f = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    return x * f;
}
const int maxn = 15;
vector<int> v[maxn];


int main(){
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
        #if __cplusplus >= 201103L
        auto start = steady_clock::now();
        #endif
    #endif
    int n = read(), d = read();
    rep(i, 1, n) {
        rep(j, 1, d) {
            int x = read();
            v[i].push_back(x);
        }
    }
    int cnt = 0;
    rep(i, 1, n) {
        // int t = 0;
        for (int j = i + 1; j <= n; ++j) {
            int t = 0;
            for (int k = 0; k < d; ++k) {
                t += (v[j][k] - v[i][k]) * (v[j][k] - v[i][k]);
            }
            int temp = sqrt(t);
            if (temp * temp == t) {
                ++cnt;
            }
        }

    }
    cout << cnt << endl;
    #ifdef LOCAL
        #if __cplusplus >= 201103L
        auto end = steady_clock::now();
        duration<double> time_span = duration_cast<duration<double>>(end - start);;
        printf("Total time: %.6fs\n", time_span.count());
        #endif
    #endif
    return 0;
}

Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}
void readC(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=rdsp;foreach(ref v;t)pick(r,v[i]);}}

void main()
{
  int n, l; readV(n, l);
  string[] s; readC(n, s);
  s.sort();
  foreach (si; s) write(si);
  writeln;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.typecons;
import std.numeric, std.math;
import core.bitop;

string FMT_F = "%.10f";

T RD(T = long)() { static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
bool minimize(T)(ref T x, T y) { if (x > y) { x = y; return true; } else { return false; } }
bool maximize(T)(ref T x, T y) { if (x < y) { x = y; return true; } else { return false; } }

long mod = 10^^9 + 7;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto A = RD;
	auto B = RD;
	auto C = RD;

	writeln(min(B / A, C));
	stdout.flush();
}

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

typedef long lint;
typedef long long llint;
typedef pair<int, int> pint;
typedef pair<long long, long long> pllint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const llint INF = 1<<21;
// static const llint MOD = 1e9 + 7;

bool compPair(const pint& arg1, const pint& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

int main(void) {
    int n;
    cin >> n;

    int alxor = 0;
    vector<int> a(n);
    for(int in=0;in<n;in++) {
        cin >> a.at(in);
        alxor ^= a.at(in);
    }

    int ans;
    for(int in=0;in<n;in++) {
        ans = alxor ^ a.at(in);
        cout << ans << " ";
    }
    return 0;
}


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

int main(){
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    int kumi = 0;
    for (int r = 0;r <= N/R;r++){
        for (int g = 0;g <= (N-r*R)/G;g++){
            if ( (N - r*R - g*G)%B == 0){
                kumi++;
            }
        }
    }
    cout << kumi <<endl;
}


Measured memory_bytes: 256
// VABC049_A
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18

int main() {
    // input(sunippets: inpv, inpn, inps)
    char N;
    cin >> N;
    
    // calculation
    if (N == 'a' || N == 'e' || N == 'i' || N == 'o' || N == 'u') {
        cout << "vowel" << "\n";
    } else {
        cout << "consonant" << "\n";
    }
    
    return 0;
}

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

using namespace std;

#define PI acos(-1)

int main(int argc, char *argv[]) {
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    double l = (30 * h) + (0.5 * m);
    double s = (360.0 / 60) * m; 
    double sub = 360 - abs(l - s);
    double ans = 0;
    if (sub == 180) {
        cout << a + b << endl;
    } else if (sub == 0) {
        cout << max(a, b) - min(a, b) << endl;
    } else {
        ans = (a * a) + (b * b) - 2 * (a * b) * cos(sub * (PI / 180.0));
        cout << setprecision(15) << sqrt(ans) << endl;
    }
    return 0;
}


Measured memory_bytes: 4180
#include<bits/stdc++.h>
using namespace std;
int main () {
	int n,ans=1,t;
	cin>>n;
	string s;
	cin>>s;
	t=s[0];
	for (int i=1;i<n;i++) {
		if (t!=s[i]) {
			ans++;
			t=s[i];
		}
	}
	cout<<ans;
}

Measured memory_bytes: 512
#include<stdio.h>
int main(void){
	int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(W>=x+r && H>=y+r && x>0 && y>0)
	printf("Yes\n");
	else
	printf("No\n");
	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int par[100010];
int r(int x){ return (x==par[x])?x:(par[x]=r(par[x])); }
void join(int a, int b){ par[r(a)]=r(b); }

int n;
pp d[100010];
map<int,vector<int>> xp, yp;

typedef tuple<int,int,int> t3;

int main()
{
	read(n);
	for(int i=1; i<=n; ++i) read(d[i].x, d[i].y), xp[d[i].x].pb(i), yp[d[i].y].pb(i);
	
	for(int i=1; i<=n; ++i) par[i]=i;
	ll ans=0;
	
	vector<t3> asdf;
	int bc, bv;
	bc=-1; bv=-1;
	for(auto& tmp:xp){
		auto& v=tmp.second;
		int n=v.size();
		for(int i=1; i<n; ++i) join(v[i-1], v[i]);
		if(bc >= 0){
			int df=tmp.x-bc;
			asdf.eb(df, bv, v[0]);
		}
		bc=tmp.x; bv=v[0];
	}
	
	bc=-1; bv=-1;
	for(auto& tmp:yp){
		auto& v=tmp.second;
		int n=v.size();
		for(int i=1; i<n; ++i) join(v[i-1], v[i]);
		if(bc >= 0){
			int df=tmp.x-bc;
			asdf.eb(df, bv, v[0]);
		}
		bc=tmp.x; bv=v[0];
	}
	
	sort(all(asdf));
	for(auto tmp:asdf){
		int d, a, b;
		tie(d, a, b) = tmp;
		if(r(a) != r(b)){
			ans += d;
			join(a, b);
		}
	}
	
	printf("%lld\n", ans);
	return 0;
}


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

int top,S[1000];

void push(int x){

  top++;
  S[top] = x;
}

int pop(){
  top--;
  return S[top+1];
}



int main(){
  int x,a,b;
  char s[100];
  int top=0;

  while( scanf("%s",s) != EOF ){
    if ( s[0] == '+' ){
      a = pop();
      b = pop();
      push(a + b);
    }
    else if ( s[0] == '-' ){
      a = pop();
      b = pop();
      push(b - a);
    }
    else if ( s[0] == '*' ){
      a = pop();
      b = pop();
      push(a * b);
    }
    else {
      x = atoi(s);
      push(x);
    }
  }

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

  return 0;
}


Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

//約数列挙
//昇順
//#include <vector>
//#include <cmath>
std::vector<long long> div(long long n) {
	std::vector<long long> v(1, 1);
	if (n == 1) return v;
	for (long long i = 2; i <= sqrt(n); i++) {
		if (n % i == 0) v.push_back(i);
	}
	if (sqrt(n) == (long long)sqrt(n)) {
		for (long long i = v.size() - 2; i >= 0; i--) v.push_back(n / v[i]);
	}
	else {
		for (long long i = v.size() - 1; i >= 0; i--) v.push_back(n / v[i]);
	}
	return v;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll n;
	cin >> n;
	vll v = div(n);

	ll ans = 0;
	for (ll i = 0; i < v.size(); i++) {
		ll x = v[i], m = n / v[i] - 1;
		if (x < m) ans += m;
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int a,b,c;
  cin>>a>>b>>c;

  cout<<max({a*10+b+c,a+b*10+c,a+b+c*10})<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

int main()
{
    int n,m;
    int x[100000];
    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++) scanf("%d",&x[i]);
    std::sort(x,x+m);
    int x2[100000]={};
    for(int i=0;i<m-1;i++) x2[i]=x[i+1]-x[i];
    std::sort(x2,x2+m);
    int ans=0;
    for(int i=0;i<m-(n-1);i++) ans+=x2[i];
    printf("%d\n",ans);
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#define ll long long
#define N 200005
#define oo 100000000000000
#define For(i,x,y) for(int i=x;i<=y;i++)
#define Rep(i,x,y) for(int i=x;i>=y;i--)
using namespace std;
inline int read(){
	int x=0,f=0;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-48;
	return f?-x:x;
}
int n,m,a[N];
ll sum[N],ans,all;
int main(){
	n=read();m=read();
	For(i,1,n) a[i]=read();
	For(i,2,n){
		int l=a[i-1],r=a[i];
		if(r<l) r+=m;
		all+=r-l;
		if(r-l>1){
			sum[l+2]++;
			sum[r+1]-=r-l;
			sum[r+2]+=r-l-1;
		}
	}
	For(i,1,m<<1) sum[i]+=sum[i-1];
	For(i,1,m<<1) sum[i]+=sum[i-1];
	For(i,1,m) ans=max(ans,sum[i]+sum[i+m]);
	cout<<all-ans;
	return 0;
}

Measured memory_bytes: 2176
N=int(input())
d4=0
d2=0
for a in input().split():
    if int(a)%4==0:
        d4+=1
    elif int(a)%2==0:
        d2+=1


if N%2==1 and d2==0 and (N-1)//2<=d4:
    print('Yes')
elif 2*d4+d2>=N:
    print('Yes')
else:
    print('No')

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

using namespace std;
long long x[10000010], y[10000010];
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lep(j, n) for (int j = 0; j < (n); j++)
#define reps(i, n) for (int i = 1; i < (n); i++)
#define leps(i, n) for (int j = 1; j < (n); j++)
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define int long long
#define gsort(x, n) sort((x), (x) + (n), greater<int>());
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

signed main()
{

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

   string n;
   cin >> n;

   if (n[0] == n[1] && n[1] == n[2])
      cout << "Yes" << '\n';
   else if (n[1] == n[2] && n[2] == n[3])
      cout << "Yes" << '\n';
   else
      cout << "No" << '\n';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long double PI = acos(-1.0);
// cout << fixed << setprecision(14);

set<int> st[26];
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
 
	int D;
	cin >> D;
	rep(i,26){
		st[i].insert(-1);
		st[i].insert(D);
	}
	int c[26];
	int s[D][26];
	int t[D];
	int ok[26];
	rep(i,26) ok[i] = -1;
	rep(i,26) cin >> c[i];
	rep(i,D){
		rep(j,26){
			cin >> s[i][j];
		}
	}
	rep(i,D){
		cin >> t[i];
		--t[i];
		st[t[i]].insert(i);
	}
	int ans = 0;
	rep(i,D){
		ans += s[i][t[i]];
		ok[t[i]] = i;
		rep(j,26){
			ans -= c[j] * (i-ok[j]);
		}
		// cout << ans << endl;
	}
	int M;
	cin >> M;
	int d[M], q[M];
	rep(i,M){
		cin >> d[i] >> q[i];
		--d[i]; --q[i];
	}
	rep(i,M){
		int _ = t[d[i]]; // コンテストの種類
		t[d[i]] = q[i];
		st[_].erase(d[i]);
		auto itr = st[_].upper_bound(d[i]);
		int W2 = *itr;
		--itr;
		int W1 = *itr; 
		ans -= c[_] * abs(d[i] - W1) * abs(W2 - d[i]);
		auto itr1 = st[q[i]].upper_bound(d[i]);
		int A2 = *itr1;
		--itr1;
		int A1 = *itr1;
		ans += c[q[i]] * abs(d[i] - A1) * abs(A2 - d[i]);
		st[q[i]].insert(d[i]);
		ans += s[d[i]][q[i]] - s[d[i]][_];
		cout << ans << endl;
	}
}

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

int main(){
  set<string> gacha;
  int N;
  string S;
  
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> S;
    gacha.insert(S);
  }
  
  cout << gacha.size() << endl;
}

Measured memory_bytes: 19180
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define chmax(a,b) a=max(a,b);
#define N 100010
struct edge{
  ll to,cost;  
  bool operator<(const edge&key)const{
      return this->cost>key.cost;
  }
};
ll n;
vector<edge> g[N];
ll down[N],up[N];
vector<edge> dtop[N];
void dfs1(ll x,ll p){
    for(edge e:g[x])if(e.to!=p){
	dfs1(e.to,x);
	edge gen; gen.to=e.to;
	gen.cost=down[e.to]+e.cost;
	dtop[x].push_back(gen);
    }
    if(dtop[x].size()==0)down[x]=0;
    else{
	sort(dtop[x].begin(),dtop[x].end());
	down[x]=dtop[x][0].cost;
    }
}
void dfs2(ll x,ll p,ll len){
    if(x==0)up[x]=0;
    else{
	up[x]=up[p]+len;
	for(int i=0;i<min(2,(int)dtop[p].size());i++){
	    if(dtop[p][i].to==x)continue;
	    chmax(up[x],dtop[p][i].cost+len);
	}
    }
    for(edge e:g[x])if(e.to!=p){
	dfs2(e.to,x,e.cost);
    }
}

int main(){
    cin>>n;
    for(int i=0;i<n-1;i++){
	ll a,b,c;cin>>a>>b>>c;
	edge gen;gen.cost=c;
	gen.to=b; g[a].push_back(gen);
	gen.to=a; g[b].push_back(gen);
    }
    dfs1(0,-1);
    dfs2(0,-1,0);
    //for(int i=0;i<n;i++)cout<<i<<":"<<down[i]<<" "<<up[i]<<endl;
    ll ans=0;
    for(int i=0;i<n;i++){
	chmax(ans,down[i]);
	chmax(ans,up[i]);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 26460