akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll> ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define tr1(x) cerr << #x << ": " << x << endl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << endl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<endl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<a.size();zz++) cerr<<a[zz]<<" ";cerr<<endl
#define trii(x) cerr<<#x<<": ("<<x.F<<","<<x.S<<")\n";
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<"\n"
#define mod 1000000007ll
#define inf 9999999999999999ll
#define nl endl
#define sz(x) (ll)(x).size()
#define all(x) x.begin(), x.end()
#define modulo 998244353ll

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll T=1;
    for(ll w1=1;w1<=T;w1++)
    {
        ll n;
        cin>>n;
        ll ans=0;
        for(ll i=1;i<=n;i++)
        {
            if(i%5==0 || i%3==0)
            {

            }
            else
            {
                ans+=i;
            }
        }
        cout<<ans<<nl;
    }
}


Measured memory_bytes: 3648
#include<iostream>
#include<vector>
int main(){
  int n,m,l;
  std::cin >> n >> m >> l;
  std::vector<std::vector<unsigned long long> > A,B,C;
  A.resize(n),B.resize(m),C.resize(n);
  for(int i=0; i<n; i++) A[i].resize(m);
  for(int i=0; i<m; i++) B[i].resize(l);
  for(int i=0; i<n; i++) C[i].resize(l);
  for(int i=0; i<n; i++) for(int j=0; j<m; j++) std::cin >> A[i][j];
  for(int i=0; i<m; i++) for(int j=0; j<l; j++) std::cin >> B[i][j];
  for(int i=0; i<n; i++){
    for(int j=0; j<l; j++){
      C[i][j] = 0;
      for(int k=0; k<m; k++) C[i][j] += A[i][k] * B[k][j];
    }
  }
  for(int i=0; i<n; i++){
    for(int j=0; j<l; j++) std::cout << C[i][j] << (j < l-1 ? " " : "\n");
  }
  return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  int ma = 0;
  for(int i=1; i*i<=m; i++){
    if(m%i == 0 && i<=m/n){
      ma = max(ma,i);
      if(i >= n){
        ma = max(ma,m/i);
      }
    }
  }
  cout << ma << endl;
}

Measured memory_bytes: 256
n=int(input())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
def find_power(n):
    # 0!からn!までのびっくりを出してくれる関数
    powlist=[0]*(n+1)
    powlist[0]=1
    powlist[1]=1
    for i in range(2,n+1):
        powlist[i]=powlist[i-1]*i%(10**9+7)
    return powlist
powl=find_power(10)
import math
a=1
b=1
for i in range(n):
    c=1
    d=1
    subp=p[i:]
    subq=q[i:]
    for j in subp:
        if j<subp[0]:
            c+=1
    for k in subq:
        if k<subq[0]:
            d+=1

    a=a+c*int(powl[n-1-i])
    b=b+d*int(powl[n-1-i])
print(abs(a-b))

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  long long a, b, c;
  cin >> a >> b >> c;
  if (c - a - b >= 0 and 4 * a * b < (c - a - b) * (c - a - b)) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


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

int h, w;
char s[30][30];
int pti(int x, int y)
{
    return (x - 1) * w + y;
}
vector<int> adj[1000];
int dis[1000];
bool vis[1000];
int st = 0, maxi = 0;
void bfs(int v)
{
    queue<int> q;
    q.push(v);
    vis[v] = true;
    dis[v] = 0;
    while (!q.empty())
    {
        int g = q.front();
        // cout << g << " ";
        q.pop();
        for (auto it : adj[g])
            if (!vis[it])
            {
                vis[it] = true;
                dis[it] = dis[g] + 1;
                q.push(it);
            }
    }
    return;
}

int main()
{
    cin >> h >> w;
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
            cin >> s[i][j];
    }
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            if (s[i][j] == '.')
            {
                if (i + 1 <= h && s[i + 1][j] == '.')
                {
                    adj[pti(i, j)].push_back(pti(i + 1, j));
                    adj[pti(i + 1, j)].push_back(pti(i, j));
                }
                if (j + 1 <= w && s[i][j + 1] == '.')
                {
                    adj[pti(i, j)].push_back(pti(i, j + 1));
                    adj[pti(i, j + 1)].push_back(pti(i, j));
                }
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= h * w; i++)
    {
        if (s[(i-1) / w + 1][(i-1) % w+1] == '.')
        {
            bfs(i);
            for (int j = 1; j <= h * w; j++)
            {
                vis[j] = false;
                ans = max(ans, dis[j]);
                dis[j] = 0;
            }
        }
    }
    cout << ans;
}

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


Measured memory_bytes: 128
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;
#define int ll

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

// template <class Head, class... Tail>
// void print(Head&& head, Tail&&... tail) {
//     cout << head;
//     if (sizeof...(tail) != 0) cout << " ";
//     print(forward<Tail>(tail)...);
// }

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << " ";
    }
    cout << endl;
}

template <class T>
void print(vector<T> &vec, ll k){
   ll n = vec.size();
   k = min(k, n);
   rep(i,k-1)cout << vec[i] << " ";
   cout << vec[k-1] << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<class T, class U>
void print(pair<T,U> &p){
    print(p.first, p.second);
}


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,x,y; cin >> n >> x >> y;
    x--;y--;
    vvl graph(n, vl(n, INF));
    rep(i,n){
        graph[i][i] = 0;
        if(i > 0){
            graph[i][i-1] = 1;
            graph[i-1][i] = 1;
        }
    }
    rep(i,n)rep(j,n){
        graph[i][j] = abs(i - j);
    }

    rep(i,n)rep(j,n){
        chmin(graph[i][j], graph[i][x] + graph[y][j] + 1);
        chmin(graph[i][j], graph[i][y] + graph[x][j] + 1);
    }

    // print(graph);

    vector<ll> cnt(n+1);
    rep(i,n)rep(j,n){
        if(i <= j)continue;
        cnt[graph[i][j]]++;
    }
    reps(i,n-1)cout << cnt[i] << "\n";
}

Measured memory_bytes: 31616
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, p: "List[int]", x: "List[int]", y: "List[int]"):
    par = [i for i in range(0, N + 1)]
    def find_root(i):
        if par[i] != i:
            par[i] = find_root(par[i])
            return par[i]
        return par[i]
    def union(a, b):
        a_ = find_root(a)
        b_ = find_root(b)
        if a_ != b_:
            par[b_] = a_
        return
    for j in range(M):
        union(x[j], y[j])
    #print(par)
    ret = 0
    for i in range(N):
        val = p[i]
        idx = i + 1
        if val == idx or find_root(idx) == find_root(val):
            ret += 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    p = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    x = [int()] * (M)  # type: "List[int]" 
    y = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        x[i] = int(next(tokens))
        y[i] = int(next(tokens))
    solve(N, M, p, x, y)

if __name__ == '__main__':
    main()


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

int main() {
  int x, y, s;
  while (true) {
    cin >> x >> y >> s;
    if (x == 0) return 0;
    
    int max = 0;
    for (int i = 1; i <= s / 2; i++) {
      int t1 = i * (100 + x) / 100;
      for (int j = 1; j < s; j++) {
	int t2 = j * (100 + x) / 100;
	if (t1 + t2 != s) continue;
	int s1 = i * (100 + y) / 100;
	int s2 = j * (100 + y) / 100;
	if (s1 + s2 > max) max = s1 + s2;
      }
    }
    cout << max << endl;
  }
}

Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    string s , t ;
    cin >> s >> t ;
    sort(s.begin(),s.end()) ;
    sort(t.begin(),t.end(),greater<char>()) ;
  if(s<t) {
    cout <<"Yes"<< endl;
  }else {
    cout <<"No" << endl;
    }
    
  return 0;
}

Measured memory_bytes: 256
N = int(input())
aa = input()
b = []
b = aa.split(" ")
output = 0
a = []
flag = []
for i in range(len(b)):
    a.append(int(b[i]))
    flag.append(False)

for i in range(len(a)):
    if (i + 1 == a[a[i] - 1]):
        output = output + 1
        

print(output//2)

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

typedef long long LL;
typedef unsigned long long ULL;

const int PI = 3.141592653589793;
const int inf = 1000111222;
const int mod = 1000000007;
const int N = 200007;

int main(){

        ios_base::sync_with_stdio(0);
        cin.tie(0); cout.tie(0);

        int n; cin >> n;
        set <string> st;
        for (int i = 0; i < n; i++) {
                string s; cin >> s;
                st.insert(s);
        }
        cout << (int)st.size() << "\n";
        return 0;
}



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

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

ll f(ll x){
    ll k = 1;
    while(x != 1){
        k = k*x%mod;
        x--;
    }
    return k;
}

int main(){
    ll n,m;
    cin >> n >> m;
    ll t = abs(n-m);
    if(t > 1) cout << 0 << endl;
    else {
        ll a = f(n);
        ll b = f(m);
        ll ans = a*b%mod;
        if(t == 0)cout << ans*2%mod << endl;
        else cout << ans << endl;
    }
}

Measured memory_bytes: 3616
#!/usr/bin/perl
use Data::Dumper;

my ($n) = map { $_ - 0 } split(/\s+/,<STDIN>);
my @A = map { $_ - 0 } split(/\s+/,<STDIN>);
my @B = map { $_ - 0 } split(/\s+/,<STDIN>);

my %cA = ();
my %cB = ();
for(my $i=0;$i<$n;$i++){
  $cA{$A[$i]}++;
  $cB{$B[$i]}++;
}

foreach my $v ( keys %cA ){
  if( exists($cB{$v}) ){
    my $c = $cA{$v} - 0;
    if( $cB{$v} - 0 > $n - $c ){
      print "No\n"; exit(0);
    }
  }
}

print "Yes\n";
my $ib = 0;

for(my $i=0;$i<$n;$i++){
  if( $A[$i] == $B[$i] ){
    while( $i==$ib || $A[$i] == $B[$ib] || $A[$ib] == $B[$i] ){
      $ib++;
      $ib = 0 if $ib >= $n;
    }
    my $tmp = $B[$i];
    $B[$i] = $B[$ib];
    $B[$ib] = $tmp;
  }
}

$#B = $n - 1;
print ( join(' ',@B) . "\n");



Measured memory_bytes: 94420
n = int(input())
result = [0 ,0]

for i in range(n):
    a = input().split()
    if a[0] > a[1] :
        result[0] += 3
    if a[0] < a[1] :
        result[1] += 3
    if a[0] == a[1] :
        result[0] += 1
        result[1] += 1

print(' '.join(map(str,result)))



Measured memory_bytes: 5600
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        hoge();
        System.Console.ReadLine();
    }

    public static void hoge()
    {
        var vars = System.Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

        var x = vars[0];
        var y = vars[1];

        for(int i = 0; i <= x; i++)
        {
            if(2 * i + 4 * (x - i) == y)
            {
                Console.WriteLine("Yes");
                return;
            }
        }

        Console.WriteLine("No");

    }
}

Measured memory_bytes: 28156
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    int N,K;
    cin >> N >> K;

    int ans = 0;
    while(N>0)
    {
        N /= K;
        ans++;
    }

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

Measured memory_bytes: 256
Q,H,S,D=map(int,input().split())
N=int(input())
min1 = min(4*Q, 2*H, S)
min2 = min(8*Q, 4*H, 2*S, D)
if N%2==0:
    print(N//2*min2)
else:
    print(N//2*min2 + min1)


Measured memory_bytes: 61900
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
count =0
for i in range(N):
  if A[i] >= B[i]  and A[i] >= 0:
    count += B[i]
    A[i] = A[i] - B[i]
  elif A[i] < B[i] and A[i] >= 0:
    if A[i+1]-B[i]+A[i] > 0:
      count += B[i]
    else:
      count += A[i] +A[i+1]
    A[i+1] -=  B[i] - A[i]
    A[i] = -1
  elif A[i] < 0:
    if A[i+1] >= B[i]:
      count += B[i]
      A[i+1] = A[i+1]- B[i]
    else:
      count += A[i+1]
      A[i+1] -= B[i]
print(count)

Measured memory_bytes: 18752
S = input()
N = len(S) - 1

ans = 0
for i in range(2 ** N):
    equation = ""
    for j in range(N):
        equation += S[j]
        if (i >> j) & 1:
            equation += "+"
    equation += S[N]
    ans += sum(list(map(int, equation.split("+"))))

print(ans)


Measured memory_bytes: 9196
n = int(input())
s = input() + "@"
t = input() + "@"
mod = 10 ** 9 + 7

# 情報を1次元にして処理しやすくするぜ
# 縦で一致 True 横で一致 False
b = []
for i in range(n):
    if s[i] == s[i + 1]:
        continue
    b.append(s[i] == t[i])

# 処理するぜ
if b[0]:
    ans = 3
else:
    ans = 6

for i in range(1, len(b)):
    if b[i]:
        if b[i - 1]:
            ans *= 2
    else:
        if b[i - 1]:
            ans *= 2
        else:
            ans *= 3
    ans %= mod

print(ans)


Measured memory_bytes: 61936
N, x = map(int, input().split())
A = list(map(int, input().split()))
sum_A = sum(A)

if sum_A == x:
    print(N)
elif sum_A < x:
    print(N-1)
else:
    A = sorted(A)
    cnt = 0
    for a in A:
        x -= a
        if x >= 0:
            cnt += 1
        else:
            print(cnt)
            break


Measured memory_bytes: 9128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] ins = sc.nextLine().split(" ");
        long l = Integer.parseInt(ins[0]);
        long r = Integer.parseInt(ins[1]);
        long s = l % 2019;
        long t = r % 2019;
        if (t <= s) {
            System.out.println(0);
            return;
        }
        if ((r - l) / 2019 >= 1) {
            System.out.println(0);
            return;
        }
        long result = Integer.MAX_VALUE;
        for (long i = s; i <= t; i++) {
            for (long j = i + 1; j <= t; j++) {
                result = Math.min(result, (i * j) % 2019);
            }
        }
        System.out.println(result);
    }
}

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

int main()
{
    int N; cin >> N;
    vector<int> C(13);
    C[0] = 1;
    for (int i = 0; i < N; i++) {
        int d; cin >> d;
        C[d]++;
    }

    if (any_of(C.begin(), C.end(), [](int c){return c>=3;}) || C[0]==2 || C[12]==2) {
        cout << 0 << endl;
        return 0;
    }

    int ans = 0;
    int absent = 0;
    for (int i = 1; i <= 11; i++) {
        if (C[i] == 0) absent |= (1<<(i-1));
    }
    for (int b = 0; b < (1<<11); b++) {
        if (b & absent) continue;
        vector<int> D;
        for (int i = 1; i <= 11; i++) {
            if (C[i] == 2) {
                D.push_back(i);
                D.push_back(24-i);
            } else if (C[i] == 1) {
                D.push_back((b & (1 << (i-1))) ? 24-i : i);
            }
        }
        if (C[12] > 0) D.push_back(12);
        D.push_back(24);
        sort(D.begin(), D.end());

        vector<int> diffs(D.size());
        adjacent_difference(D.begin(), D.end(), diffs.begin());

        ans = max(ans, *min_element(diffs.begin(), diffs.end()));
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int n,m,a[N],c[N],b[N],d[N],idx,h[N],ne[N<<1],e[N<<1],w[N<<1];
void add(int a,int b,int c){e[idx]=b;ne[idx]=h[a];w[idx] =c;h[a]=idx ++;}
bool vis[N],use[N];
int get(int x)
{
    return lower_bound(d+1,d+1+n,x)-d;
}
// bool dfs(int u)
// {
//     vis[u]=true;
//     int x=c[u];
//     for(int i=h[u];~i;i=ne[i])
//     {
//         int v=e[i];
//         if(!vis[v]&&dfs(v))
//         {
//             x^=1;use[w[i]]=true;
//         }
//     }
//     return x;
// }
int dfs(int u)
{
  vis[u] = 1 ;
  int x = c[u] ;
  for(int i = h[u] ; ~i ; i = ne[i])
   {
     int v = e[i] ;
     if(!vis[v] && dfs(v))
      x ^= 1 , use[w[i]] = 1 ;
   }
  return x ;
}
int main()
{
    // scanf("%d%d",&n,&m);
    // for(int i = 0 ;i < N ;i ++) h[i] = -1 ;
    // for(int i=1;i<=n;i++)
    //     scanf("%d%d",&a[i],&b[i]),d[i]=a[i];
    // sort(d+1,d+1+n);
    // for(int i=1;i<=n;i++)
    //     a[i]=get(a[i]),c[a[i]]=b[i];
    // for(int i=n+1;i>=1;i--)
    //     c[i]^=c[i-1];
    // for(int i=1;i<=m;i++)
    // {
    //     int l,r;scanf("%d%d",&l,&r);
    //     l=get(l);
    //     r=upper_bound(d+1,d+1+n,r)-d -1;
    //     if(l<=r)
    //         add(l,r+1,i),add(r+1,l,i);
    // }
    for(int i = 0 ;i < N ;i ++) h[i] = -1 ;
    ios::sync_with_stdio(false) ;
    cin.tie(0) , cout.tie(0) ;
    cin >> n >> m ;
    for(int i = 1; i <= n ; i ++) cin >> a[i] >> b[i] , d[i] = a[i] ;
    sort(d + 1 , d + n + 1) ;
    for(int i = 1; i <= n ;i ++)
     c[get(a[i])] = b[i] ;
    for(int i = n + 1; i >= 1 ;i --) c[i] ^= c[i - 1] ;
    for(int i = 1; i <= m ;i ++)
     {
       int l , r ;
       cin >> l >> r ;
       l = get(l) , r = upper_bound(d + 1 , d + n + 1 , r) - d - 1 ;
       if(l <= r)
       add(l , r + 1 , i) , add(r + 1 , l , i) ;
     }
    // for(int i=1;i<=n+1;i++)
    //     if(!vis[i]&&dfs(i))
    // {
    //     cout << -1 << endl ;;return 0;
    // }
    // int ans=0;
    // for(int i=1;i<=m;i++)
    //     if(use[i]) ans++;
    // cout << ans << endl ;
    // for(int i=1;i<=m;i++)
    // if(use[i])
    //    cout << i << " " ;
    for(int i = 1; i <= n + 1 ;i ++)
     if(!vis[i] && dfs(i))
      {
        cout << -1 << endl ;
        return 0 ;
      }
      int ans =  0 ;
      for(int i = 1; i <= m ;i ++)
       if(use[i]) ans ++ ;
     cout << ans << endl ;
     for(int i = 1;i <= m ;i ++)
      if(use[i])
       cout << i << " " ;
}


Measured memory_bytes: 11008
/**
 *      ///----- My Info -----///
 *      Code by: Unk
 *      Codeforces User: Ernest0_0Abreu
 *      Country: Cuba
 *      E-mail: ernestoabreup@gmail.com
 *      CopyRight
**/
#include <bits/stdc++.h>
#ifdef Ernest0_0Abreu 
#include <debug/to_string.h>
#endif
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;
        ///----- My Template -----///
///===================================================================================================================================
/// Debug
#define _end cout << "\n"
#ifndef Ernest0_0Abreu
#define db(x) ;
#define dbrange(x,begin,end) ;
#define dbname(x) ;
#define dbnamerange(x,begin,end) ;
#define dbmat(x,begin_n,end_n,begin_m,end_m) ;
#define dbST(x,end) ;
#define db_end ;
#endif
///Function
#define pi ( acos(-1) )
#define lg2(x) ( 31-__builtin_clz(x) )
#define lgx(x,n) ( log(n) / log(x) )
/// Macros
#define fst first
#define scd second
#define left (node<<1)
#define right ((node<<1)+1)
#define _sz(x) (int)(x.size())
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
/// Typedef
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/// Constant
const int MAXN = 1e6+7;
const int MOD = 1e9+7;
const ull BASE = 311;
const ld EPS = 1e-9;
const int INF = ((1<<30)-1);
const ll INFLL = ((1ll<<62ll)-1ll);
const ll oo = 2e18;
/// Hash Prime Numbers: 2, 277, 293, 307, 331, 337, 1009, 2027, 3079, 10079;
/// Module Prime Numbers: 3, 200017, 1000033, 998244353, 1000000007, 1000000009, 1000000021;
#define int long long
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
///===================================================================================================================================
        ///----- My code -----///



int32_t main(){
    
    ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

	int k, x;
	cin >> k >> x;
	if(k*500 >= x)
		cout << "Yes";
	else cout << "No";
         
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;

struct edge {
    i64 from, to, cost;
    edge(i64 from, i64 to) : from(from), to(to), cost(1) {}
    edge(i64 from, i64 to, i64 cost) : from(from), to(to), cost(cost) {}
};
using Graph = vector<vector<edge>>;

constexpr i64 INF = std::numeric_limits<i64>::max();
constexpr i64 SINF = std::numeric_limits<i64>::max() / 10;
const i64 MOD = 1000000007;
const i64 dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
//const i64 dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//const i64 dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//const i64 dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e : t) fill_v(e, v);
}

struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main() {
    i64 a, b;
    cin >> a >> b;
    i64 tmp = a * 3 + b;
    cout << tmp / 2 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
      int s,h,m,i;
      int S;
      scanf("%d",&S);
      i=S%3600;
      s=i%60;
      m=(i-s)/60;
      h=(S-m*60-s)/3600;
      printf("%d:%d:%d\n",h,m,s);
      return 0;
}

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

int32_t main() 
{
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif 
  ios::sync_with_stdio(0); 
  cin.tie(0); cout.tie(0);
  
  string s;
  cin >> s;
  if(s.back() == 's')
    s += "es";
  else
    s += 's';

  cout << s;

  return 0;
}

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

#define i64 long long int

i64 a, b, g;
i64 q[5055];
int lq;

i64 gcd(i64 a, i64 b) { return b ? gcd(b, a%b) : a; }

int main() {
	cin>>a>>b;
	g = gcd(a, b);
	
	int ans = 1;
	for(i64 i = 2;i*i<=g;i++) {
		if (g%i) continue;
		ans++;
		while(g%i==0) g/=i;
	}
	if(g>1) ans++;
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int a, b; char c; cin >> a >> c >> b;
    if (c == '+')cout << a + b << "\n";
    else cout << a - b << "\n";
}


Measured memory_bytes: 256
// <sushi.cpp> - Sat Mar 25 08:49:56 2017
// This file is created by XuYike's black technology automatically.
// Copyright (C) 2015 ChangJun High School, Inc.
// I don't know what this program is.

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
typedef long long lol;
template<typename T>
inline void gg(T &res){
    res=0;T fh=1;char ch=getchar();
    while((ch>'9'||ch<'0')&&ch!='-')ch=getchar();
    if(ch=='-')fh=-1,ch=getchar();
    while(ch>='0'&&ch<='9')res=res*10+ch-'0',ch=getchar();
    res*=fh;
}
inline int gi(){int x;gg(x);return x;}
inline lol gl(){lol x;gg(x);return x;}
const int MAXN=100010;
const int MAXK=MAXN<<2;
const lol INF=1e18;
int n,pos[MAXN];
lol val[MAXK],lazy[MAXK],mi[MAXK];
inline void update(int x){
    val[x]=val[x<<1]+val[x<<1|1];
    mi[x]=min(mi[x<<1],mi[x<<1|1]);
}
void pushdown(int x,int l,int r){
    if(!lazy[x])return;
    int m=l+r>>1;
    val[x<<1]=(m-l+1)*lazy[x];
    val[x<<1|1]=(r-m)*lazy[x];
    mi[x<<1]=mi[x<<1|1]=lazy[x<<1]=lazy[x<<1|1]=lazy[x];
    lazy[x]=0;
}
lol getsum(int L,int R,int l=0,int r=n,int x=1){
    if(l==L&&r==R)return val[x];
    pushdown(x,l,r);
    int m=l+r>>1;lol ans=0;
    if(L<=m)ans+=getsum(L,min(R,m),l,m,x<<1);
    if(R>m)ans+=getsum(max(L,m+1),R,m+1,r,x<<1|1);
    return ans;
}
int find(int p,lol s,lol y,int l=0,int r=n,int x=1){
    if(l==r)return l;
    pushdown(x,l,r);
    int m=l+r>>1;
    if(p<=m||s-val[x<<1]+y>mi[x<<1]*(p-m))return find(p,s,y,l,m,x<<1);
    return find(p,s-val[x<<1],y,m+1,r,x<<1|1);
}
void set(int L,int R,lol v,int l=0,int r=n,int x=1){
    if(L>R)return;
    if(l==L&&r==R){
        val[x]=(r-l+1)*v;
        lazy[x]=mi[x]=v;
        return;
    }
    pushdown(x,l,r);
    int m=l+r>>1;
    if(L<=m)set(L,min(R,m),v,l,m,x<<1);
    if(R>m)set(max(L,m+1),R,v,m+1,r,x<<1|1);
    update(x);
}
void dfs(int l,int r,int x){
    if(l==r){
        if(l!=n)printf("%lld\n",val[x]);
        return;
    }
    pushdown(x,l,r);
    int m=l+r>>1;
    dfs(l,m,x<<1);
    dfs(m+1,r,x<<1|1);
}
int main(){
    n=gi();int m=gi();
    while(m--){
        int x=gi()-1;
        lol s=getsum(0,x),y=gl();
        int p=find(x,s,y);s=getsum(p,x);
        set(p,x,(y+s)/(x-p+1));
        set(p,p+(y+s)%(x-p+1)-1,(y+s)/(x-p+1)+1);
    }
    dfs(0,n,1);
    return 0;
}

Measured memory_bytes: 9856
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define vsort(v) sort(v.begin(),v.end())
#define asort(a,n) sort(a, a + n)
#define vi vector<int>
#define vd vector<double>

//ここからAtCoder向けdefine
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vi vec(n);
    vi ary(n + 1);
    rep(i, n){
        cin >> vec[i];
        ary[vec[i]]++;
    }
    vsort(ary);
    // REP(i, 1, n + 1){
    //     cout << ary[i] << endl;
    // }
    int cnt = 0;
    rep(i, n - k + 1){
        cnt += ary[i];
    }

    cout << cnt << endl;


    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>

using namespace std;

int main() {
  int a, b;

  cin >> a >> b;

  int taka=0;
  bool out=false;
  for (int i =1;i<=a;i++){
    for (int j=1; j <= 31; ++j) {
      if(j>b and i==a){
        out=true;
        break;
      }
      if(i==j){
        taka++;
      }
    }
    if(out)
      break;
  }
  cout << taka << endl;
}


Measured memory_bytes: 256
/**
 * Heaps - Complete Binary Tree
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		int h = parseInt(br.readLine());
		int[] heap = new int[h + 5];
		StringTokenizer st = new StringTokenizer(br.readLine());
		for (int i = 1; i < h + 1; i++) {
			heap[i] = parseInt(st.nextToken());
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i < h + 1; i++) {
			sb.append(String.format("node %d: key = %d, ", i, heap[i]));
			if (i / 2 > 0) {
				sb.append(String.format("parent key = %d, ", heap[i / 2]));
			}
			if (i * 2 <= h) {
				sb.append(String.format("left key = %d, ", heap[i * 2]));
			}
			if (i * 2 + 1 <= h) {
				sb.append(String.format("right key = %d, ", heap[i * 2 + 1]));
			}
			sb.append("\n");
		}
		System.out.print(sb.toString());
	} //end main
}

Measured memory_bytes: 22948
#include <iostream>
#include <string>
#include <vector>
#include <map>

using namespace std;
using ll = long long int;

int main()
{
    string S, T;
    cin >> S >> T;

    map<char, char> mp;
    for (ll i = 0; i < 26; i++)
    {
        mp['a' + i] = '_';
    }
    
    bool ok = true;
    for (ll i = 0; i < S.size(); i++)
    {
        if (mp[S[i]] != '_' && mp[S[i]] != T[i]) {
            ok = false;
        }
        mp[S[i]] = T[i];
    }

    mp.clear();
    for (ll i = 0; i < 26; i++)
    {
        mp['a' + i] = '_';
    }
    
    for (ll i = 0; i < T.size(); i++)
    {
        if (mp[T[i]] != '_' && mp[T[i]] != S[i]) {
            ok = false;
        }
        mp[T[i]] = S[i];
    }
    cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3856
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const long long INF = 1LL<<60;
const int MAX = 210;

int N, M, R;
long long dist[MAX][MAX];

int main() {
    cin >> N >> M >> R;
    vector<int> vr;
    for (int i = 0; i < R; ++i) {  int r; cin >> r; --r; vr.push_back(r); }
    
    // Floyd-Warshall の初期化: dist[i][i] = 0 に注意
    for (int i = 0; i < 210; ++i) {
        for (int j = 0; j < 210; ++j) dist[i][j] = INF;
        dist[i][i] = 0;
    }
    
    // 入力と Floyd-Warshall
    for (int i = 0; i < M; ++i) {
        int a, b, c; cin >> a >> b >> c; --a, --b;
        dist[a][b] = c;
        dist[b][a] = c;
    }
    for (int k = 0; k < N; ++k)
        for (int i = 0; i < N; ++i)
            for (int j = 0; j < N; ++j)
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);

    // R! 通りの探索
    long long res = INF;
    sort(vr.begin(), vr.end());
    do {
        long long tmp = 0;
        for (int i = 1; i < vr.size(); ++i) tmp += dist[vr[i]][vr[i-1]];
        res = min(res, tmp);
    } while (next_permutation(vr.begin(), vr.end()));

    cout << res << endl;
}

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

ll modpow(ll a,ll n,ll mod){
    ll res=1;
    while(n>0){
        if(n&1)res=res*a%mod;
        a=a*a%mod;
        n>>=1;
            }
        return res;
}

ll modinv(ll a, ll mod) {
    return modpow(a, mod - 2, mod);
}
 
const int MAX = 510000;
const ll MOD = 1000000007;
 
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
    ll n,a,b;cin>>n>>a>>b;
    COMinit();
    ll v1=1;
    for(ll i=n;i>n-a;i--){
        v1*=i;
        v1%=MOD;
    }
    ll v2=1;
    for(ll i=n;i>n-b;i--){
        v2*=i;
        v2%=MOD;
    }
    v1*=finv[a];
    v2*=finv[b];
    v1%=MOD;
    v2%=MOD;
    ll ans=modpow(2,n,MOD)-1-v1-v2;
    ans+=10*MOD;
    ans%=MOD;
    cout<<ans<<endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++)cin >> a[i];
    for(int i=0;i<n;i++)cin >> b[i];
    for(int i=0;i<n;i++)cin >> c[i];
    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);
    
    long long int ans = 0;
    for(int i=0;i<n;i++){
        //aを求める
        auto p1 = lower_bound(a,a+n,b[i]);
        long long int dis1 = distance(a,p1);
        //bを求める
        auto p2 = upper_bound(c,c+n,b[i]);
        int index = distance(c,p2);
        long long int dis2 = n-index;
        
        ans += dis1*dis2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1408
from math import gcd
def solve():
  N, M = map(int, input().split())
  S = input()
  T = input()
  g = gcd(N,M)
  ans = N*M//g
  for i in range(g):
    if S[N//g*i]!=T[M//g*i]:
      return -1
  return ans
print(solve())

Measured memory_bytes: 9224
atoe =[int(input()),int(input()),int(input()),int(input()),int(input())]
k = int(input())

maxNum = 5
_err = 0
for i in range(0, maxNum):
    for j in range(i+1, maxNum):
        if abs(atoe[i] - atoe[j]) > k:
            _err = 1

if _err:
    print(":(")
else:
    print("Yay!")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	for (auto& x : A) cin >> x;
	long long res = 1;
	int l = 0;
	int x = A[0];
	for (int r = 1; r < N; ++ r) {
		while (x & A[r]) {
			x &= ~A[l++];
		}
		x |= A[r];
		res += r-l+1;
	}
	cout << res << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
int f[N], sz[N];
int findf(int x)
{
	if(x == f[x])	return x;
	f[x] = findf(f[x]);
	return f[x]; 
}
void link(int x, int y)
{
	int fx = findf(x);
	int fy = findf(y);
	if(fx != fy)
	{
		f[fx] = fy;
		sz[fy] += sz[fx];
	}
}
int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n; i++)
		f[i] = i, sz[i] = 1;
	for(int i = 1; i <= m; i++)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		link(x, y);
	}
	int ans = 0;
	for(int i = 1; i <= n; i++)
		ans = max(ans, sz[i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5240
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#define MOD 1000000007
#define SIZE 100005

using namespace std;
typedef long long int ll;

ll inv[SIZE],fac[SIZE],finv[SIZE];
void make()
{
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<SIZE;i++)
	{
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		fac[i]=fac[i-1]*(ll) i%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}
ll C(int a,int b)
{
	if(a<b) return 0;
	return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}
int id[SIZE];

int main()
{
	make();
	int n;
	scanf("%d",&n);
	memset(id,-1,sizeof(id));
	int s,t;
	for(int i=0;i<=n;i++)
	{
		int a;
		scanf("%d",&a);a--;
		if(id[a]==-1) id[a]=i;
		else
		{
			s=id[a];
			t=i;
		}
	}
	for(int i=1;i<=n+1;i++)
	{
		ll ret=C(n+1,i);
		ret-=C(s+(n-t),i-1);
		if(ret<0) ret+=MOD;
		
		printf("%lld\n",ret);
	}
	return 0;
}


Measured memory_bytes: 3840
#include <iostream>
#include <string>
using namespace std;
int main(void){
  string a,b,c;
  int n,cnt=0,d=0;
  
  cin>>n>>a>>b>>c;
  
  for(int i=0;i<n;i++){
      cnt=0;
      if(a[i]==b[i] && a[i]==c[i]) continue;
      else if(a[i]==b[i]) cnt++;
      else if(c[i]==b[i]) cnt++;
      else if(c[i]==a[i]) cnt++;
      
      if(cnt==0) d+=2;
      else if(cnt==1) d+=1;
      
  }
  cout<<d<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

class UnionFind {
public:
    // 親の番号を格納する。親だった場合-size
    vector<int> parents;

    UnionFind(int n) {
        parents = vector<int>(n, -1);
    }

    // aがどのグループに属しているか
    int root(int a) {
        if (parents[a] < 0) {
            return a;
        }
        return parents[a] = root(parents[a]);
    }

    int size(int a) {
        return -parents[root(a)];
    }

    // aとbをくっつける
    bool connect(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        if (ra == rb) {
            return false;
        }
        // 大きいほうにA
        if (size(ra) < size(rb)) {
            swap(ra, rb);
        }
        parents[ra] += parents[rb];
        parents[rb] = ra;
        return true;
    }

    bool is_union(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        return ra == rb;
    }
};

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

    vector<P> bridges(m);
    for (P &p : bridges) cin >> p.first >> p.second, p.first--, p.second--;

    reverse(bridges.begin(), bridges.end());

    ll all = ll(n) * (n - 1) / 2;

    vector<ll> ans = {all};

    UnionFind uf(n);
    for (P p : bridges) {

        if (uf.is_union(p.first, p.second)) {
            ans.push_back(ans.back());
            continue;
        }

        ll a = uf.size(p.first);
        ll b = uf.size(p.second);

        uf.connect(p.first, p.second);
        ll prev = ans.back();
        ll add = a * b;
        ll next = prev - add;
        ans.push_back(next);
    }

    ans.pop_back();

    reverse(ans.begin(), ans.end());

    for (ll a : ans) cout << a << endl;

}


Measured memory_bytes: 6216
fun main(args: Array<String>) {
    val n = readInputLine().toInt()
    val a = readInputLine().split(" ").map { it.toLong() }
    
    // 偶数インデックスが正数のパターン
    var sum = 0L
    var ans1st = 0L
    for (i in 0 until n) {
        sum += a[i]
        if (i % 2 == 0) {
            if (sum <= 0L) {
                ans1st += -sum + 1L
                sum = 1L
            }
        } else {
            if (sum >= 0L) {
                ans1st += sum + 1L
                sum = -1L
            }
        }
    }
    
    // 偶数インデックスが負数のパターン
    sum = 0L
    var ans2nd = 0L
    for (i in 0 until n) {
        sum += a[i]
        if (i % 2 == 0) {
            if (sum >= 0L) {
                ans2nd += sum + 1L
                sum = -1L
            }
        } else {
            if (sum <= 0L) {
                ans2nd += -sum + 1L
                sum = 1L
            }
        }
    }
    
    println(if (ans1st < ans2nd) ans1st else ans2nd)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 53512
#include<bits/stdc++.h>
using namespace std;
typedef signed long long ll;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
	int i,j,n,m,l,f,x,y,z; string s;
	ll k, a, b;
	cin >> k >> a >> b;
	if(a >= b-2 || k <= a){
		cout << k + 1 << endl;
		return 0;
	}

	ll cnt = 1;
	for(i = 1; i<=k; i++){
		if(i >= a && k-i >= 1){
			cnt += b-a;
			i++;
			continue;
		}
		cnt += 1;
	}

	cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define debug(n) cout << "DEBUG1 " << n << "\n";
#define debug2(n, m) cout << "DEBUG2 " << n << ' ' << m << "\n";
#define debug3(n, m, x) cout << "DEBUG3 " << n << ' ' << m << ' ' << x << "\n";
#define debug4(n, m, x, y) cout << "DEBUG3 " << n << ' ' << m << ' ' << x << ' ' << y << "\n";
#define ss_def stringstream ss // stringstream, do ss_def(str), then ss >> n (n is int)
#define upzero(n) rrn < 0) n = 0
#define alive(n) cout << "Alive here: checkpoint " << n << endl
#pragma GCC optimize("Ofast")
using namespace std;
void yes() {
    cout << "Ywa\n";
    return;
}
void no() {
    cout << "No\n";
    return;
}
void solve(int case_no) {
    // implementation
    int a, b, c;
    cin >> a >> b >> c;
    int sum = ceil(a * 1.0 / b);
    sum *= c;
    cout << sum << endl;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    srand(time(NULL));
    int t = 1;
//    cin >> t;
    for (int i = 1;i <= t;i++) solve(i);
}
/*

*/

Measured memory_bytes: 3688
import heapq

n,m = (int(i) for i in input().split())
jobs = [[] for i in range(m)]
for i in range(n):
    tmp,tmp2 = (int(i) for i in input().split())
    if(tmp>m):
        continue
    jobs[m-tmp].append(tmp2)
    
ans = 0
h=[]
for i in range(m-1,-1,-1):
    for b in jobs[i]:
        heapq.heappush(h,-b)
        
    if(len(h)!=0):
        a = -heapq.heappop(h)
        ans += a

print(ans)

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

int main() {
  int a,b,c,x,y;
  cin>>a>>b>>c>>x>>y;
  int kotae=a*x+b*y;
  for(int i=0;i<=max(x,y);i++){
    if(x-i<=0)a=0;
    if(y-i<=0)b=0;
    kotae=min(kotae,a*(x-i)+b*(y-i)+c*2*i);
  }           
  cout <<kotae<<endl;
}

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

// @author: pashka

vector<vector<int>> g;
vector<int> d1, d2;
vector<bool> z;

int res = 0;

void dfs(int x, int p, vector<int> &d) {
    for (int y : g[x]) {
        if (y != p) {
            d[y] = d[x] + 1;
            dfs(y, x, d);
        }
    }
}

void dfs2(int x, int p) {
    if (!z[x]) return;
    res = max(res, d2[x]);
    for (int y : g[x]) {
        if (y != p) {
            dfs2(y, x);
        }
    }
}

int main() {
    ios::sync_with_stdio(false);

    int n, u, v;
    cin >> n >> u >> v;
    g.resize(n);
    u--; v--;
    for (int i = 0; i < n - 1; i++) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    d1.resize(n); d2.resize(n);
    z.assign(n, true);
    dfs(u, -1, d1);
    dfs(v, -1, d2);
    for (int i = 0; i < n; i++) {
        if (d2[i] <= d1[i]) {
            z[i] = false;
        }
    }

    dfs2(u, -1);

    res--;
    cout << res;

    return 0;
}

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

public class Main {

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

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      StringBuffer buf = new StringBuffer();
      while(true) {
        Container target = new Container();
        String[] lines = in.readLine().split(" ");
        target.w = Integer.parseInt(lines[0]);
        target.h = Integer.parseInt(lines[1]);

        if(target.h == 0 && target.w == 0) break;

        target.createTable();

        String line;
        for(int i=0; i<target.h; i++) {
          line = in.readLine();
          for(int j=0; j<target.w; j++) {
            target.table[i][j] = line.charAt(j<<1) == '1' ? true : false;
          }
        }

        int ans = solve(target);
        buf.append(ans).append("\n");
      }

      System.out.print(buf);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }

  private int solve(Container t) {
    int ret = 0;

    for(int y=0; y<t.h; y++) {
      for(int x=0; x<t.w; x++) {
        if(t.table[y][x]) {
          dfs(t, x,y);
          ret++;
        }
      }
    }

    return ret;
  }

  private void dfs(Container t, int x, int y) {
    t.table[y][x] =false;

    for(int dy=-1; dy<=1; dy++) {
      for(int dx=-1; dx<=1; dx++) {
        int ny = y + dy, nx = x + dx;
        if(0<=ny && ny<t.h && 0<=nx && nx<t.w && t.table[ny][nx])
          dfs(t, nx, ny);
      }
    }
    return;
  }
}

class Container {
  int h;
  int w;
  boolean[][] table;

  public void createTable() {
    table = new boolean[h][w];
  }
}


Measured memory_bytes: 25260
import itertools

n, x = -1, -1
dataset = []

while True:
    n, x = map(int, input().split())
    if n == x == 0:break
    
    dataset.append([n, x])

for data in dataset:
    c = 0
    arr = [x + 1 for x in range(data[0])]
    for v in itertools.combinations(arr, 3):
        if sum(v) == data[1]: c +=1
    print(c)


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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] ab = br.readLine().split(" ");
        int a = Integer.parseInt(ab[0]);
        int b = Integer.parseInt(ab[1]);
        System.out.println(problem127a(a, b));
    }

    private static int problem127a(int a, int b) {
        if (a >= 13) {
            return b;
        } else if (a <= 5) {
            return 0;
        }
        return (b / 2);
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	rep(i, tx - sx) {
		cout << 'R';
	}
	rep(i, ty - sy+1) {
		cout << 'U';
	}
	rep(i, tx - sx+1) {
		cout << 'L';
	}
	rep(i, ty - sy+1) {
		cout << 'D';
	}
	cout << "RD";
	rep(i, tx - sx+1) {
		cout << 'R';
	}
	rep(i, ty - sy + 1) {
		cout << 'U';
	}
	rep(i, tx - sx + 1) {
		cout << 'L';
	}
	rep(i, ty - sy) {
		cout << 'D';
	}
}



Measured memory_bytes: 256