akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <complex>
#include <vector>
#include <tuple>
#include <algorithm>

using namespace std;

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

typedef complex<double> P;
typedef pair<P, P> L;

const double EPS = 1e-9;
const int INF = 1e9 + 10;

#define X real()
#define Y imag()
#define EQ(n,m) (abs((n)-(m)) < EPS)

double cross(P a, P b) {
	return (conj(a) * b).Y;
}
double dist(P a, P b) {
	return (a.X - b.X) * (a.X - b.X) + (a.Y - b.Y) * (a.Y - b.Y);
}
bool isPointOnLine(P a, P b, P c) {
	return abs(a - c) + abs(c - b) < abs(a - b) + EPS;
}
P crosspointLL(P a1, P a2, P b1, P b2) {
	double d1 = cross(b2 - b1, b1 - a1);
	double d2 = cross(b2 - b1, a2 - a1);
	P ret;
	if (EQ(d1, 0) && EQ(d2, 0)) {
		ret = a1;
	}else
	if (EQ(d2, 0))return P(INF, INF);
	ret = a1 + d1 / d2 * (a2 - a1);
	if (isPointOnLine(b1, b2, ret) && isPointOnLine(a1, a2, ret)) {
		return ret;
	}
	else {
		return P(INF, INF);
	}
}
typedef tuple<P, bool, bool> pbb;

int dp[102][2];

signed main() {

	int T;
	cin >> T;
	rep(_, T) {
		int xa, ya, xb, yb, n;
		cin >> xa >> ya >> xb >> yb;
		P A(xa, ya), B(xb, yb);
		cin >> n;
		vector<pbb> vp;
		rep(i, n) {
			int xs, ys, xt, yt, o, l;
			cin >> xs >> ys >> xt >> yt >> o >> l;
			P s(xs, ys), t(xt, yt);
			if (crosspointLL(s, t, A, B) != P(INF, INF)) {
				vp.push_back(pbb(crosspointLL(s, t, A, B), o, l));
			}
		}
		sort(vp.begin(), vp.end(), [&](pbb &t0, pbb &t1) {
			return dist(A, get<0>(t0)) < dist(A, get<0>(t1));
		});
		rep(i, 102)rep(j, 2)dp[i][j] = INF;
		dp[0][0] = dp[0][1] = 0;
		rep(i, vp.size()) {
			int o = get<1>(vp[i]), l = get<2>(vp[i]);
			rep(j, 2) {
				if (o == 1) {
					if (j == l) {
						dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
					}else{
						dp[i + 1][1 - j] = min(dp[i + 1][1 - j], dp[i][j] + 1);
					}
				}else
				if (o == 0) {
					if (j == l) {
						dp[i + 1][1 - j] = min(dp[i + 1][1 - j], dp[i][j] + 1);
					}
					else {
						dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
					}
				}
			}
		}
		int ans = INF;
		rep(j, 2) {
			ans = min(dp[vp.size()][j], ans);
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3132
# https://atcoder.jp/contests/abc151/tasks/abc151_e
# NCK種のすべてのSについてf(S)の合計をもとめる.
# S1,S2...とすると
# sum_i f(Si) = max(S1) + max(S2) ... max(S NCK) - (min(S1) + min(S2) ... min(S NCK))
# となる。
# sum_i max(Si)について考えると、ある要素を固定したときにそれが最大となるような集合を全パターン持ってくれば簡単に計算できる
# 例えば 1 1 3 4 (K=2)で 4が最大となるとり方は3C1(K-1)
# 3が最大となるとり方は(2C1)
# 1が最大となるとり方は(1C1)
# 1が最大となるとり方は(0C1=0)
# 以上によりsum_i max(Si) = 4 * 3C1 + 2*2C1 + 1*1C1 + 1*0C1となる
# 注意としてiC(K-1)をiについてリストにするときいちいちcombination_modを呼び出すとTLEになるので、一気にここを用意する必要がある。
# 具体的には(K-1)!の逆元を計算を計算しておいて
# 分子についてはかけて割って調節すれば良い？


MOD = 10**9 + 7


def combination_mod(n, r, mod):
    if r > n or n == 0:
        return 0  # このような通りの数は無いため便宜上こう定義する
    r = min(r, n - r)
    nf = rf = 1
    for i in range(r):
        nf = nf * (n - i) % mod
        rf = rf * (i + 1) % mod
    return nf * pow(rf, mod - 2, mod) % mod


import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


N, K = read_ints()
A = read_ints()
A.sort()


# 通りの数を先に計算しておく
k = K - 1
k_fact = 1
for i in range(k):
    k_fact = k_fact * (i + 1) % MOD
k_fact_inv = pow(k_fact, MOD - 2, MOD)
conbi = [0]
correct = []
tmp = 1
for i in range(1, N):
    if i < k:
        conbi.append(0)
        tmp *= i
        if tmp >= MOD:
            tmp %= MOD
    else:
        tmp *= i
        tmp %= MOD
        conbi.append((tmp % MOD) * k_fact_inv)
        tmp *= pow(i - k + 1, MOD - 2, MOD)  # 逆元をかけて割ったことにする。
        # tmp //= (i - k + 1)
    # correct.append(combination_mod(i, k, MOD)) #確認用
# conbi[i]はA_reverse[i]にかけることに対応

# print(conbi)
# print(correct)

ans = 0
# maxを足す
for a, c in zip(A, conbi):
    ans += a * c
    if ans >= MOD:
        ans %= MOD

        # minを引く
for a, c in zip(A[::-1], conbi):
    ans -= a * c
    if ans >= MOD:
        ans %= MOD


print(ans)


Measured memory_bytes: 14048
n,m = list(map(int,input().split()))

a = []
b = []
c = []
d = []
e = []
f = []
g = []
h = []
for i in range(n):
    j = list(map(int,input().split()))
    a.append(j[0]+j[1]+j[2])
    b.append(-j[0]+j[1]+j[2])
    c.append(j[0]-j[1]+j[2])
    d.append(j[0]+j[1]-j[2])
    e.append(-j[0]-j[1]+j[2])
    f.append(-j[0]+j[1]-j[2])
    g.append(j[0]-j[1]-j[2])
    h.append(-j[0]-j[1]-j[2])
a.sort()
a.reverse()
b.sort()
b.reverse()
c.sort()
c.reverse()
d.sort()
d.reverse()
e.sort()
e.reverse()
f.sort()
f.reverse()
g.sort()
g.reverse()
h.sort()
h.reverse()

print(max(sum(a[:m]),sum(b[:m]),sum(c[:m]),sum(d[:m]),sum(e[:m]),sum(f[:m]),sum(g[:m]),sum(h[:m])))


Measured memory_bytes: 3440
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define forn(i,n) for(int i = 0; i < (int) n; ++i)
#define ios ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
typedef long long ll;

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

  vector<vector<int>> x(n, vector<int>(3));
  forn(i, n) forn(j, 3) cin >> x[i][j];

  sort(all(x), [&](const vector<int>& lhs, const vector<int>& rhs) {
    return lhs[1] - lhs[2] > rhs[1] - rhs[2]; // sort by L-R
  });

  set<int> left;
  forn(i,n) left.insert(i+1);

  int first = n, skip = 0;
  ll ans = 0;

  forn(i, n) {
    if (x[i][1] - x[i][2] < 0) {
      first = i;
      break;
    }

    // greatest e in left <= x[i][0]
    auto it = left.upper_bound(x[i][0]);
    if (it == left.begin()){
      ans += x[i][2];
      skip++;
      continue;
    }
    --it;

    left.erase(it);
    ans += x[i][1];
  }

  left.clear();
  for(int i = n - 1; i >= first; i--)
    left.insert(i+1);

  for(int i = n - 1; i >= first; i--) {
    assert(x[i][1] - x[i][2] < 0);

    // want to be in smallest e > x[i][0]
    auto it = left.upper_bound(x[i][0]);

    if (it == left.end()){
      ans += x[i][1];
      left.erase(left.begin());
      continue;
    }

    left.erase(it);
    ans += x[i][2];
  }

  cout << ans << "\n";
}

int main() {
  ios;
  int t;
  cin >> t;
  while(t--) solve();
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<vector<int>> S(M + 1);
  for (int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    if (a > M) continue;
    S[a].emplace_back(b);
  }
  for (int i = 0; i <= M; i++) {
    if (S[i].empty()) continue;
    sort(S[i].begin(), S[i].end(), greater<int>());
  }
  int res = 0;
  priority_queue<int> q;
  for (int i = 0; i <= M; i++) {
    for (auto b : S[i]) {
      q.push(b);
    }
    if (q.empty()) continue;
    res += q.top();
    q.pop();
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 5632
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 15
#define W 8

int main(){
    int i, oc, len;
    char str[16]; 
    scanf("%s", str);
    len = strlen(str);
    oc=0;
    for(i=0; i<len; i++){
        if(str[i] == 'o')oc++;
    }
    if(N-len >= W-oc)printf("YES\n");
    else printf("NO\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int A, B, K; cin >> A >> B >> K;
  for (int i=A;i<=B;i++){
    if (i-A<K || B-i<K) cout << i << endl;
  }

  // cout << fixed << setprecision(6);
  return 0;
}


Measured memory_bytes: 256
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = []
for i,j in zip(a,b):
  c.append(i-j)
c.sort()
if min(c) >= 0:
  print(0)
  exit()
else:
  zero = bisect.bisect_left(c,0)
  minus = sum(c[:zero])
  #print(minus)
  d = c[zero:]
  ans = zero
  for i in d[::-1]:
    minus += i
    ans += 1
    if minus >= 0:
      print(ans)
      exit()
print(-1)

Measured memory_bytes: 18356
#include <stdio.h>

int get_int() {
    int n = 0;
    int c = getchar_unlocked();
    if(c == 45) {
        c = getchar_unlocked();
        while(47 < c && c < 58) n = 10 * n + (c & 0xf), c = getchar_unlocked();
        return -n;
    } else if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) n = 10 * n + (c & 0xf), c = getchar_unlocked();
    return n;
}
void put_int(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    if(n < 0) n = -n, putchar_unlocked('-');
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}
void put_str(char *str) { while(*str) putchar_unlocked(*str++); }

void _maxheap(int *A, const int i, const int N) {
    int l = i * 2;
    int r = i * 2 + 1;
    int max = i;
    if(l <= N && A[l] > A[max]) max = l;
    if(r <= N && A[r] > A[max]) max = r;
    if(max != i) {
        int tmp = A[i];
        A[i] = A[max];
        A[max] = tmp;
        _maxheap(A, max, N);
    }
}
void maxheap(int *A, const int N) {
    for(int i = N / 2; i > 0; --i) _maxheap(A, i, N);
}
int main(int argc, char **argv) {
    int h = get_int();
    int a[h + 1];
    for(int i = 1; i <= h; ++i) a[i] = get_int();
    maxheap(a, h);
    for(int i = 1; i <= h; ++i) putchar_unlocked(' '), put_int(a[i]);
    putchar_unlocked('\n');
    return 0;
}



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

int N, S, cnt;
void dfs( int i, int sum, int total )
{
    if( total == N && sum == S )
    {
        cnt++;
        return;
    }
    if( i == 10 || total == N ) return;
    
    dfs( i + 1, sum + i, total + 1 );
    dfs( i + 1, sum, total );
}
int main()
{
    while( cin >> N >> S )
    {
        if( N == 0 && S == 0 ) break;
        cnt = 0;
        dfs( 0, 0, 0 );
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
   int N;
   cin >> N;
   map<int,int>a;
   rep(i,N){
      int k;cin >> k;
      a[k]++;
   }
   int ans=0;
   for(auto x :a){
      if(x.second%2==1)ans++;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 4864
#べき乗関数powを使った逆元の計算
def modinv2(a,m):
    return pow(a,m-2,m)

X,Y = map(int,input().split())

X,Y = min(X,Y),max(X,Y)

if (X+Y)%3 != 0 or X*2-Y < 0:
    ans = 0
else:
    a = (2*X-Y)//3
    b = (2*Y-X)//3
    m = 10**9+7
    ans = 1
    for i in range(b+1,a+b+1):
        ans = ans*i%m
    for i in range(1,a+1):
        ans = ans*modinv2(i,m)%m
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

template <typename T>
struct UnionFind {
  std::vector<T> par, rank, sz;
  UnionFind(T n) : par(n), rank(n, 0), sz(n, 1) {
    for (T i = 0; i < n; i++) par[i] = i;
  }
  void init(T n) {
    par.resize(n);
    rank.resize(n);
    sz.resize(n);
    for (T i = 0; i < n; i++) {
      par[i] = i;
      rank[i] = 0;
      sz[i] = 1;
    }
  }

  int root(T x) {
    if (par[x] == x)
      return x;
    else
      return par[x] = root(par[x]);
  }

  bool is_same(T x, T y) { return root(x) == root(y); }

  int size(T x) { return sz[root(x)]; }

  bool unite(T x, T y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;

    if (rank[x] < rank[y]) std::swap(x, y);
    if (rank[x] == rank[y]) rank[x]++;
    par[y] = x;
    sz[x] += sz[y];
    return true;
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
    p[i]--;
  }
  UnionFind uf(N);
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    uf.unite(x, y);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (uf.is_same(p[i], i)) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, a, b) for(int i = a; i >= (b); --i)
#define all(x) x.begin(), x.end()
#define pb  push_back
#define mb  make_pair
#define fi  first
#define se  second
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
const ll mod = 1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}



void solve()
{
    double pi = 3.141592653589793238;
    double r;
    cin >> r;
    double ans = 2*pi*r;
    printf("%.9lf", ans);
}

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

	solve();
	return 0;
}


Measured memory_bytes: 3772
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int HT = Integer.valueOf(s.split(" ")[0]);
		int ST = Integer.valueOf(s.split(" ")[1]);
		int HA = Integer.valueOf(s.split(" ")[2]);
		int SA = Integer.valueOf(s.split(" ")[3]);
	
		while(HA > 0 && HT > 0) {
			HA = HA - ST;
			if(HA <= 0)
				break;
			HT = HT - SA;
			if(HT <= 0)
				break;
		}
		//System.out.println(HA + " " + HT);
		
		if(HT > HA) {
			System.out.println("Yes");
		}
		else
			System.out.println("No");
	}

}

class FastReader {
	BufferedReader bf;
	StringTokenizer st;

	public FastReader() {
		bf = new BufferedReader(new InputStreamReader(System.in));
	}

	String next() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(bf.readLine());
			} catch (Exception e) {
				System.out.println(e);
			}
		}
		return st.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	long nextLong() {
		return Long.parseLong(next());
	}

	double nextDouble() {
		return Double.parseDouble(next());
	}

	String nextLine() {
		String str = "";
		try {
			str = bf.readLine();
		} catch (Exception e) {
			System.out.println(e);
		}
		return str;
	}
}



Measured memory_bytes: 35732
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll A, B, Q;
    cin >> A >> B >> Q;
    vec s(A), t(B);
    loop(i, A) cin >> s[i];
    loop(i, B) cin >> t[i];
    s.push_back(-1e18);
    s.push_back(1e18);
    t.push_back(-1e18);
    t.push_back(1e18);
    sort(all(s));
    sort(all(t));
    A += 2;
    B += 2;
    loop(i, Q)
    {
        ll x;
        cin >> x;
        ll sll, srr, tll, trr;
        sll = idx_lower(s, x) - 1;
        srr = sll + 1;
        tll = idx_lower(t, x) - 1;
        trr = tll + 1;
        ll sl, sr, tl, tr;
        sl = s[sll];
        sr = s[srr];
        tl = t[tll];
        tr = t[trr];
        ll ans = 2e18;
        //8パターン
        ans = min(ans, abs(x - sl) + abs(sl - tl));
        ans = min(ans, abs(x - sl) + abs(sl - tr));
        ans = min(ans, abs(x - sr) + abs(sr - tl));
        ans = min(ans, abs(x - sr) + abs(sr - tr));
        ans = min(ans, abs(x - tl) + abs(tl - sl));
        ans = min(ans, abs(x - tl) + abs(tl - sr));
        ans = min(ans, abs(x - tr) + abs(tr - sl));
        ans = min(ans, abs(x - tr) + abs(tr - sr));
        putout(ans);
    }
    return 0;
}


Measured memory_bytes: 5556
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++){
        if(s[i]=='7'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 3624
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>

using namespace std;

int main() {
	char S[6];
	int N,i;

	scanf("%s", S);
	N = strlen(S);
	for (i = 0; i < N - i;i++) {
		if (S[i] == 'A' && S[i + 1] == 'C') {
			printf("Yes\n"); return 0;
		}
	}
	printf("No\n"); return 0;
}

Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
////////////////////////////
class UnionFind {
public:
    vector < ll > par; // 各元の親を表す配列
    vector < ll > siz; // 素集合のサイズを表す配列(1 で初期化)
    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }
    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }
    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }
    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};
/////////////////////////////////////
//UnionFind uf(N);
struct point{
    ll x,y,num;
};
bool c1(point a,point b){
    return a.x<b.x;
}
bool c2(point a,point b){
    return a.y<b.y;
}
bool c3(point a,point b){
    return a.num<b.num;
}


int main(){fastio
    ll n;cin>>n;
    point p[n];
    rep(i,0,n-1){
        cin>>p[i].x>>p[i].y;
        p[i].num=i;
    }
    UnionFind uf(n);
    sort(p,p+n,c1);
    rep(i,0,n-2){
        if(p[i].x==p[i+1].x){
            uf.merge(p[i].num,p[i+1].num);
        }
    }
    sort(p,p+n,c2);
    rep(i,0,n-2){
        if(p[i].y==p[i+1].y){
            uf.merge(p[i].num,p[i+1].num);
        }
    }
    vector<ll>v[n];
    rep(i,0,n-1){
        v[uf.root(i)].pb(i);
    }
    sort(p,p+n,c3);
    ll ans=0;
    rep(i,0,n-1){
        set<ll>x,y;
        for(auto nu:v[i]){
            x.insert(p[nu].x);
            y.insert(p[nu].y);
        }
        ans+=x.size()*y.size();
    }
    cout<<ans-n<<endl;
    
    return 0;
}


Measured memory_bytes: 13684
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define PI 3.141592653589793
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, M;
  cin >> N >> M;
  vvll G(N, vll(0));
  for(int i = 0; i < M; i++){
    ll u, v;
    cin >> u >> v;
    u--; v--;
    G.at(u).push_back(v);
  }
  ll S, T;
  cin >> S >> T;
  S--; T--;

  vvll dist(N, vll(3, INF));
  dist.at(S).at(0) = 0;
  queue<P> que;
  que.push(P(S, 0));
  while(!que.empty()){
    ll v = que.front().first;
    ll l = que.front().second;
    que.pop();
    for(int i = 0; i < G.at(v).size(); i++){
      ll next = G.at(v).at(i);
      ll nl = (l+1)%3;
      if(dist.at(next).at(nl) != INF) continue;
      dist.at(next).at(nl) = dist.at(v).at(l) + 1;
      que.push(P(next, nl));
    }
  }
  ll ans = dist.at(T).at(0);
  if(ans == INF) cout << -1 << endl;
  else cout << ans/3 << endl;
}

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    lli h,w;
    cin2(h,w);
    string s[h+2];
    REPE(i,0,h+1) {
        if (i == 0) {
            s[i] = string(w+2, 'o');
            continue;
        }
        else if (i == h+1) {
            s[i] = string(w+2, 'o');
            continue;
        }
        string x;
        cin >> x;
        x = "o" + x + "o";
        s[i] = x;
    }

    lli ans = h*w;
    REPE(i,1,h) {
        //cout << s[i] <<endl;
        REPE(j,1,w) {
            if (s[i][j] == '#')
                ans--;
        }
    }


    lli lr[4] = {-1,0,1,0};
    lli ud[4] = {0,1,0,-1};
    bool done[h+2][w+2] = {false};
    queue<tup> que;
    // row, column, 何手目か
    que.push(make_tuple(1,1,1));
    done[1][1] = true;
    bool is_ok = false;
    while (!que.empty()) {
        lli r, c, n;
        tie(r, c, n) = que.front();
        que.pop();
        if (r == h && c == w) {
            ans -= n;
            is_ok = true;
            break;
        }
        // 上下左右に移動
        REP(i,0,4) {
            lli next_r = r + ud[i];
            lli next_c = c + lr[i];
            // 上下左右の境界チェック
            if (next_r <= 0 || next_r >= h+1)
                continue;
            if (next_c <= 0 || next_c >= w+1)
                continue;

            if (done[next_r][next_c])
                continue;
            if (s[next_r][next_c] == '#')
                continue;
            done[next_r][next_c] = true;
            que.push(make_tuple(next_r, next_c, n+1));
        }
    }
    if (is_ok)
        cout << ans << endl;
    else
        cout << -1 << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC127A
{
    class Program
    {
        static void Main(string[] args)
        {
            var nums = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToList();

            var a = nums[0];
            var b = nums[1];

            if (a < 6)
            {
                Console.WriteLine(0);
            }
            else if (a <= 12)
            {
                Console.WriteLine(b / 2);
            }
            else
            {
                Console.WriteLine(b);
            }
        }
    }
}


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

int64_t lcm(int64_t x, int64_t y) {
  int64_t t;
  if(x<y) {
    t=x;
    x=y;
    y=t;
  }
  int64_t r=x*y,n=x%y;
  while(n!=0) {
    x=y;
    y=n;
    n=x%y;
  }
  return r/y;
}

int main() {
  int64_t A,B,C,D;
  cin >> A >> B >> C >> D;
  int64_t n=lcm(C,D);

  cout << B-A+1-(B/C-(A-1)/C+B/D-(A-1)/D-B/n+(A-1)/n) << endl;
}

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

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  int sum = 0;
  for(int i = 1; i <= n; i++){
    int c = 0, temp = i;
    for(int j = 0; j < 5; j++){
      c += temp % 10, temp /= 10;
    }
    if(a <= c && c <= b){
      sum += i;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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();
		}
		int[] count = new int[N];

		for(int a : A) {
			count[a-1] ++;
		}

		long sum = 0;
		for(int c : count) {
			sum += combination(c, 2);
		}
		
		for(int k=0; k < N; k++) {
			System.out.println(sum - (count[A[k]-1] -1 ));
		}

	}
	//組み合わせの数nCrを計算
	static long combination(long n, long r){
		if(n < r) return 0;
		long num = 1;
		for(long i = 1; i <= r; i++){
			num = num * (n - i + 1) / i;
		}
		return num;
	}
}







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

int main() {
    string s;
    cin >> s;
    int start, end;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'A') {
            start = i;
            break;
        }
    }
    for(int i = s.size(); i > 0; i--) {
        if(s[i] == 'Z') {
            end = i;
            break;
        }
    }
    cout << end - start + 1 << endl;
}

Measured memory_bytes: 3744
import java.util.*;
public class Main{
  public static void main(String[] args) {
    int n;
    String s,t;
    Scanner sc=new Scanner(System.in);
    n=sc.nextInt();
    s=sc.next();
    t=sc.next();
    for(int i=1;i<=n;i++){
      System.out.print(s.substring(i-1,i)+t.substring(i-1,i));
    }
  }
}


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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

typedef pair<int, int> P; 


int main(){
    ll ans = INF_LL, n;
    cin >> n;
    vector<ll> x(n);
    REP(i, n) cin >> x[i];

    REPN(p, 1, 101) {
        ll tmp = 0;
        REP(i, n) {
            tmp += (x[i] - p) * (x[i] - p);
        }
        ans = min(tmp, ans);
    }

    cout << ans << endl;

    return 0;
}


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

bool line[101], row[101]; 
char f[101][101];
int main() {
  int h, w; cin >> h >> w;
  rep(i,h) rep(j,w) cin >> f[i][j];

  rep(i,h) {
    bool allb = true;
    rep(j,w) {
      if (f[i][j] != '.') allb = false;
    }
    if (allb) line[i] = true;
    else line[i] = false;
  }
  rep(j,w) {
    bool allb = true;
    rep(i,h) {
      if (f[i][j] != '.') allb = false;
    }
    if (allb) row[j] = true;
    else row[j] = false;
  }

  rep(i,h) {
    rep(j,w) {
      if (line[i] || row[j]) continue;
      else cout << f[i][j];
    }
    if (!line[i])cout << endl;
  }
    return 0;
}

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

int main() {
    int n; cin >> n;
    while(n >= 10) n %= 10;
    string ans;
    if(n==3) ans = "bon";
    else if(n==0 || n==1 || n==6 || n==8) ans = "pon";
    else ans  = "hon";
    cout << ans  << endl; 
}

Measured memory_bytes: 3596
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;
#define pb push_back
#define fi first
#define se second
#define in insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
ll s(ll n) {
	return n * (n - 1) / 2;
}
void solve(){
	int n;
	cin >> n;
	vi a(n);
	map<int, int> m;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		m[a[i]]++;
	}
	ll sum = 0;
	for (auto p : m) {
		sum += s(p.se);
	} 
	for (int i = 0; i < n; ++i) {
		cout << sum - s(m[a[i]]) + s(m[a[i]] - 1) << endl;
	}
}

int main(){
	speed;
	int t = 1;
	//cin >> t;
	while(t--) solve();
}

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

int n,m;
const int maxn=200010;

int f[100005];
typedef pair < int , int > II;
typedef pair < int , II > III;
III tmp[1000006];
#define fr first
#define sc second
int d[3][maxn];
int sl=0;

void update(int id , int u ,int l)
{
    while(u<=maxn-5)
        d[id][u]+=l,u+=u&(-u);
}

int get(int id ,int u)
{
    int kq=0;

    while(u>0)
    kq+=d[id][u],u-=u&(-u);

    return kq;
}

int main ()
{
    //freopen("main.inp","r",stdin);
    //freopen("main.out","w",stdout);

    scanf("%d %d ",&n,&m);

    for(int i=1;i<=n;++i)
    {
        int a,b;

        scanf("%d %d ",&a,&b);

        update(0,a+1,1);
        update(0,b+2,-1);

        tmp[++sl]={b-a,{a,b}};
        update(1,a,1);
        update(2,b+1,1);
    }

    sort(tmp+1,tmp+sl+1);

    for(int i=m;i>=1;--i)
    {
        int k=get(0,i+1);

        for(int j=1;j*j<=i;++j)
        if(i%j==0)
        {
            f[j]+=k;
            f[i/j]+=k;
            if(j==i/j)
                f[j]-=k;
        }
    }

    int u=1;

    for(int i=1;i<=m;++i)
    {
        while(u<=sl&&tmp[u].fr<i)
        {
            update(1,tmp[u].sc.fr,-1);
            update(2,tmp[u].sc.sc+1,-1);
            ++u;
        }

        int k=0;

        for(int j=1;j<=m/i;++j)
        {
            k+=(get(2,(j+1)*i)-get(2,i*j)-get(1,(j+1)*i)+get(1,i*j))*j;
        }

        printf("%d\n",f[i]-k+sl-u+1);
    }
}


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

const int nm = 1e4, am = 1e6;
int n;
int as[nm], es[am + 1];

//mod
const int mod = 1e9 + 7;
int pow(int x, int y) { //x^y
	int rv = 1;
	for (; y > 0; y >>= 1, x = (long long) x * x % mod)
		if (y & 1)
			rv = (long long) rv * x % mod;
	return rv;
}
int inverce(int x) {
	return pow(x, mod - 2);
}

int main() {
	cin >> n;
	
	for (int i = 0, a; i < n; i++) {
		cin >> a;
		as[i] = a;
		for (int j = 2, e; j * j <= a; j++) {
			e = 0;
			while (a % j == 0)
				e++, a /= j;
			es[j] = max(es[j], e);
		}
		es[a] = max(es[a], 1);
	}
	
	int lcm = 1;
	long long l = 1;
	for (int i = 2; i < am + 1; i++) {
		if (es[i])
			lcm = (long long) lcm * pow(i, es[i]) % mod;
		if (es[i])
			l *= pow(i, es[i]);
	}
	
	int ans = 0;
	for (int i = 0; i < n; i++)
		ans = (ans + (long long) lcm * inverce(as[i])) % mod;
	cout << ans << endl;
}


Measured memory_bytes: 2816
#include <iostream>
#include <string>
#include <cmath>

using namespace std;

int main() {
	int N, c, tmp;
	cin >> N;
	string ans;
	for (int i = 0; i < N; i++) {
		ans = "";
		c = 0;
		string a, b;
		cin >> a >> b;
		for (int j = 0; j < max(a.length(), b.length()); j++) {
			int A, B;
			A = a.length() - j - 1;
			B = b.length() - j - 1;
			tmp = (A >= 0 ? a[A] - '0' : 0) + (B >= 0 ? b[B] - '0' : 0) + c;
			ans = (char)(tmp % 10 + '0') + ans;
			c = tmp / 10;
		}
		if (c) {
			ans = '1' + ans;
		}
		cout << (ans.length() > 80 ? "overflow" : ans) << endl;
	}
	return 0;
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_H = 305;
int H, W, K;
char S[MAX_H][MAX_H];
int A[MAX_H][MAX_H];

signed main()
{
  cin >> H >> W >> K;
  REP(h,H) {
    REP(w,W) {
      cin >> S[h][w];
    }
  }

  int k = 1;
  bool hFlag = false;
  REP(h,H) {
    hFlag = false;
    REP(w,W) {
      if(S[h][w] == '#') {
        hFlag = true;
        bool flag = true;
        for(int hh = h; 0 <= hh && flag; hh--) {
          for(int ww = w; 0 <= ww && flag; ww--) {
            if(A[hh][ww] == 0) {
              A[hh][ww] = k;
            } else {
              if(ww == w) {
                flag = false;
              }
              break;
            }
          }
        }
        k++;
      }
    }

    if(hFlag) {
      bool flag = true;
      for(int hh = h; 0 <= hh && flag; hh--) {
        for(int ww = W-1; 0 <= ww && flag; ww--) {
          if(A[hh][ww] == 0) {
            A[hh][ww] = k-1;
          } else {
            if(ww == W-1) {
              flag = false;
            }
            break;
          }
        }
      }
    }
  }

  FOR(h,1,H) {
    REP(w,W) {
      if(A[h][w] == 0) {
        A[h][w] = A[h-1][w];
      }
    }
  }

  REP(h,H) {
    REP(w,W) {
      cout << A[h][w];
      if(w < W-1) cout << " ";
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 1536
h, w, k = map(int, input().split())
ans = 0
c = [input() for i in range(h)]

for i in range(2**h):
    for j in range(2**w):
        cnt = 0
        for l in range(h):
            for m in range(w):
                if c[l][m] == '#' and (i >> l) & 1 and (j >> m) & 1:
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)

Measured memory_bytes: 74116
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define rep(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define irep(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define rrep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

const int MOD = 1e9 + 7;




int main() {
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;

    int i = 0;
    vector<bool> tate;
    while (i < n) {
        if (s1[i] == s2[i]) {
            tate.push_back(true);
            i++;
        }
        else {
            tate.push_back(false);
            i += 2;
        }
    }

    long long now = 1;
    bool beforetate = false;
    rep(i, 0, tate.size()) {
        if (!tate[i]) {
            if (!beforetate && i != 0)
                now = (now * 3) % MOD;
            else
                now = (now * 2) % MOD;
        }
        else if (beforetate)
            now = (now * 2) % MOD;

        if (tate[i])
            beforetate = true;
        else
            beforetate = false;
    }
    now = (now * 3) % MOD;

    cout << now << endl;


    return 0;
}

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

int main()
{
	string S;
	cin >> S;
	int n = S.size();
	bool ok = true;
	if (S[0] != 'A') ok = false;
	int cnt = 0;
	for (int i = 2; i < n - 1; i++) {
		if (S[i] == 'C') {
			cnt++;
		}
	}
	if (cnt != 1) {
		ok = false;
	}
	cnt = 0;
	for (auto c : S) {
		if ('A' <= c && c <= 'Z') {
			cnt++;
		}
	}
	puts(ok && cnt == 2 ? "AC" : "WA");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <string.h>
#include <sstream>
#include <stack>

using namespace std;

int main()
{
   int n;
   scanf("%d",&n);
   int *a=new int[n];
   for(int i=0;i<n;++i)
   {
       scanf("%d",&a[i]);
   }
   int sum=0;
   for(int i=0;i<n;++i)
   {
       sum+=a[i]-1;
   }
   printf("%d\n",sum);
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll N = 3e5+5;
vector<int>adj[N],adj1[N];
vector<pair<int,int>>v;
map<pair<int,int>,int>mp;
bool visited[N];
int height[N],val[N],grid[55][55];



void solve(){
 double d,t,s;
 cin>>d>>t>>s;
 if((double)d/s<=t)cout<<"Yes";
 else cout<<"No";
}
int main(){
    int t=1;
    //cin>>t;
   while(t--)solve();
}


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

typedef long long ll;
const int inf = 1e9;

int n, k;

int main(){
	cin>>n>>k;
	vector<int> vec(n, 0);
	for(int i = 0; i < n; ++i)cin>>vec[i];
	long long t = 1;
	for(int i = 0; i < k; ++i)t += vec[i];
	for(int i = k; i < n; ++i){
		long long q = t;
		t -=  vec[i - k];
		t += vec[i];
		long long r = t;
		if(r > q)cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 4068
import sys
readline = sys.stdin.readline

# 両端から見ていき、回文になっていないときに片方がxだったら、ans += 1してxのほうのインデックスを1進める
# 両方ともxでなかったら-1を出力

S = readline().rstrip()

left = 0
right = len(S) - 1
ans = 0
while left < right:
  if S[left] == S[right]:
    left += 1
    right -= 1
  else:
    if S[left] == "x":
      ans += 1
      left += 1
    elif S[right] == "x":
      ans += 1
      right -= 1
    else:
      print(-1)
      break
else:
  print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin>>n;
    unordered_map<string, ll> m;
    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        string d;
        cin >> d;
        sort(ALL(d));
        m[d]++;
    }
    for (auto k : m)
    {
        ans += k.second * (k.second - 1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 10660
from collections import defaultdict


n = int(input())
rel = defaultdict(set)

times = {}
for _ in range(n):
    rl = list(map(int, input().split()))
    p, ts = rl[0], rl[2:]
    rel[p] = sorted(ts, reverse=True)
    times[p] = {'first': 0, 'last': 0}

t = 0

for f in range(1, len(rel)+1):
    if times[f]['last']:
        continue
    stack = [f]
    while stack:
        u = stack[-1]
        if times[u]['first']:
            if not times[u]['last']:
                t += 1
                times[u]['last'] = t
            stack.pop()
            continue
        t += 1
        times[u]['first'] = t
        for v in rel[u]:
            if not times[v]['first']:
                stack.append(v)

for k in sorted(times):
    print(k, times[k]['first'], times[k]['last'])



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

int main() 
{
  int A, B, C, x;
  cin>>A>>B>>C;
  x=((A==B)+(B==C)+(C==A));
  if(x==1)
  { cout<<"Yes";
  }
  else 
    cout<<"No";
  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
P = list(map(int, input().split()))


ans = 0
for i in range(len(P)-K+1):
    if i == 0:
        c = sum(P[:K])
    else:
        c = c + P[i+K-1] - P[i-1]
    if c > ans:
        ans = c


print((ans+K)/2)

Measured memory_bytes: 25060
import itertools

[n,d]=[int(item) for item in input().split()]
x=[[int(item) for item in input().split()] for _ in range(n)]

clist=list(itertools.combinations(x,2))
res=0
for c in clist:
  dist=sum([(c[0][i]-c[1][i])**2 for i in range(len(c[0]))])**0.5
  if dist==int(dist):
    res+=1
print(res)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
#define ll long long int
#define mod 1000000007
using namespace std;

int main()
{
    ll n, i, j;
    cin >> n;

    vector <bool> primes(n + 1, true);
    primes[0] = false;
    primes[1] = false;

    vector <ll> primeList;

    for(i = 2; i <= sqrt(n); i ++)
    {
    	if(primes[i] == true)
    	{
	    	for(j = 2; i * j <= n; j ++)
	    	{
	    		primes[i * j] = false;
	    	}    		
    	}

    }

    for(i = 2; i <= n; i ++)
    {
    	if(primes[i] == true)
    		primeList.push_back(i);
    }

    map <ll, ll> mp;

    for(i = 2; i <= n; i ++)
    {
    	ll val = i;
    	for(ll num: primeList)
    	{
    		if(num * num > val)
    			break;
    		while(val % num == 0)
    		{
    			mp[num] ++;
    			val = val / num; 
    		}
    	}

    	if(val > 1)
    		mp[val] ++;
    }

    ll ans = 1;
	for(auto it = mp.begin(); it != mp.end(); it ++)
	{
		ans = ((ans % mod) * (((it -> second) + 1) % mod)) % mod;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x)  x.begin(),x.end()
#define vi vector<int>
#define print(x) for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<'\n';
#define in(x,n) for(int e=0;e<n;e++){int y;cin>>y;x.pb(y);}
#define lower(sl)  transform(sl.begin(), sl.end(), sl.begin(), ::tolower); 
//Available in Snips
#define fi(i, x, y)   for (__typeof(x) i = x; i < y; i ++)
#define fir(i, x, y)  for (__typeof(x) i = x; i > y; i --)
#define fv(x)   for (auto itr = x.begin(); itr != x.end(); itr ++)
#define fvr(x)  for (auto itr = x.end() - 1; itr != x.begin() - 1; itr --)

map<ll,ll>check,str;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//code here
	int N;cin>>N;
	vi a(N);
	int sum =0;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
		sum += a[i];
	}

	int mini = sum;
	int prefix_sum = 0;
	for (int i = 0; i < N; ++i) {
		prefix_sum += a[i];
		mini = min(mini, abs(prefix_sum - (sum - prefix_sum)));
	}

	cout << mini << endl;
	return 0;
}


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

int main() {

	int X, Y;
	cin >> X >> Y;

	int ans_y = (Y - 2 * X) / 2;
	int ans_x = X - ans_y;
	int jdg = (Y - 2 * X) % 2;

	if (jdg != 0 || ans_y < 0 || ans_x < 0) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}


	return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
 
const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;
 
int n;
ll a[N], b[N], c[N];
ll ans;
int main()
{
	scanf("%d", &n);
	for(int i = 0; i <= n; i++)
		scanf("%lld", &a[i]);
	b[0] = 1;
	for(int i = 1; i <= n; i++)
    	b[i] = min(b[i - 1] * 2, INF);
	c[0] = 1;
    for(int i = 0; i <= n; i++){
		if(c[i] < a[i]){
			printf("-1");
			return 0;
		}
		c[i + 1] = min((c[i] - a[i]) * 2, b[i + 1]); 	
	}
	c[n] = a[n];
	for(int i = n - 1; i >= 0; i--)
		c[i] = min(c[i], c[i + 1] + a[i]);	
	for(int i = 0; i <= n; i++)
		ans += c[i];
	printf("%lld", ans);
}


Measured memory_bytes: 6176
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
int main(){
    vector <long long> v;
    double a,b,c=0,d=0,e=0,f=0,g=0,i,j,k=1,l=0,r=1,n,m,z,h,p;
    string s,t,x,y[101];
    double q,u,w;
    cin>>a>>b>>c>>d;
    f=d*6;
    e=(0.5*d)+(c*30);
    f=min(abs(f-e),360-(abs(f-e)));
    e=sqrt(a*a+b*b-(2*a*b*cos(f*3.141592653589793238462643383279502884197169399375105820974944/180)));
    printf("%.20f",e);
}

Measured memory_bytes: 4236
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> S(N);
  for(int i=0; i<N; i++){
    cin >> S.at(i);
  }
  for(int i=1; i<N; i++){
    int j = i,k;
    while(S.at(j)>S.at(j-1)){
      k=S.at(j);
      S.at(j)=S.at(j-1);
      S.at(j-1)=k;
      if(j==1) break;
      j--;
    }
  }
  int sum=1;
  for(int i=1; i<N; i+=1){
    if(S.at(i)!=S.at(i-1)) sum++;
  }
  cout << sum <<endl;
}

Measured memory_bytes: 256
from sys import stdin
K, S = map(int, stdin.readline().rstrip().split())
l = list(i for i in range(K+1))
count = 0
for i in range(K+1):
    for j in range(K+1):
        z = S - i - j
        if 0 <= z <= K:
            count += 1
print(count)


Measured memory_bytes: 3060
S = input()
if 0<int(S[0]+S[1])<13:	#MMかYY
  if 0<int(S[2]+S[3])<13:	#MMかYY
    print('AMBIGUOUS')
  else:	#YY
    print('MMYY')
else:	#YY
  if 0<int(S[2]+S[3])<13:	#MM
    print('YYMM')
  else:	#YY
    print('NA')

Measured memory_bytes: 9108
#include<bits/stdc++.h>
using namespace std;
#define N 1111116
#define mod 1000000007

int n,ta,tb;
long long a,b,s[N],f[N],g[N],cnta,cntb;

long long read(){
	long long x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	n=read();a=read();b=read();
	for (int i=1;i<=n;i++) s[i]=read();
	s[0]=-1ll<<60;f[0]=g[0]=1;
	ta=tb=1,cnta=cntb=1;
	for (int i=1;i<n;i++){
		while (ta<i&&s[i+1]-s[ta]>=b)
			cnta=(cnta+f[ta++])%mod;
		g[i]=cnta;
		if (s[i+1]-s[i]<a) ta=i,cnta=0;
		while (tb<i&&s[i+1]-s[tb]>=a)
			cntb=(cntb+g[tb++])%mod;
		f[i]=cntb;
		if (s[i+1]-s[i]<b) tb=i,cntb=0;
	}
	while (ta<n) cnta=(cnta+f[ta++])%mod;
	while (tb<n) cntb=(cntb+g[tb++])%mod;
	printf("%lld\n",(cnta+cntb)%mod);
	return 0;
}

Measured memory_bytes: 5120