akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i ,n) for(int i = 0; i < (int)(n); i++)

int main(){
  int N;
  cin >> N;
  vector<int> idx(N);
  rep(i,N){
    idx.at(i) = i;
  }
  
  vector<pair<double,double>> pos;
  rep(i,N){
    int x,y;
    cin >> x >> y;
    pos.push_back(make_pair(x,y)); 
  }
  
  int cnt = 0;
  double total = 0.0;
  do{
    rep(i,N-1){
      pair<int,int> x = pos[idx[i]];
      pair<int,int> y = pos[idx[i+1]];
      total += pow((pow((x.first-y.first),2.0)+pow((x.second-y.second),2.0)),0.5);
    }
    cnt++;
  }while(next_permutation(idx.begin(),idx.end()));
  printf("%f\n",total/cnt);
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define print_array(ary, size) cout << ary[0]; rep1(i, 1, size - 1) cout << ' ' << ary[i]; cout << endl;
typedef long long ll;
typedef unsigned long long ull;

typedef struct {
	char c;
	int v;
} Card;


Card A[100000];
Card B[100000];

int partition(Card* A, int p, int r)
{
	int x = A[r].v;
	int i = p - 1;
	int tmp;
	char tmpc;

	rep1(j, p, r - 1) {
		if (A[j].v <= x) {
			i++;
			tmp = A[i].v;
			A[i].v = A[j].v;
			A[j].v = tmp;
			tmpc = A[i].c;
			A[i].c = A[j].c;
			A[j].c = tmpc;
		}
	}
	tmp = A[i + 1].v;
	A[i + 1].v = A[r].v;
	A[r].v = tmp;
	tmpc = A[i + 1].c;
	A[i + 1].c = A[r].c;
	A[r].c = tmpc;

	return i + 1;
}

void quicksort(Card* A, int p, int r)
{
	int q;

	if (p < r) {
		q = partition(A, p, r);
		quicksort(A, p, q - 1);
		quicksort(A, q + 1, r);
	}
}

void merge(Card* A, int left, int mid, int right)
{
	int i = 0, j = 0;

	int n1 = mid - left;
	int n2 = right - mid;

	int* L = new int[n1 + 1];
	int* R = new int[n2 + 1];
	char* Lc = new char[n1 + 1];
	char* Rc = new char[n2 + 1];

	rep(i, n1) {
		L[i] = A[left + i].v;
		Lc[i] = A[left + i].c;
	}
	rep(i, n2) {
		R[i] = A[mid + i].v;
		Rc[i] = A[mid + i].c;
	}
	L[n1] = 1000000001;
	R[n2] = 1000000001;

	rep1(k, left, right - 1) {
		if (L[i] <= R[j]) {
			A[k].v = L[i];
			A[k].c = Lc[i];
			i++;
		}
		else {
			A[k].v = R[j];
			A[k].c = Rc[j];
			j++;
		}
	}

	delete[] L, R, Lc, Rc;
}

void mergeSort(Card* A, int left, int right)
{
	int mid;

	if (left + 1 < right) {
		mid = (left + right) / 2;
		mergeSort(A, left, mid);
		mergeSort(A, mid, right);
		merge(A, left, mid, right);
	}
}

int main()
{
	int n;
	bool stable = true;

	cin >> n;
	rep(i, n) {
		cin >> A[i].c >> A[i].v;
		B[i].c = A[i].c;
		B[i].v = A[i].v;
	}

	quicksort(A, 0, n - 1);
	mergeSort(B, 0, n);

	rep(i, n) {
		if ((A[i].c != B[i].c) ||
			(A[i].v != B[i].v)) {
			stable = false;
			break;
		}
	}

	if (stable) cout << "Stable" << endl;
	else cout << "Not stable" << endl;

	rep(i, n) cout << A[i].c << ' ' << A[i].v << endl;

	return 0;
}


Measured memory_bytes: 17724
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] A = new int[N];
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
        }
        sc.close();
        long[] s = new long[N];
        s[0] = A[0];
        for(int i = 1; i < N; i++){
            s[i] = s[i-1] + A[i];
        }
        Map<Long, Integer> map = new HashMap<>();

        long count = 0;

        for(int i = 0; i < N; i++){
            if(map.containsKey(s[i]))
                map.put(s[i], map.get(s[i])+1);
            else
                map.put(s[i], 1);
        }

        for(int i = 0; i < N; i++){
            if(s[i] == 0)
                count++;
        }
        for(Long key: map.keySet()){
            long v = map.get(key);
            if(v >= 2){
                count+= v*(v-1)/2;
            }
        }

        System.out.println(count);
    }
}

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

string s;
int cnt[111111];

int main(void)
{
	cin.tie(NULL);
	cout.tie(NULL);
	ios_base::sync_with_stdio(false);

	int i, point;

	cin >> s;

	for (i = 0; i < s.size(); i++)
		if (s[i] == 'L')
			cnt[point + (i - point) % 2]++;
		else
			point = i;

	for (i = s.size() - 1; i >= 0; i--)
		if (s[i] == 'R')
			cnt[point - (point - i) % 2]++;
		else
			point = i;

	for (i = 0; i < s.size(); i++)
		cout << cnt[i] << " ";
	return 0;
}

Measured memory_bytes: 1104
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
using namespace std;

void solve(){
  string s; cin >> s;
  int n = s.size();
  for(int i = 0; i < n; i++){
    if(s[i] == '9'){
      cout << "Yes\n";
      return;
    }
  }
  cout << "No\n";
  return;
}

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


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 998244353;
const ll INF = (ll) 1e15;

ll modpow(ll n, ll r) {
    ll ret = 1;
    ll p = n;
    while (r > 0) {
        if (r & 1)
            ret = (ret * p) % MOD;
        p = (p * p) % MOD;
        r /= 2;
    }
    return ret;
}

ll P[200005];

ll sum(ll a, ll n) {
    ll ret = a * P[n] % MOD;
    return ret;
}

pll op(pll a, pll b) {
    ll p = (a.first * modpow(10LL, b.second) % MOD + b.first) % MOD;

    return pll(p, a.second + b.second);
}

pll e() { return pll(0, 0); }

pll mapping(ll a, pll b) {
    if (a == 0) {
        return b;
    }
    return pll(sum(a, b.second), b.second);
}

ll comp(ll a, ll b) {
    if (a == 0)
        return b;
    return a;
}

ll id() { return 0; }

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

    ll N, Q;
    cin >> N >> Q;
    P[0] = 0;
    REP(i, N + 2) {
        P[i + 1] = (P[i] * 10LL + 1) % MOD;
    }
    vector<pll> A(N);
    REP(i, N) {
        A[i] = pll(1, 1);
    }
    atcoder::lazy_segtree<pll, op, e, ll, mapping, comp, id> seg(A);
    REP(_, Q) {
        ll L, R, D;
        cin >> L >> R >> D;
        seg.apply(L - 1, R, D);
        cout << seg.prod(0, N).first << endl;
    }

    return 0;
}

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


class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i


N, Q = map(int, input().split())
c = list(map(int, input().split()))

lr = []
for i in range(Q):
    l, r = map(int, input().split())
    lr.append([l, r, i])

lr.sort(key=lambda x: x[1])
# print("lr", lr)
rightest = [-1] * (N + 1)
current_q = 0
bit = Bit(N)
ans = [0] * Q

for i in range(N):
    if rightest[c[i]] != -1:
        bit.add(rightest[c[i]] + 1, -1)
    rightest[c[i]] = i
    bit.add(i + 1, 1)
    # print(bit.tree)

    while current_q < Q and lr[current_q][1] == i + 1:
        ans[lr[current_q][2]] = bit.sum(lr[current_q][1]) - bit.sum(lr[current_q][0] - 1)
        current_q += 1

for i in range(Q):
    print(ans[i])


Measured memory_bytes: 226740
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl

//-----
void ini(string s, int p[], int dp[]) {
	int t = -1; p[0] = dp[0] = -1;
	rep(i, 1, sz(s)) {
		while (~t && s[t + 1] != s[i]) t = p[t];
		p[i] = t += (s[t + 1] == s[i]);
		if (p[i] + 1 == i - p[i] || dp[p[i]] == i - p[i]) dp[i] = i - p[i];
		else dp[i] = -1;
	}
}
const int N = 5e5 + 7;
int p1[N], p2[N], d1[N], d2[N];
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
  string s1; cin >> s1;
  string s2; s2 = s1; reverse(all(s2));
  ini(s1, p1, d1);
  ini(s2, p2, d2);
	if (!~d1[sz(s1) - 1]) { cout << "1\n1"; return 0; }
	int ans = 0;
	rep(i, 0, sz(s1) - 1) if (!~d1[i] && !~d2[sz(s1) - i - 2]) ans++;
	if (ans) cout << 2 << endl << ans;
	else cout << sz(s1) << endl << 1;
	return 0;
}

Measured memory_bytes: 9524
h, n = map(int, input().split())
magics = [list(map(int, input().split())) for _ in range(n)]
max_damage = max(a for a, b in magics)
dp = [0] * (h + max_damage)
for i in range(1, h + max_damage):
    dp[i] = min(dp[i - a] + b for a, b in magics)
print(dp[h])

Measured memory_bytes: 3664
#include <stdio.h>

const int DIV = 998244353;

int             max(int a, int b)
{
        if (a >= b)
        {
                return (a);
        }
        else
        {
                return (b);
        }
}

int             main(void)
{
        int n;
        int k;
        int lr[10][2] = {0};
        int dp[200001] = {0};
        int sdp[200001] = {0};
        int i, j;

        scanf("%d%d", &n, &k);
        for (i = 0; i < k; i++)
        {
                scanf("%d%d", &lr[i][0], &lr[i][1]);
        }
        dp[1] = 1;
        sdp[2] = 1;
        for (i = 2; i <= n; i++)
        {
                for (j = 0; j < k; j++)
                {
                        dp[i] += (DIV + sdp[max(1, i - lr[j][0] + 1)] - sdp[max(1, i - lr[j][1])]) % DIV;
                        dp[i] = dp[i] % DIV;
                }
                sdp[i + 1] += (sdp[i] + dp[i]) % DIV;
        }
        printf("%d\n", dp[n]);
        return (0);
}

Measured memory_bytes: 3292
using System;


class AOJ
{
    public static void Main()
    {
        int w = int.Parse(Console.ReadLine());
        int[] a = new int[w];

        for (int i = 0; i < w; i++)
        {
            a[i] = i + 1;
        }
               
        int n = int.Parse(Console.ReadLine());
        int[] b = new int[2];
        int tmp;

        for (int i = 0; i < n; i++)
        {
            string[] ss = Console.ReadLine().Split(',');
            b[0] = int.Parse(ss[0]);
            b[1] = int.Parse(ss[1]);

            tmp = a[b[0]-1];
            a[b[0]-1] = a[b[1]-1];
            a[b[1]-1] = tmp;
        }

        for (int i = 0; i < w; i++)
        {
            Console.WriteLine(a[i]);
        }
    }
}

Measured memory_bytes: 5600
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
// #include <bits/stdc++.h> all

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

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

  int ans = 0;
  for(int i = 0; i < n; i++){
    int temp; cin >> temp;
    if(temp >= k){
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

int main() {
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for (int i = l; i <= r; i++) {
        if (i % d == 0) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3588
#include<stdio.h>
 
int main(){
  	char s1[4],s2[4];
  	while(~scanf("%s%s",s1,s2)){
      	int same = 0;
    	for(int i = 0;i < 3;i++)
          if(s1[i] == s2[i]) same++;
      	printf("%d\n",same);
    }
	return 0;
}

Measured memory_bytes: 128
package main

import (
  "fmt"
)

func main() {
 
  var n , a ,b int
  fmt.Scan(&n,&a,&b)
  if n == 2 {
    fmt.Printf("Borys")
  }else {
    if (b-a) %2 ==1 {
      fmt.Printf("Borys")
    } else {
     fmt.Printf("Alice")
    }
  }
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	std::string S;
	in >> S;

	bool ans = false;
	if (S[0] == S[1]) ans = true;
	if (S[1] == S[2]) ans = true;
	if (S[2] == S[3]) ans = true;
	out << (ans ? "Bad" : "Good") << std::endl;
}


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

using ll = long long;

ll dp[3010][3010][3];
ll v[3010][3010];

void renderv(int r,int c)
{
    for(int i=1;i<=r;i++)
    {
        for(int j=1;j<=c;j++)cout<<v[i][j]<<",";
        cout<<"\n";
    }
}

void render(int r,int c)
{
    for(int i=1;i<=r;i++)
    {
        for(int j=1;j<=c;j++)cout<<dp[i][j][0]<<","<<dp[i][j][1]<<","<<dp[i][j][2]<<","<<"|";
        cout<<"\n";
    }
}

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

    int r,c,k;cin>>r>>c>>k;

    for(int i=0;i<k;i++)
    {
        int ir,ic,iv;cin>>ir>>ic>>iv;
        v[ir][ic]=iv;
    }

    for(int i=1;i<=r;i++)
    {
        ll m0=0,m1=0,m2=0;
        for(int j=1;j<=c;j++)
        {
            dp[i][j][0]=max(max(max(dp[i-1][j][0],dp[i-1][j][1]),dp[i-1][j][2])+v[i][j],m0);
            if(j>=2)dp[i][j][1]=max(m0+v[i][j],m1);
            if(j>=3)dp[i][j][2]=max(m1+v[i][j],m2);
            m0=max(m0,dp[i][j][0]);
            m1=max(m1,dp[i][j][1]);
            m2=max(m2,dp[i][j][2]);
        }
    }

    // renderv(r,c);
    // render(r,c);

    ll ans=max(max(dp[r][c][0],dp[r][c][1]),dp[r][c][2]);

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 285760
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;cin >> N;
    vector<int> A(100);
    int B = 0;
    vector<int> C(100);
    for(int i = 0;i < N;i++){
        cin >> A.at(i);
    }
    for(int i = 0;i < N;i++){
        int b = 0;
        cin >> b;
        B += b;
    }
    for(int i = 0;i < N-1;i++){
        cin >> C.at(i);
    }
    for(int i = 0;i < N;i++){
        int a = A.at(i) + 1;
        int b = A.at(i+1);
        if(a == b){
            B += C.at(A.at(i)-1);
        }
    }
    cout << B << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
//#include "toollib.h"
#pragma warning (disable:4018)
#define INT_MAX 2147483647

using namespace std;

int main() {
	struct item {
		int value;
		int weight;
		bool operator<(const item & another) const {
			if (weight != another.weight) return weight < another.weight;
			else return value < another.value;
		}
	};
	int N, W;
	cin >> N >> W;
	vector<item> items(N);
	for (int i = 0; i < N; i++) {
		cin >> items[i].value >> items[i].weight;
	}
	sort(items.begin(), items.end());
	vector<vector<int>> dp(N + 1, vector<int>(W + 1, 0));
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= W; j++) {
			if (j - items[i - 1].weight >= 0) dp[i][j] = max(dp[i - 1][j - items[i - 1].weight] + items[i - 1].value, dp[i - 1][j]);
			else dp[i][j] = dp[i - 1][j];
		}
	}
	cout << dp[N][W] << endl;
	return 0;
}

Measured memory_bytes: 6804
#include <bits/stdc++.h>
using namespace std;
double dp[4000][4000];
double P[4000];
int main(){
    int N; cin >> N;
    for(int i=0; i<N; ++i){
        double p;
        cin >> p;
        P[i] = p;
    }
    dp[0][0] = 1.0;
    //i番目のコインを振ってj個表が出た状態からi+1個目のコインを振る
    for(int i=0; i<N; ++i){
        for(int j=0; j<=i; ++j){
            dp[i+1][j+1] += P[i]*dp[i][j];
            dp[i+1][j] += (1.0-P[i]) * dp[i][j]; 
        }
    }
    double res = 0;
    for(int j=N/2+1; j<=N; ++j){
        res += dp[N][j];
    }
    cout << setprecision(10) << res << endl;
    return 0;
}

Measured memory_bytes: 92672
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(),(a).end()

using namespace std;

int main(int argc, char const *argv[]) {
    int A,B,C;
    scanf("%d%d%d",&A,&B,&C);
    if(A==B && B==C){
        printf("1\n");
    }else if(A==B || B==C ||C==A){
        printf("2\n");
    }else{
        printf("3\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 1000000000000000LL
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long n,i,a[100005],b[100005],sum,ans;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read();
	for(i=0;i<=n;i++)
		a[i]=read();
	sum=1;
	for(i=0;i<=n;i++)
		b[i]=maxn;
	for(i=0;i<=n;i++){
		b[i]=sum;
		if(sum<a[i]){
			pus(-1,2);
			return 0;
		}
		sum-=a[i];
		sum<<=1;
		if(sum>=maxn)
			break;
	}
	sum=0;
	for(i=n;i>=0;i--){
		sum+=a[i];
		if(sum>b[i])
			sum=b[i];
		ans+=sum;
	}
	pus(ans,2);
    return 0;
}

Measured memory_bytes: 5200
#include <bits/stdc++.h>
using namespace std;
// typedef
using ll  = long long;
using str = string;
using PL  = pair<ll, ll>;
using P   = pair<int, int>;
using VL  = vector<ll>;
using VI  = vector<int>;
using VS  = vector<str>;
using VP  = vector<P>;
using VPL = vector<PL>;
using VVL = vector<VL>;
using VVI = vector<VI>;

// const num
const ll INF         = 1e18 + 18;
const ll MAX         = 100005;
const ll MOD         = 1000000007;
const long double PI = acosl(-1.0);

// loop
#define REP(i, a, b) for(ll(i) = (a); (i) < (b); (i)++)
#define RREP(i, a, b) for(ll(i) = (a); (i) >= (b); (i)--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)

// YesNo
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
// All
#define ALL(v) v.begin(), v.end()
#define deduplicate(v) (v).erase(unique(ALL(d)), (v).end())

int main(void) {
	int n;
	cin >> n;
	VI p(n), q(n);
	rep(i, n) {
		cin >> p[i];
	}
	rep(i, n) {
		cin >> q[i];
	}
	VI cp, cq;
	cp = p;
	cq = q;
	sort(ALL(cp));
	sort(ALL(cq));
	int a = 1;
	int b = 1;
	do {
		if(cp == p) {
			break;
		}
		a++;
	} while(next_permutation(ALL(cp)));
	do {
		if(cq == q) {
			break;
		}
		b++;
	} while(next_permutation(ALL(cq)));
	cout << abs(a - b) << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#include <vector>
using namespace std;
int n, a, b, c;
int main(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a >> b >> c;
		if(a*a == b*b + c*c || b*b == a*a + c*c || c*c == a*a + b*b){
			cout << "YES\n";
		}
		else
			cout << "NO\n";
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define int long long

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

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

#define REP(i, a, b) for(int i = a; i <= b; ++i)
#define DEC(i, a, b) for(int i = a; i >= b; --i)
#define getmid(l,r) ((l) + ((r) - (l)) / 2)
#define MEM(a,b) memset(a,b,sizeof(a))
#define FI first
#define SE second
#define SZ(x) ((int)(x).size())
#define MP make_pair
#define PB push_back
 
typedef long long ll;
typedef pair<int,int> pii;
const int mod = 1000000007;

int N, T, A;
vector<int> G[100010];
int da[100010], son[100010];
int ans;

void Dfs(int p, int pre, int len, int d[]){
    d[p] = len;
    REP(i, 0, SZ(G[p]) - 1){
        int v = G[p][i];
        if(v == pre) continue;
        Dfs(v, p, len + 1, d);
        son[p] = 1;
    }
}

void Dfs2(int p, int pre, int len){
    //cout << "p : " << p << endl;
    if(len > da[p]) return;
    REP(i, 0, SZ(G[p]) - 1){
        int v = G[p][i];
        if(v == pre) continue;
        Dfs2(v, p, len + 1);
    }
    if(son[p]) ans = max(ans, da[p]);
}

int main(){
    ios_base::sync_with_stdio(false);
	cin >> N >> T >> A;
    REP(i, 1, N - 1){
        int a, b;
        cin >> a >> b;
        G[a].PB(b);
        G[b].PB(a);
    }
    Dfs(A, -1, 0, da);
    Dfs2(T, -1, 0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12928
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import math

A,B,C,D = map(int,input().split())

cnt = 0
for i in range(101):
    if A<i<=B and C< i <= D:
        cnt += 1

print(cnt)


Measured memory_bytes: 5104
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int L[2000][2000], R[2000][2000];
int U[2000][2000], D[2000][2000];

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int h,w;
  cin >> h >> w;
  vector<string> field(h);
  REP(i,h) cin >> field[i];
  
  REP(i,h){
    REP(j,w){
      if(field[i][j]=='#') continue;
      if(j==0) L[i][j] = 1;
      else L[i][j] = L[i][j-1] + 1;
      if(i==0) U[i][j] = 1;
      else U[i][j] = U[i-1][j] + 1;
    }
  }
  REPR(i,h-1){
    REPR(j,w-1){
      if(field[i][j]=='#') continue;
      if(j==w-1) R[i][j] = 1;
      else R[i][j] = R[i][j+1] + 1;
      if(i==h-1) D[i][j] = 1;
      else D[i][j] = D[i+1][j] + 1;
    }
  }

  int ans = 0;
  REP(i,h) REP(j,w){
    ans = max(ans, L[i][j]+R[i][j]+U[i][j]+D[i][j]-3);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 67072
#include <bits/stdc++.h>
using namespace std;
int n,a[405];
long long s[405],dp[405][405];
int main(){
	scanf("%d",&n);
	memset(dp,0x3f,sizeof(dp));
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),dp[i][i]=0;
	for (int i=1;i<=n;i++) s[i]=a[i]+s[i-1];
	for (int i=1;i<=n;i++){
		for (int l=1,r=i;r<=n;l++,r++)
			for (int j=l;j<r;j++)
				dp[l][r]=min(dp[l][r],dp[l][j]+dp[j+1][r]+s[r]-s[l-1]);
	} 
	printf("%lld",dp[1][n]);
}

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

using namespace std;

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

int main(){
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int r = 0;
  r += 1 * min(k, a);
  k -= min(k, a);
  r += 0 * min(k, b);
  k -= min(k, b);
  r += -1 * min(k, c);
  k -= min(k, c);
  cout << r << endl;
  return 0;
}

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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define pb emplace_back
#define ll long long

const int INF = 2e9 + 1;
const ll INFLL = 1e18 + 1;
const ll mod = 1e9 + 7;

vector<vector<int>> g, g1;
vector<int> usd;

void dfs(int v, vector<int> &now) {
    now.pb(v);
    usd[v] = 1;
    for (auto &to : g[v]) {
        if (!usd[to]) dfs(to, now);
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    g.resize(n);
    g1.resize(n);
    usd.resize(n);
    while (m--) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    while (k--) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g1[a].pb(b); g1[b].pb(a);
    }
    vector<int> id(n);
    vector<int> sz;
    int cur = 0;
    for (int i = 0; i < n; i++) {
        if (usd[i]) continue;
        vector<int> now;
        dfs(i, now);
        sz.pb(now.size());
        for (auto &v : now) id[v] = cur;
        cur++;
    }
    vector<int> ans(n);
    for (int i = 0; i < n; i++) ans[i] = sz[id[i]] - 1;
    for (int i = 0; i < n; i++) {
        for (auto &to : g1[i]) {
            if (id[i] == id[to]) ans[i]--;
        }
    }
    for (int i = 0; i < n; i++) {
        for (auto &to : g[i]) {
            if (id[i] == id[to]) ans[i]--;
        }
    }
    for (auto &c : ans) cout << c << " ";
    return 0;
}


Measured memory_bytes: 16000
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int h, w;
  cin >> h >> w;

  string s[h];
  REP(i,h){
    cin >> s[i];
  }

  REP(i,w + 2){
    cout << "#";
  }
  cout << "\n";

  REP(i,h){
    cout << "#" << s[i] << "#\n";
  }

  REP(i,w + 2){
    cout << "#";
  }
  cout << "\n";
  return 0;
}



Measured memory_bytes: 764
lst = []
for i in range(5):
  n = int(input())
  lst.append([(n - 1) % 10, n])
lst = sorted(lst)

res = 0
for i in range(5):
  if i == 0:
    res += lst[i][1]
  else:
    res += (lst[i][1] + 9) // 10 * 10
print(res)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
const ll mod=1e9+7;
template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
const ll N=1e6+8;
ll dp[N],k;
ll a[N];
int main(){
	ll n;
	cin>>n;
	cin>>k;
	for(ll i=1;i<=n;i++){
		cin>>a[i];
	}
	for(ll i=0;i<N;i++)
	dp[i]=INT_MAX;
	dp[1]=0;
   for(ll i=1;i<n;i++){
   	for(ll j=i+1;j<=i+k;j++){
   		if(j<=n)
   		dp[j]=min(dp[j],dp[i]+abs(a[j]-a[i]));
   		//cout<<dp[j]<<endl;
	   }
   }
   cout<<dp[n]<<endl;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for (int i = (a); i <= (b); ++i)
#define REPD(i,a,b) for (int i = (a); i >= (b); --i)
#define FORI(i,n) REP(i,1,n)
#define FOR(i,n) REP(i,0,int(n)-1)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define SZ(x) int((x).size())
#define DBG(v) cerr << #v << " = " << (v) << endl;
#define FOREACH(i,t) for (typeof(t.begin()) i=t.begin(); i!=t.end(); i++)
#define fi first
#define se second

char s[100100];

void test() {
	int n;
	scanf("%s", s);
	for (n=0; s[n]; n++) ;
	int cnt=0;
	FOR(i,n) if (s[i+1] != s[i]) cnt++;
	printf("%d\n", cnt-1);
}

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


Measured memory_bytes: 384
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

#ifdef LOCAL
    #define LLD_SPEC "%lld"
#else
    #define LLD_SPEC "%I64d"
#endif

int main() {
    int n;
    scanf("%d", &n);
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }

    int result = 1e9;
    for (int i = -100; i <= 100; ++i) {
        int cost = 0;
        for (int j = 0; j < n; ++j) {
            cost += (i - a[j]) * (i - a[j]);
        }
        result = min(result, cost);
    }

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

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1 << 20;

typedef long long ll;




int main(){
  string s,t,u;
  cin >> s >> t >> u;
  cout << s[0] << t[1] << u[2] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000 //1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
  cout << H << " ";
  debug_out(T...);
}

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;

// const
// 円周率
const double pi = M_PI;
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)

int main()
{
  // faster
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll xsize,ysize,x,y; cin >> xsize >> ysize >> x >> y;
  cout << fixed << setprecision(15) << xsize*ysize*0.5;
  if(2*x==xsize and 2*y==ysize)
    cout << " " <<  1;
  else
    cout << " " <<  0;
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
use scanner::Scanner;

fn main() {
    let mut sc = Scanner::new();
    let h:usize = sc.read();
    let _w:usize = sc.read();
    let ss: Vec<String> = (0..h).map(|_| sc.read()).collect();

    for s in ss {
        println!("{}", s);
        println!("{}", s);
    }

}

mod scanner {
    pub struct Scanner<'a> {
        s: String,
        words: ::std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new() -> Scanner<'a> {
            let s = String::new();
            let words = unsafe { ::std::mem::transmute(s.split_whitespace()) };
            Scanner { s: s, words: words }
        }

        pub fn read<T: ::std::str::FromStr>(&mut self) -> T {
            match self.words.next() {
                Some(x) => x.parse().ok().unwrap(),
                None => {
                    self.load();
                    self.read()
                }
            }
        }

        fn load(&mut self) {
            self.s.clear();
            ::std::io::stdin().read_line(&mut self.s).unwrap();
            self.words = unsafe { ::std::mem::transmute(self.s.split_whitespace()) };
        }
    }
}

Measured memory_bytes: 4352
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <functional>
using namespace std;
using ll = long long;

int main() {
	ll W, a, b, d;
	cin >> W >> a >> b;
	d = (abs(a - b) <= W) ? 0 : abs(a - b) - W;
	cout << d << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using namespace std;
using P = pair<int,int>;
typedef long long ll;

int  main()
{
	int n; cin >> n;
	int even = n / 2;
	double ans = (double)even / n;
	printf("%f", 1 - ans);
	return (0);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
  	cin>>n;
  	int a[n+1],b[n];
  	for(int i=0;i<=n;i++){
      cin>>a[i];
    }
  long long int ans=0;
  	for(int i=0;i<n;i++){
		cin>>b[i];
      	if(b[i]>=a[i]){
          	ans+=a[i];
          	b[i]-=a[i];
          	a[i]=0;
        }
        else{
            ans+=b[i];
            a[i]-=b[i];
            b[i]=0;
        }
      	if(b[i]>=a[i+1]){
          ans+=a[i+1];
          b[i]-=a[i+1];
          a[i+1]=0;
        }
      	else{
          ans+=(b[i]);
          a[i+1]-=b[i];
          b[i]=0;
        }
          	
    }
  cout<<ans<<endl;
  return 0;
}
  	
  

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
const ll mod = 1e9+7;
ll power(ll a, ll b, ll m = mod) {
    ll x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
 
mt19937_64 gen (random_device{}());
ll rint(ll a, ll b) { // generate rand int in [a, b]
    return a + gen() % (b - a + 1);
}

const int N = 2e5+9;
signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

    int n; cin >> n;
    int k = 1;
    while(1ll * k * (k+1) / 2 < (long long) n) k++;
    if(k * (k+1) / 2 != n) {
        cout << "No\n";
        return 0;
    }
    cout << "Yes\n";
    k++;
    int c = 1;
    vector<vector<int>> g(k+1);
    for(int i = 1; i <= k; i++) {
        for(int j = i+1; j <= k; j++) {
            g[i].push_back(c);
            g[j].push_back(c);
            c++;
        }
    }
    cout << k << "\n";
    for(int i = 1; i <= k; i++) {
        cout << g[i].size() << " ";
        for(int x: g[i]) cout << x << " ";
        cout << "\n";
    }


    return 0;
    
}

Measured memory_bytes: 2304
#include<iostream>
#include<cstdio>
using namespace std;
inline 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;
}
int main()
{
	cout<<read()/3;
	return 0;
}



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

using namespace std;

int main()
{
 	int x; cin>>x;
  	int f, l, fv;
  	f = x / 500;
  	l = x - (f * 500);
  	fv = l / 5;
  	cout<< f * 1000 + fv * 5<<endl;
}

Measured memory_bytes: 256
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


class BinaryIndexedTree:
    # http://hos.ac/slides/20140319_bit.pdf
    def __init__(self, size):
        """
        :param int size:
        """
        self._bit = [0] * size
        self._size = size

    def add(self, i, w):
        """
        i 番目に w を加える
        :param int i:
        :param int w:
        :return:
        """
        x = i + 1
        while x <= self._size:
            self._bit[x - 1] += w
            x += x & -x

    def sum(self, i):
        """
        0 番目から i 番目までの合計
        :param int i:
        :return:
        """
        ret = 0
        x = i + 1
        while x > 0:
            ret += self._bit[x - 1]
            x -= x & -x
        return ret

    def __len__(self):
        return self._size


def count_inversions(li, max=None):
    if not max:
        max = __builtins__.max(li)
    bit = BinaryIndexedTree(size=max + 1)
    ret = 0
    for i in range(len(li)):
        ret += i - bit.sum(li[i])
        bit.add(li[i], 1)
    return ret


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

bit = BinaryIndexedTree(size=2001)
invs = []
for i, a in enumerate(A):
    invs.append(i - bit.sum(a))
    bit.add(a, 1)
ans = 0
for i, a in enumerate(A):
    rem = N - bit.sum(a)
    ans += K * (2 * invs[i] + (K - 1) * rem) // 2
    ans %= MOD
print(ans)



Measured memory_bytes: 41584
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
using namespace std;

int main() {
	
	long long A;
	long long B;
	cin >> A;
	cin >> B;

	if (0 == (A - B) % 2) {
		long long K = (A + B) / 2;
		cout << K << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) begin(c), end(c)
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6+6;


int main(){
	//freopen("input.txt","r",stdin); //freopen("output.txt","w",stdout);
	ios::sync_with_stdio(0);cin.tie(0);//cout.precision(12);cout<<fixed;
	
	ll x,k,d;
	cin>>x>>k>>d;
	
	x = abs(x);
	
	ll h = x / d;
	
	if(h>=k){
		cout<<x-k*d<<endl;
		return 0;
	}
	
	ll y = x-h*d;
	
	k-=h;
	
	if(k&1) y-=d;
	
	cout<<abs(y)<<endl;
	
	
	
	return 0;
}


Measured memory_bytes: 3652
N, K, Q = map(int, input().split())
A = [int(input()) for _ in range(Q)]
answer = [0]*N

for i in range(Q):
    answer[A[i]-1] += 1

for i in range(N):
    if K-Q+answer[i] > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 8632
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	if s[0] != 'A' {
		fmt.Println("WA")
		return
	}

	flagLargeC := 0
	for i := 2; i < len(s)-1; i++ {
		if s[i] == 'C' {
			flagLargeC++
		}
	}
	if flagLargeC != 1 {
		fmt.Println("WA")
		return
	}

	flagCapital := 0
	for i := range s {
		if s[i] >= 65 && s[i] <= 90 {
			flagCapital++
		}
	}
	if flagCapital != 2 {
		fmt.Println("WA")
		return
	}

	fmt.Println("AC")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <unordered_set>
#include <random>
using namespace std;
#define ll long long
#define fr first
#define sc second
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()

ll Apsum[220000];
ll Bpsum[220000];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N, M, K; cin >> N >> M >> K;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		Apsum[i + 1] = Apsum[i] + a;
	}
	for (int i = 0; i < M; i++) {
		int a; cin >> a;
		Bpsum[i + 1] = Bpsum[i] + a;
	}

	int ans = 0;
	for (int i = 0; i <= N; i++) { //i: A에서 고른 책의 개수
		ll canread = K - Apsum[i];
		if (canread < 0) continue;

		int idx = upper_bound(Bpsum, Bpsum + M + 1, canread) - Bpsum;
		idx--;
		if (idx < 0) continue;
		ans = max(ans, i + idx);
//		cout << i << ' ' << idx << '\n';
	}
	cout << ans << '\n';
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> D(N + 100);
  for (int i; i < N; i++) cin >> D.at(i);
  
  sort(D.begin(), D.end(), greater<int>());
  
  int counter = 1;
  int mochi_radius = D.at(0);
  
  for (int i; i < N; i++) {
	if (D.at(i) < mochi_radius) {
      mochi_radius = D.at(i);
      counter++;
    }
  }
  cout << counter << endl;
}
      
  
    

Measured memory_bytes: 256
n=int(input())
m=10**9+7
dp=[{} for _ in range(n+1)]

def ok(last4):
    for i in range(4):
        t=list(last4)
        if i>=1:
            t[i],t[i-1]=t[i-1],t[i]
        if  "".join(t).count("AGC")>=1:
            return False
    return True

def dfs(cur, last3):
    if last3 in dp[cur]:
        return dp[cur][last3]
    if cur==n:
        return 1

    ret=0
    for c in "AGCT":
        if ok(last3+c):
            ret=ret+dfs(cur+1, last3[1:]+c)
            ret%=m
        dp[cur][last3]=ret
    return ret

print(dfs(0, "___"))

Measured memory_bytes: 3884
N, M = map(int, input().split())
H = [int(a) for a in input().split()]
X = [1] * N
for _ in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    if H[a] <= H[b]:
        X[a] = 0
    if H[b] <= H[a]:
        X[b] = 0
print(sum(X))

Measured memory_bytes: 19968
#include<bits/stdc++.h>
using namespace std;
#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 fi first
#define se second
#define INF 1000000009
#define lINF 1000000000000000009
typedef long long ll;

int main(){
  string s;
  cin>>s;
  if(s[0]==s[2]){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  return(0);
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007, INF = 1111111111;
const double EPS = 1e-9;


int main() {

	cin.tie(0);

	int A, B, C;
	cin >> A >> B >> C;

	int mod, cnt = 2;
	vector<int> mods;
	mods.emplace_back(A % B);

	do {

		mod = (A * cnt) % B;
		mods.emplace_back(mod);
		
		if (mod == C) {

			cout << "YES";
			return 0;
		}

		cnt++;
	}
	while (mods[0] != *(mods.end() - 1));

	cout << "NO";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
#define pa pair<int,int>
using namespace std;
namespace fastIO{
	const int L=2333333;
	char LZH[L],*A=LZH,*B=LZH;
	inline char gc(){
		if (A==B){
			B=(A=LZH)+fread(LZH,1,L,stdin);
			if (A==B) return EOF;
		}
		return *A++;
	}
	inline int read(){
		int x=0;
		char ch=gc();
		for (;ch<'0'||ch>'9';ch=gc());
		for (;ch>='0'&&ch<='9';ch=gc())
			x=x*10-48+ch;
		return x;
	}
	inline void write(int x){
		if (!x){
			puts("0");
			return;
		}
		static int a[15],top;
		for (top=0;x;a[++top]=x%10,x/=10);
		for (;top;putchar('0'+a[top--]));
		puts("");
	}
}
int x[N],y[N],lap[N];
int n,l,T,pl;
set<pa> s1,s2;
int getid(int T,int jzq){
	int nowT=0;
	for (;;){
		if (y[jzq]==1){
			if (s2.empty()) break;
			int tmp=(x[jzq]+nowT)%l;
			pa ano=*s2.lower_bound(pa(tmp,233333));
			if (T*2-nowT<ano.first-tmp) break;
			jzq=ano.second;
			nowT+=ano.first-tmp;
		}
		else{
			if (s1.empty()) break;
			int tmp=((x[jzq]-nowT)%l+l)%l+l;
			set<pa>::iterator it=s1.lower_bound(pa(tmp,-233333));
			pa ano=*(--it);
			if (T*2-nowT<tmp-ano.first) break;
			jzq=ano.second;
			nowT+=tmp-ano.first;
		}
	}
	return jzq;
}
int main(){
	using namespace fastIO;
	n=read(); l=read(); T=read();
	for (int i=1;i<=n;i++){
		x[i]=read(); y[i]=read();
		lap[i]=((x[i]+(y[i]==1?1:-1)*T)%l+l)%l;
	}
	sort(lap+1,lap+n+1);
	for (int i=1;i<=n;i++)
		if (y[i]==1){
			s1.insert(pa(x[i],i));
			s1.insert(pa(x[i]+l,i));
		}
		else{
			s2.insert(pa(x[i],i));
			s2.insert(pa(x[i]+l,i));
		}
	int delta=getid(l,1)-1;
	int jzq=getid(T%l,delta*(T/l)%n+1);
	int jzq2=getid(T%l,(delta*(T/l)+1)%n+1);
	int firp=((x[jzq]+(y[jzq]==1?1:-1)*T)%l+l)%l;
	int secp=((x[jzq2]+(y[jzq2]==1?1:-1)*T)%l+l)%l;
	for (pl=1;pl<=n;pl++)
		if (lap[pl]==firp&&lap[pl%n+1]==secp) break;
	for (int i=1;i<=n;i++,pl=pl%n+1)
		write(lap[pl]);
}

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

int main() {
    long long s, t; cin >> s >> t;
    long long a, b, c, d; cin >> a >> b >> c >> d;
    a *= s; c *= s; b *= t; d *= t;
    b += a; d += c;
    if (b == d) {
        cout << "infinity" << endl;
        return 0;
    }
    if ((b > d) == (a > c)) {
        cout << 0 << endl;
        return 0;
    }
    if (b > d) {
        swap(b, d); swap(a, c);
    }
    long long x = d - b;
    long long y = a - c;
    cout << (y / x) * 2 + 1 - (y % x == 0) << endl;
    return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Sum of Interior Angles
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

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

  printf("%d\n", (n - 2) * 180);
  return 0;
}


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

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)

using namespace std;
using ll = long long;

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll n,w;
  cin >> n >> w;
  ll val[n]; ll wt[n];
  for (ll i = 0; i < n; i++)
  {
    cin >> wt[i] >> val[i];
  }
  ll dp[n + 1][w + 1];
  for (ll i = 0; i <= n; i++)
  {
    for (ll j = 0; j <= w; j++)
    {
      if(i==0||j==0)
        dp[i][j]=0;
    }
  }
  for (ll i = 1; i <= n; i++)
  {
    for (ll j = 1; j <= w; j++)
    {
      if (j  >= wt[i-1])
        dp[i][j] = max(val[i - 1] + dp[i - 1][j - wt[i - 1]], dp[i - 1][j]);
      else
        dp[i][j] = dp[i - 1][j];
    }
  }
  cout<<dp[n][w]<<endl;
  return 0;
}

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

int main()
{
	int n = 0;
	cin >> n;
	for (int i = 1; i <= n; i++){
		if (i % 3 == 0) cout << " " << i;
		else{
			int tmp = i;
			int a = tmp % 10;
			tmp /= 10;
			int b = tmp % 10;
			tmp /= 10;
			int c = tmp % 10;
			tmp /= 10;
			int d = tmp % 10;
			if (a == 3 || b == 3 || c == 3 || d == 3) cout << " " << i;
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
using namespace std;
int main(void){
    int n, k, a, x[200020], ans = 0;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        x[i] = 0;
    }
    for (int i = 0; i < n; i++) {
        cin >> a;
        x[a - 1]++;
    }
    
    sort(x, x + n);
    
    for (int i = 0; i < n - k; i++) {
        ans += x[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 1024
h, w = map(int, input().split())
s = [list(input()) for i in range(h)]
grid = []
for i in range(h+2):
    grid.append([0]*(w+2))

for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            grid[i + 1][j + 1] = '#'

            if grid[i][j] != '#':
                grid[i][j] += 1

            if grid[i][j + 1] != '#':
                grid[i][j + 1] += 1

            if grid[i][j+2] != '#':
                grid[i][j+2] += 1

            if grid[i+1][j] != '#':
                grid[i+1][j] += 1

            if grid[i+1][j+2] != '#':
                grid[i+1][j+2] += 1

            if grid[i+2][j] != '#':
                grid[i+2][j] += 1

            if grid[i+2][j+1] != '#':
                grid[i+2][j+1] += 1

            if grid[i+2][j+2] != '#':
                grid[i+2][j+2] += 1




for i in range(1, h+1):
    ans = ''
    for j in range(1, w+1):
        ans += str(grid[i][j])
    print(ans)


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

long long t1, t2, a1, a2, b1, b2;

int main() {
    cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;

    if (t1 * a1 + t2 * a2 == t1 * b1 + t2 * b2) {
        cout << "infinity\n";
        return 0;
    }
    if (t1 * a1 + t2 * a2 < t1 * b1 + t2 * b2) {
        swap(a1, b1); swap(a2, b2);
    } 
    if (a1 > b1) {
        cout << "0\n";
        return 0;
    }

    long long q1 = t1 * (b1 - a1);
    long long q2 = (t1 * a1 + t2 * a2) -  (t1 * b1 + t2 * b2);
    long long ans = q1 / q2;
    ans *= 2;
    if (q1 % q2 != 0) ans++;
    cout << ans << '\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

int w, d;

int main() {
	while (cin >> w >> d&&w + d) {
		int h[2][100];
		int sum = 0;
		int cnt[2][100] = {};
		REP(i, w) {
			cin >> h[0][i];
			sum += h[0][i];
			cnt[0][h[0][i]]++;
		}
		REP(i, d) {
			cin >> h[1][i];
			cnt[1][h[1][i]]++;
		}
		REP(i, 100) {
			sum += i*max(0, cnt[1][i] - cnt[0][i]);
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 3016
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin>>n;
	if(n%2==1){
		cout<<"0";
		return 0;
	}
	n=n/2;
	long long cnt=0;
	while(n!=0){
		n=n/5;
		cnt+=n;
	} 
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256