akhauriyash/Code-Regression huggingface dataset:
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA
*/
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
using namespace std::tr1;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld\n",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli,lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
#define nl cout<<"\n"
#define MX1 100005
#define MX2 1000005
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};
lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif*/
    opt;
    lli n;
    cin>>n;
    lli x[n+1],y[n+1],t[n+1],i,flag=0;
    rep(i,1,1+n)
    {
        cin>>t[i]>>x[i]>>y[i];
    }
    x[0]=0;
    y[0]=0;
    t[0]=0;
    rep(i,1,1+n)
    {
        lli dist=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
        if(t[i]-t[i-1]<dist)
        {
            flag=1;
        }
        if(dist%2!=(t[i]-t[i-1])%2)
        {
            flag=1;
        }
    }
    if(flag)
    {
        cout<<"No";
    }
    else
    {
        cout<<"Yes";
    }
}


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

using namespace std;

int main()
{
    int N,K;
    while(cin>>N>>K)
    {
        int i,cnt=0;
        for(i=1;i<=N;i++)
        {
            int h;
            cin>>h;
            if(h>=K)
                cnt++;
        }
        cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
h = list(map(int, input().split()))
 
S = [0] * N
S[0] = 0
 
for i in range(1, N):
    value = S[i - 1] + abs(h[i] - h[i - 1])
    maxStep = min(K, i)
    for step in range(1, maxStep + 1):
        value = min(value, S[i - step] + abs(h[i] - h[i - step]))
    S[i] = value
print(S[N - 1])

Measured memory_bytes: 84972
n,k=map(int,input().split())

a=range(n+1)

max=sum(a[n+1-k:])
min=sum(a[:k])
ans=max-min+1
if n+1==k:
  print(ans)
  exit()
for i in range(k+1,n+2):
    max += a[n+1-i]
    min += a[i-1]
    ans += max-min+1
print(ans%(10**9+7))


Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    string a;
    cin>>a;
    if(a.size()<=n)
        cout<<a;
    else
    {
        string b="...";
        cout<<a.substr(0,n)+b;
    }
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int cnt[10];

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

    for(int i=0;i<3;++i){
        int a, b;
        std::cin >> a >> b;

        cnt[a] += 1;
        cnt[b] += 1;
    }

    int odd_n = 0, nonzero_n = 0;
    for(int i=1;i<=4;++i){
        if(cnt[i] % 2 == 1){
            odd_n += 1;
        }

        if(cnt[i] > 0){
            nonzero_n += 1;
        }
    }

    if(odd_n == 2 && nonzero_n == 4){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,sum=0;
  cin >>n;
  vector<int> w(n),an(n);
  for(int i=0;i<n;++i){
    cin>>w[i];
    sum+=w[i];
    if(i!=0)
      w[i]+=w[i-1];
  }
      an[0]=w[0];
  int mi=1000000;
  for(int i=0;i<n;++i){
    mi=min(mi,abs(w[i]-(sum-w[i])));
  }
  cout<<mi<<endl;
}

Measured memory_bytes: 3596
N,M = map(int,input().split())
seito = 0
penarty = 0
pena = [False for i in range(N+1)]
pena2 = [0 for i in range(N+1)]
for i in range(M):
    p,s = input().split()
    p = int(p)
    if not pena[p]:
        if s == "AC":
            pena[p]=True
            seito += 1
        else:
            pena2[p] += 1

for i in range(N+1):
    if pena[i]:
        penarty += pena2[i]
print(seito,penarty)

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

const int maxn = 1003;

int n;
int mp[maxn][maxn];
int cnt = 0;
vector<int> g[maxn * maxn];
int in[maxn * maxn];

int main(int argc, char const *argv[])
{
	// freopen("in", "r", stdin);
	cin >> n;
	for(int i = 1; i <= n; i++) {
		for(int j = i + 1; j <= n; j++) {
			mp[i][j] = ++cnt;
		}
	}
	for(int i = 1; i <= n; i++) {
		int prv; cin >> prv;
		for(int k = 1; k < n - 1; k++) {
			int nxt; cin >> nxt;
			int u, v;
			if(i > prv) u = mp[prv][i];
			else u = mp[i][prv];
			if(i > nxt) v = mp[nxt][i];
			else v = mp[i][nxt];
			g[u].emplace_back(v);
			in[v]++;
			prv = nxt;
		}
	}
	int done = 0, ans = 0;
	vector<int> Q;
	for(int i = 1; i <= n * (n - 1) / 2; i++) {
		if(in[i] == 0) {
			Q.emplace_back(i);
		}
	}
	while(Q.size()) {
		ans++;
		done += Q.size();
		vector<int> cur;
		for(int u : Q) {
			for(int v : g[u]) {
				in[v]--;
				if(in[v] == 0) {
					cur.emplace_back(v);
				}
			}
		}
		Q = cur;
	}
	if(done < n * (n - 1) / 2) {
		cout << "-1" << endl;
	} else {
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 47232
#include <cstdio>

typedef long long LL;
const int MX = 10005, MP = 2005;
const int MN = 505;

bool ip[MX];
int p[MP], pc;
inline void Sieve(int N) {
	for (int i = 2; i <= N; ++i) {
		if (!ip[i]) p[++pc] = i;
		for (int j = 1, k; j <= pc; ++j) {
			if ((k = p[j] * i) > N) break;
			ip[k] = 1;
			if (i % p[j] == 0) break;
		}
	}
}

int N, A[MN], B[MN];

int main() {
	Sieve(10000);
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) A[i] = p[i & 1 ? i / 2 + 1 : N + N - i / 2 + 1];
	for (int i = 1; i <= N; ++i) B[i] = p[(i & 1 ? N - i / 2 : N + i / 2) + (N & 1)];
	A[0] = A[N + 1] = B[0] = B[N + 1] = 1;
	for (int i = 1; i <= N; ++i, puts(""))
		for (int j = 1; j <= N; ++j)
			if ((i + j) % 2) printf("%lld ", (LL)A[(i + j) / 2] * A[(i + j) / 2 + 1] * B[(N + i - j + (N & 1)) / 2] * B[(N + i - j + (N & 1)) / 2 + 1] + 1);
			else printf("%d ", A[(i + j) / 2] * B[(N + i - j + (N & 1)) / 2]);
	return 0;
}

// Luogu : PinkRabbit

Measured memory_bytes: 3072
#include <stdio.h>
int main(){
  
    int i=0,j;
    char S[128];
  
    scanf("%s", S);
    
    while(S[i] != '\0'){
      ++i;
    }
      
    if(i == 2){
      for(j = 0; j < 2; j++){
        printf("%c", S[j]);
      }
    }
    else if(i == 3){
      for(j = 2; j >= 0; j--){
        printf("%c", S[j]);
      }
    }
  
    return 0;
}
      


Measured memory_bytes: 128
const processData = (lines) => {
  const [N, M] = lines[0].split(' ').map(x => +x)
  const take = lines[1].split(' ').map(x => +x).reduce((r,x ) => r+x, 0)
  if (take > N) {
    console.log(-1)
  } else {
    console.log(N-take)
  }
}

let i = ''
process.stdin.on('data', c => i += c)
process.stdin.on('end', () => {
  const {EOL} = require('os')
  const lines = i.split(EOL) /*your input text, split by lines*/
  processData(lines)
})


Measured memory_bytes: 30756
H, W, N = [int(x) for x in input().split()]

dxy = [(-1, -1), (-1, 0), (-1, 1),
       (0, -1), (0, 0), (0, 1),
       (1, -1), (1, 0), (1, 1)]

count = {}
ans = [0 for x in range(10)]
ans[0] = (H - 2) * (W - 2)

for _ in range(N):
    x, y = [int(x) for x in input().split()]
    for dx, dy in dxy:
        xx = x + dx
        yy = y + dy
        if 2 <= xx <= H - 1 and 2 <= yy <= W - 1:
            if (xx, yy) in count:
                count[(xx, yy)] += 1
            else:
                count[(xx, yy)] = 1

for i in count.values():
    ans[0] -= 1
    ans[i] += 1
for i in ans:
    print(i)

Measured memory_bytes: 166576
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
using ll = long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

const int MN = 2020;
const int ML = 100100;
int n, m;
ll l;
int k[MN];
ll s[ML], ssm[ML];

ll gt(int a, int b) {
    return (ssm[k[b]+1]-ssm[k[a]])/l;
}


ll calc(int a, int b) {
    if (a > b) return calc(b, a);
    if (b == n-2) {
        return gt(a, n-1)+gt(b, n-1);
    }
    static ll dp[MN][MN];
    static bool used[MN][MN];
    if (used[a][b]) return dp[a][b];
    used[a][b] = true;
    ll &ans = dp[a][b];
    ans = TEN(16);
    ans = min(ans, calc(b+1, b)+gt(a, b+1));
    ans = min(ans, calc(a, b+1)+gt(b, b+1));
    return ans;
}

int main() {
    cin >> n >> m >> l;
    for (int i = 0; i < n; i++) {
	cin >> k[i]; k[i]--;
    }
    sort(k, k+n);
    for (int i = 0; i < m; i++) {
	cin >> s[i];
    }
    ssm[0] = 0;
    for (int i = 0; i < m; i++) {
	ssm[i+1] = s[i]+ssm[i];
    }
    cout << calc(0, 0) << endl;
    return 0;
}

Measured memory_bytes: 31384
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void solve() {
	int x, y;
	while (cin >> x >> y) {
		if (x == 0 && y == 0)break;
		if (x > y)swap(x, y);
		cout << x << " " << y << endl;
	}
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}



Measured memory_bytes: 3120
#include <stdio.h>

int main(void)
{
  int n, odd;
  scanf("%d\n", &n);
  if (n == 1)
  {
    printf("%.10f\n", 1.0);
    return 0;
  }
  else if (n % 2 == 0)
  	odd = n / 2;
  else if (n % 2 == 1)
    odd = (n-1) / 2 + 1;
  
  printf("%.10lf\n", (double)odd / n);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define SZ(x) ((int)(x.size()))
#define FOR(i,s,n) for (ll i = (s); (i) < (n); ++i)
#define FORD(i,s,l) for (ll i = (s); (i) >= l; --i)
#define F first
#define S second
#define TC int __tc; cin >> __tc; FOR(case_num,1,__tc+1)
#define TEST(x,i) ((x)&(1ll<<(i)))
#define SET(x,i) ((x)|(1ll<<(i)))
#define FLIP(x,i) ((x)^(1ll<<(i)))
#define CLEAR(x,i) ((x)&~(1ll<<(i)))

const double pi = 4 * atan(1);
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
const int MAXN = 200005;


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n, k;
	cin >> n >> k;
	
	vector<ll> pos;
	vector<ll> neg;
	bool zero = false;
	
	for (int i = 0; i < n; i++){
		ll a;
		cin >> a;
		if (a < 0) {
			neg.pb(a);
		} else if (a > 0) {
			pos.pb(a);
		} else {
			zero = true;
		}
	}
	
	ll p = 1;
	
	if ( 2*min(k/2,SZ(neg)/2) + SZ(pos) >= k) {
		//can be positive
		
		sort(pos.begin(),pos.end());
		sort(neg.begin(),neg.end(),greater<ll>());
		
		if (k%2 == 1) {
			p*=pos.back(); pos.pop_back();
			p%=MOD;
			k--;
		}
		
		vector<ll> f;
		
		for (int i = SZ(neg)-1; i >= 1; i-=2) {
			f.pb((neg[i]*neg[i-1]));
		}
		for (int i = SZ(pos)-1; i >= 1; i-=2) {
			f.pb((pos[i]*pos[i-1]));
		}
		
		sort(f.begin(),f.end());
		
		while(k) {
			p*=f.back()%MOD; f.pop_back();
			p%=MOD;
			k-=2;
		}
		
		cout << p << "\n";
	} else if (zero) {
		cout << 0 << "\n";
	} else {
		
		vector<ll> absolute;
		for (auto v : neg) {
			absolute.pb(llabs(v));
		}
		for (auto v : pos) {
			absolute.pb(llabs(v));
		}
		sort(absolute.begin(),absolute.end());
		
		for (int i = 0; i < k; i++){
			p*=absolute[i];
			p%=MOD;
		}
		p = MOD-p;
		
		cout << p << "\n";

	}
	
	

}


Measured memory_bytes: 6856
export class Main {
  static main(input: string): string {
    const tmp: string[] = input.split("\n");
    const [a, b]: number[] = tmp.shift().split(" ").map(int => parseInt(int));
    return `${a * b}`;
  }
}
console.log(Main.main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 29628
from collections import defaultdict


def key(pair):
    _, n = pair
    return n


def partitionize(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if key(A[j]) <= key(x):
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1


def quick_sort(A, p, r):
    if p < r:
        q = partitionize(A, p, r)
        quick_sort(A, p, q - 1)
        quick_sort(A, q + 1, r)


def is_stable(ordered, original):
    scanned_ordered = defaultdict(list)
    scanned_original = defaultdict(list)
    for a, b in zip(ordered, original):
        s, n = a
        scanned_ordered[n].append(s)
        t, m = b
        scanned_original[m].append(t)
    for k in scanned_ordered:
        if scanned_ordered.get(k, "__NaN_1__") != scanned_original.get(k, "__NaN_2__"):
            return False
    return True


N = int(input())
A = []
for _ in range(N):
    s, n = input().split()
    A.append((s, int(n)))
sorted_A = A.copy()
quick_sort(sorted_A, 0, N - 1)
print("Stable" if is_stable(sorted_A, A) else "Not stable")
for s, n in sorted_A:
    print(s, n)



Measured memory_bytes: 25136
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<char>());
  int x = min(s.size(), t.size());
  bool judge = false;
  if (s.size() < t.size()) judge = true;
  for (int i = 0; i < x; i++) {
    if (t[i] - s[i] > 0) {
      judge = true;
      break;
    } else if (t[i] - s[i] == 0) {
      continue;
    } else {
      judge = false;
      break;
    }
  }
  cout << (judge ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0, i##_len=(lli)(n); i<i##_len; i++)
#define repf(i, n) for(lli i=1, i##_len=(lli)(n+1); i<i##_len; i++)
#define per(i, n) for(lli i=((lli)(n))-1; i>=0; i--)
#define perf(i, n) for(lli i=((lli)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n; string s; cin >> n >> s;
    lli cnt = 0;

    char c = '\0';
    rep(i, n){
        if(s.at(i) != c){
            cnt++;
            c = s.at(i);
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    int n,t,temp,a[100],b[100],i,k,cnt=0,j=0,r;
    scanf("%d",&n);
    t=n;
    while(t!=0)
    {
        temp=t%10;
        a[cnt]=temp;
        t=t/10;
        cnt++;
    }
    t=n;
    while(t!=0)

    while(t!=0)
    {
        t=t/10;
        b[j]=t;
        t=t%10;
        j++;
    }
    b[j-1]=a[0];
    for(i=0;i<cnt;i++)
    {
        for(k=0;k<j;k++)
        {
            if(a[i]==b[k])
            {
                r=1;
            }
            else
            {
                r=0;
            }
        }
    }
    if(r==1)
    {
        printf("Yes\n");
    }
    else if(r==0)
    {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
    int a, b, c, ans = 0;
    scanf("%d %d %d", &a, &b, &c);
    for(int i=a; i<=b; i++){
        if(c%i == 0){
            ans = ans + 1;
        }
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll a,b;
  cin >> a >> b;
  if(a==b){
    cout << 0;
  } else {
    if((b-a)%2 == 0){
      cout << (a+b)/2;
    } else {
      cout << "IMPOSSIBLE";
    }
  }
 return 0;
}


Measured memory_bytes: 256
import numpy as np
from fractions import gcd
def lcm(a,b):
  return a*b//gcd(a,b)
N,M=map(int,input().split())
a=[i//2 for i in map(int,input().split())]
b=np.array(a)
cnt=0
while all(b%2==0):
  b//=2
if any(b%2==0):
  print(0)
  exit()
ans=1
for i in a:
  ans=lcm(ans,i)
print((M//ans-1)//2+1)


Measured memory_bytes: 24932
import math
r = 9999
sqrt = int(math.sqrt(r))
p = [1 for i in range(r)]
p[0] = 0
for i in range(sqrt):
    if p[i]:
        p[2*i+1::i+1] = [0 for j in range(2*i+1,r,i+1)]
prime = []
for i in range(r):
    if p[i]:
        prime.append(i)

while True:
    try:
        n = int(raw_input())
        count = 0
        for i in prime:
            if i > n-1:
                break
            if p[n-i-1] == 1:
                count += 1
        print count
    except:
        break

Measured memory_bytes: 4760
package main

import "fmt"

func main() {
	var x1, y1, x2, y2 int
	fmt.Scan(&x1, &y1, &x2, &y2)

	dx, dy := x2-x1, y2-y1
	fmt.Println(x2-dy, y2+dx, x1-dy, y1+dx)
}


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

#define FOR(s, i, n) for(int i = s; i n; i++)
typedef long long ll;
const int INF = 1e9;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, k;
	cin>>n>>k;
	vector<int> nums(n);
	for (int i = 0; i < n; i++){
		cin>>nums[i];
	}
	sort(nums.begin(), nums.end());
	int ans = 0;
	for (int i = 0; i < k; i++){
		ans+=nums[i];
	}
	cout<<ans<<'\n';
	return 0;
}

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

int main(){
   string str;
   string ans;
   getline(cin, str);
   for(int i=0; i<str.size(); i++){
      if(str[i]>'C')
         ans+=str[i]-3;
      else if(str[i]=='C')
         ans+='Z';
      else if(str[i]=='B')
         ans+='Y';
      else if(str[i]=='A')
         ans+='X';
   }
   cout << ans << endl;
}


Measured memory_bytes: 3192
import java.util.*;
public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int H = sc.nextInt();
    int W = sc.nextInt();
    char[][] m = new char[H][W];
    for (int i = 0; i < H; i++) {
      String string = sc.next();
      for (int j = 0; j < W; j++) {
        m[i][j] = string.charAt(j);
      }
    }
    
    int[][] above = new int[H][W];
    int[][] below = new int[H][W];
    int[][] left = new int[H][W];
    int[][] right = new int[H][W];
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (m[i][j] == '#') {
          above[i][j] = 0;
          left[i][j] = 0;
        } else {
          above[i][j] = (i == 0 ? 0 : above[i-1][j])+1;
          left[i][j] = (j == 0 ? 0 : left[i][j-1])+1;
        }
        if (m[H-1-i][j] == '#') {
          below[H-1-i][j] = 0;
        } else {
          below[H-1-i][j] = (i == 0 ? 0 : below[H-i][j])+1;
        }
        if (m[i][W-1-j] == '#') {
          right[i][W-1-j] = 0;
        } else {
          right[i][W-1-j] = (j == 0 ? 0 : right[i][W-j])+1;
        }
      }
    }
    
    int max = 0;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        if (m[i][j] != '#') {
          int v = above[i][j]+below[i][j]+left[i][j]+right[i][j]-3;
          max = Math.max(max, v);
        }
      }
    }
    
    System.out.println(max);
  }
}

Measured memory_bytes: 113224
#include<bits/stdc++.h>
#include <math.h>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    string x;
	cin >> x;
    int ans=0;
    fr(i,4){
     if(x[i]=='+')ans+=1;
     else ans-=1;
    }
      cout << ans << endl;
}

Measured memory_bytes: 256
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll count = 1;
    for (ll i = 0; i < N - 1; i++)
    {
        if (S[i] != S[i + 1])
        {
            count++;
        }
    }

    cout << count << endl;

    return;
}

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <queue>
#include <string>
#include <algorithm>

using namespace std;
using Graph = vector<vector<int>>;

int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0;

        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        res.push_back({a, ex});
    }

    if (N != 1) res.push_back({N, 1});
    return res;
}

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n + 1; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define repr1(i, n) for (int i = n; i > 0; i--)
#define FOR(i, j, n) for (int i = j; i < n; i++)

typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 100000000;

int main() {
    int64_t n;
    cin >> n;
    const auto &res = prime_factorize(n);

    int64_t cnt = 0,z=1;

    for (auto p : res) {
        rep1(i,p.second){
            if(n==1){
                cout << cnt << endl;
                return 0;
            }

            if(n%(z*p.first) == 0){
                z *= p.first;
                n /= z;
                cnt++;
            }
        }
        z=1;
    }
    cout << cnt << endl;
    return 0;

}

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



int main(){
    int N;
    cin >> N;
    int amari = 0;
    int K = N;
    for(int i = 0;i<10;i++){
        amari = amari + K%10;
        //cout << amari << endl;
        K = K/10;
        if(K == 0){
            break;
        }
        
        
    }

    if(N%amari == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

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

int main() {
    string s;
    int i;
    cin >> s;
    for(i = 0; i < s.length(); i++){
        if(s.length()%2==1) {
            cout << "No" << endl;
            return 0;
        }
        else if(i % 2 == 0){
            if(s.at(i) != 'h' ) {
                cout << "No" << endl;
                return 0;
            }
        }else{
            if(s.at(i) != 'i' ){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
const int dm = 1 << 17;
char *dn = cn, * di = dn, * owad = dn + dm - 20;
inline void putint(int X) {
	if (owad < di) {
		fwrite(dn, 1, di - dn, stdout);
		di = dn;
	}
	int dig = 1;
	if (X >= 10000) {
		if (X >= 100000) dig = 6;
		else dig = 5;
	}
	else {
		if (X >= 1000) dig = 4;
		else if (X >= 100) dig = 3;
		else if (X >= 10) dig = 2;
	}
	rep1(i, dig) {
		di[dig - i] = '0' + X % 10;
		X /= 10;
	}
	di[dig] = '\n';
	di += dig + 1;
}
const int bm = 500001;
int BIT[bm];
void add(int A) {
	while (A > 0) {
		BIT[A]++;
		A -= A & -A;
	}
}
int query(int A) {
	int ret = 0;
	while (A < bm) {
		ret += BIT[A];
		A += A & -A;
	}
	return ret;
}
int L[500001], R[500001], C[500001], ne[500001];
int are[500001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint(), Q = getint();
	rep1(i, N) C[i] = getint();
	rep1(i, Q) {
		L[i] = getint();
		int r = getint();
		ne[i] = R[r];
		R[r] = i;
	}
	rep1(i, N) {
		if (are[C[i]]) add(are[C[i]]);
		are[C[i]] = i;
		
		for (int r = R[i]; r; r = ne[r]) {
			L[r] = i - L[r] - query(L[r]) + 1;
		}
	}

	rep1(i, Q) putint(L[i]);
	fwrite(dn, 1, di - dn, stdout);


	Would you please return 0;
}

Measured memory_bytes: 14904
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

#define over return puts("No"), 0
const int MAXN = 100005;
int num[MAXN][3], bit[MAXN], n;
void add(int x, int y) {
	for (; x <= n; x += x & -x) bit[x] ^= y;
}
int sum(int x) {
	int res = 0;
	for (; x; x -= x & -x) res ^= bit[x];
	return res;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < 3; i++)
	for (int j = 0; j < n; j++)
		scanf("%d", &num[j][i]);
	int f0 = 0, f1 = 0, g0 = 0, g1 = 0;
	for (int i = 0; i < n; i++) {
		int c = num[i][1];
		if (c % 6 != 2 + 3 * (i & 1)) over;
		if (abs(c - num[i][0]) != 1 || abs(c - num[i][2]) != 1) over;
	}
	for (int i = n - 1; i >= 0; i--) if (i & 1) {
		f1 ^= num[i][0] > num[i][2];
		int c = num[i][1] / 6 + 1;
		g1 ^= sum(c);
		add(c, 1);
	}
	memset(bit, 0, sizeof(bit));
	for (int i = n - 1; i >= 0; i--) if (~i & 1) {
		f0 ^= num[i][0] > num[i][2];
		int c = num[i][1] / 6 + 1;
		g0 ^= sum(c);
		add(c, 1);
	}
	puts(f0 == g1 && f1 == g0 ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 1792
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
import Data.List

readIntsLine :: IO [Int]
readIntsLine = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

solve :: Int -> [Int] -> Int
solve _ [] = 0
solve k (h:hs) = result + solve k hs
  where result = if h >= k then 1 else 0

main :: IO ()
main = do
  [n, k] <- map read . words <$> getLine
  hs <- readIntsLine
  print $ solve k hs

Measured memory_bytes: 1916
#include<iostream>
#include<string>
using namespace std;
int main()
{
   string s,t;
   int i,x=0;
   cin>>s>>t;
   int l=s.size();
   for(i=0;i<l;i++)
   {
       if(s[i]!=t[i])
       {
           x++;
       }
   }
   cout<<x<<endl;

    return 0;
}


Measured memory_bytes: 3860
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        if (n == m) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}


Measured memory_bytes: 35488
#include <stdio.h>

int main(){
	int a,b,c,d,e,f,tmp;

	//printf("2つのベルを買うときの最安値を出力せよ。\n");
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);

	if(a >= 0 && a <= 10000 && b >= 0 && b <= 10000 && c >= 0 && c <= 10000){
	
		d = a + b;
		e = a + c;
		f = b + c;

		//printf("%d円のベルと%d円のベルを買うと、%d円かかります。\n",a,b,d);
		//printf("%d円のベルと%d円のベルを買うと、%d円かかります。\n",a,c,e);
		//printf("%d円のベルと%d円のベルを買うと、%d円かかります。\n",b,c,f);

		if(d > e){
			tmp = d;
			d = e;
			e = tmp;
		}
		if(e > f){
			tmp = e;
			e = f;
			f = tmp;
		}
		if(d > e){
			tmp = d;
			d = e;
			e = tmp;
		}

		//printf("よって、一番安いのは%d円です。\n",d);
		printf("%d\n",d);

		return 0;
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    int n;
    cin >> n;
    
    int a[100];
    int b[100];
    

    b[0] = 100001;
    b[n] = 100001;
    
    for(int i=1; i<n; i++) cin >> b[i];
    //for(int i=0; i<=n; i++) cout << b[i] << " ";
    //cout << endl;
    int sum = 0;
    for(int i=1; i<=n; i++) {
        a[i] = min(b[i-1], b[i]);
        //cout << a[i] << " ";
        sum += a[i];
    }
    //cout << endl;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
def comp(gen1,gen2,i,j)
    p1=Array.new
    p2=Array.new
    for x in 1..6 do
       p1.push(gen2[i][x])
       p2.push(gen2[j][x])
    end
    if p1.sort != p2.sort then
       return false
    end

    ht0=Hash.new
    gen1[i].each{|key,value|
       str=""
       value.each{|v|
         str+=v.to_s
       }
       ht0.store(key,str+str)
    }

    ht1=Hash.new
    gen1[j].each{|key,value|
       str=""
       value.each{|v|
         str+=v.to_s
       }
       ht1.store(key,str)
    }

    ht0.each{|key0,value0|
    ht1.each{|key1,value1|
       if value0.include?(value1)==true then
          if ht0[7-key0].include?(ht1[7-key1])
             if gen2[i][key0]==gen2[j][key1] && gen2[i][7-key0]==gen2[j][7-key1] then
                return true
             end
          end
       end
    }
    }
    return false
end

def generate(src,lbl)

     gen=Hash.new
     src.each{|key,arr|
       r=Array.new
       arr.each{|v|
         r.push(lbl[v])
       }
       gen.store(key,r)
     }
     return gen
end

src={1=>[2,3,5,4],
     2=>[1,4,6,3],
     3=>[1,2,6,5],
     4=>[2,1,5,6],
     5=>[3,6,4,1],
     6=>[2,4,5,3]}

gen1=Hash.new
gen2=Hash.new
n=gets.to_i
n.times do |p|
    lbl=Hash.new
    mp=gets.split(' ').map(&:to_i)
    mp.each_with_index {|x,i|
       lbl.store(i+1,x)
    }
    gen1.store(p,generate(src,lbl))
    gen2.store(p,lbl)
end
res="Yes"
for i in 0..n-1 do
for j in i+1..n-1 do
if comp(gen1,gen2,i,j) == true then
    res="No"
    break
end
end
end
puts res

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

using namespace std;

int d, l, r, ans;

int main() {
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	cin >> l >> r >> d;

	for (int i = l; i <= r; ++i)
		if (i % d == 0)
			++ans;

	cout << ans << endl;
}


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

using namespace std;

const int INF = 1e9 + 5;
const int MAX_N = 3e3 + 5;

int lm [MAX_N];
int wins [MAX_N];
int del [MAX_N];
int arr [MAX_N];
vector<int> adj [MAX_N];

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

  int n;
  cin >> n;

  for (int i = 1; i <= n; i++) {
    cin >> arr[i];
  }

  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;

    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  int ac = n;
  while (ac > 0) {
    int mn = INF;
    for (int i = 1; i <= n; i++) {
      if (!del[i]) {
        mn = min(mn, arr[i]);
      }
    }

    for (int i = 1; i <= n; i++) {
      if (!del[i]) {
        if (arr[i] == mn) {
          lm[i] = 1;
        }
      }
    }
    
    for (int i = 1; i <= n; i++) {
      if (!del[i] && lm[i]) {
        for (int nxt : adj[i]) {
          if (!del[nxt] && !lm[nxt]) {
            wins[nxt] = 1;
          }
        }
      }
    }

    for (int i = 1; i <= n; i++) {
      if (!del[i] && (lm[i] || wins[i])) {
        del[i] = 1;
        ac--;
      }
    }
  }

  for (int i = 1; i <= n; i++) {
    if (wins[i]) {
      cout << i << " ";
    }
  }
  cout << endl;
}


Measured memory_bytes: 3872
#include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ? -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 100000 + 5;

int n;
LL ans[N];

struct node {
	LL x, p;
} a[N];

int cmp(const node &a, const node &b) {
	if (a.x == b.x) return a.p < b.p;
	return a.x > b.x;
}

int main() {
	read(n);
	for (int i = 1; i <= n; i++) read(a[i].x), a[i].p = i;
	sort(a + 1, a + n + 1, cmp);
	LL mn = n + 1; a[n + 1].x = 0, a[n + 1].p = n + 1;
	for (int i = 1, j; i <= n; i = j + 1) {
		j = i;
		mn = min(mn, a[i].p);
		while (j + 1 <= n && a[j + 1].x == a[i].x) j++;
		LL tmp = a[i].x - a[j + 1].x;
		ans[mn] += tmp * j;
	}
	for (int i = 1; i <= n; i++) printf("%lld\n", ans[i]);
	return 0;
}

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


int main() { 
string  S;
cin>>S;
if (S[0]=='C') {
cout<<"Rainy" ;
} 
else  if (S[0]=='R'){ 
cout<<"Sunny"; 
} 
else{

cout << "Cloudy" << endl; 
} 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353 
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
ll F[1000005],R[1000005];
void make(){
	F[0] = 1;
	for(int i=1;i<1000005;i++) F[i] = F[i-1]*i%mod;
	for(int i=0;i<1000005;i++) R[i] = modpow(F[i],mod-2);
}
ll C(int a,int b){
	return F[a]*R[b]%mod*R[a-b]%mod;
}
int n,k;
ll ans;
int main(){
	cin>>n>>k;
	if(n > k){
		puts("0");
		return 0;
	}
	make();
	for(int s=0;s<=k;s++){
		if(s%2 != k%2) continue;
		if(s >= n){
			ans += C(k,(k+s)/2);
		}
		else if(s >= 1){
			if((k-s)/2<n-s) continue;
			ans += C(k,(k+s)/2)-C(k,n-s-1);
		}
		else{
			if((k-s)/2<n-s) continue;
			ans += C(k-1,(k+s)/2)-C(k-1,n-s-2);
		}
	}
	cout<<(ans%mod+mod)%mod<<endl;
}

Measured memory_bytes: 15872
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> v(m);
    for(int i=0; i<m; i++){
        cin >> v[i];
    }

    for(int i=0; i<m; i++){
        n -= v[i];
    }

    if(n < 0){
        cout << -1 << endl;
        return 0;
    }

    cout << n << endl;
    return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<P,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
ll C[100005]={};

vector<int> v[100005];

bool ca[1004],cb[1005];
bool a[1000005]={};
int n;
int main() {
	cin>>n;
	int h[101];
	rep(i,0,n)cin>>h[i];
	int ans=0;
	rep(i,1,101){
		bool b=0;
		rep(j,0,n){
			if(!b&&h[j]>=i){
				++ans;
				b=!b;
			}
			if(b&&h[j]<i)b=!b;
		}
//		cout<<ans<<endl;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int main(){
  int D;
  cin>>D;
  if(D==25){
  cout<<"Christmas"<<endl;
  }
  if(D==24){
  cout<<"Christmas Eve"<<endl;
  }
  if(D==23){
  cout<<"Christmas Eve Eve"<<endl;
  }
  if(D==22){
  cout<<"Christmas Eve Eve Eve"<<endl;
  }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 7)


class Tree:
    WHITE = -2
    GRAY = -1
    BLACK = 1

    def __init__(self, adj):
        n = len(adj)
        self.adj = adj
        self.colors = [self.WHITE] * n
        self.depths = [-1] * n
        self.depth = 0

    def init(self):
        self.__init__(self.adj)

    def dfs(self, u, c):
        if self.colors[u] >= 0:
            return

        self.colors[u] = self.GRAY
        self.depths[u] = self.depth

        for v in self.adj[u]:
            if self.colors[v] == self.WHITE:
                self.dfs(v, c)

        self.colors[u] = c

from collections import Counter

n, m, k = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
cd = [list(map(int, input().split())) for _ in range(k)]

adj = [[] for _ in range(n)]
for a, b in ab:
    a -= 1
    b -= 1
    adj[a].append(b)
    adj[b].append(a)

tree = Tree(adj)
for i in range(n):
    tree.dfs(i, i)

labels = tree.colors

counter = Counter(labels)

ans = [counter[labels[i]] - 1 for i in range(n)]

for a, b in ab:
    a -= 1
    b -= 1
    if labels[a] == labels[b]:
        ans[a] -= 1
        ans[b] -= 1

for c, d in cd:
    c -= 1
    d -= 1
    if labels[c] == labels[d]:
        ans[c] -= 1
        ans[d] -= 1

print(*ans)


Measured memory_bytes: 91000
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
    int n,m;
    int i;
    int ans = 1;
    scanf("%d%d",&n,&m);
    for(i = 1;i*i <= m;i++)
    {
        if(m%i == 0)
        {
            if(m/i >= n) ans = max(ans,i);
            if(i >= n) ans = max(ans,m/i);
        }
    }
    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 256
def powmod(x, n,mod):
  if n == 0:
   return 1
  K = 1
  while n > 1:
   if n % 2 != 0:
    K = K * x%mod
    x = x ** 2%mod
    n = (n - 1) // 2
   else:
    x = x ** 2%mod
    n = n // 2%mod
  return K * x # 指数を割り続け n が 1 に至ったら終了
N,K = map(int,input().split())
mod=10**9+7
ans=[0]*(K+1)
for i in range(K):
 b=int(K/(K-i))
 if b==1:
  ans[K-i]+=1
 else:
  ans[K-i]+=powmod(b, N,mod)
  ans[K-i]%=mod
  for j in range(b-1):
   ans[K-i]-= ans[(K-i)*(j+2)]
   ans[K-i]%=mod
c=0
for i in range(K+1):
 c+=ans[i]*i
 c%=mod
print(c)


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int A, B;
    cin >> A >> B;
    cout << max(0, A - 2 * B) << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	int a,b;
	cin>>a>>b;
	if(a==1) a=100;
	if(b==1) b=100;
	if(a>b) cout<<"Alice";
	else if(a<b) cout<<"Bob";
	else cout<<"Draw";
	re 0;
}

Measured memory_bytes: 3648
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    A, B, C, D = map(int, input().split())
    print(max(A * B, C * D))


if __name__ == '__main__':
    main()


Measured memory_bytes: 4204
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M; cin>>N>>M; if(N>=M){cout<<0<<endl; return 0;}
  vector<int>A(M);for(int i=0;i<M;i++)cin>>A[i];
  sort(A.begin(),A.end());
  vector<int>B(M-1);for(int i=0;i<M-1;i++)B[i]=A[i+1]-A[i];
  sort(B.begin(),B.end());
  int ans=0;
  for(int i=0;i<M-N;i++)ans+=B[i];
  cout<<ans<<endl;
}

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

using namespace std;

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define sz size()
#define mp make_pair
#define pii pair<int,int>

int n,m,d;

int main()
{
	while(scanf("%d %d %d",&n,&m,&d) != EOF){

		if(d >= n){
			printf("0\n");
			return 0;
		}
		if(m == 1){
			printf("0\n");
			return 0;
		}

		double st = 2.00*(double)(n-d);
		st /= (double)n;
		st *= (double)(m-1);
		st /= (double)n;
		if(d == 0)printf("%.9lf\n",st/2.00);
		else printf("%.9lf\n",st);
	}

	return 0;
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll h,n,sum=0;
  cin  >> h >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum += a[i];
  }
  if(sum>=h) cout << "Yes\n";
  else cout <<"No\n";
}


Measured memory_bytes: 1024
N = int(input())
H = list(map(int,input().split()))

for i in range(1, N):
    H[i] = H[i] - 1
    if H[i] < H[i-1]:
        H[i] = H[i] + 1
    else:
        pass


count = 0
for k in range(N-1):
    if H[k] <= H[k + 1]:
        count = count + 1
    else:
        count = -1
        break

if 0 <= count <= N:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 14704
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;
#define INF 1000000000000
#define NOD 1000000007
#define PI 3.141592653589793238462643

ll gcd(ll a, ll b) {
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

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

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
    cout << b - (a-1) - b/c + (a-1)/c - b/d + (a-1)/d + b/lcm(c, d) - (a-1)/lcm(c, d) <<endl;
}


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

int main()
{
  string A, B, C;

  cin >> A >> B >> C;

  if ( A.at(A.size() - 1) == B.at(0)
    && B.at(B.size() - 1) == C.at(0) )
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
vector<int>g[123456];
int dp[123456][11];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,q;
    cin >> n >> m;
    while(m--){
        int a,b;
        cin >> a >> b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    cin >> q;
    vector<int>c;
    memset(dp,-1,sizeof(dp));
    rep(i,q){
        int v,d,cc;
        cin >> v >> d >> cc;
        v--;
        dp[v][d] = i;
        c.push_back(cc);
    }
    for(int i = 10; i > 0; i--){
        rep(j,n){
            for(int x:g[j]){
                dp[x][i-1] = max(dp[x][i-1], dp[j][i]);
            }
        }
    }
    rep(i,n){
        int k = *max_element(dp[i],dp[i]+11);
        if(k==-1)cout << 0 << "\n";
        else cout << c[k] << "\n";
    }
}

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

#define int long long
#define ll long long
#define f1(i,a,b) for(i=a;i<b;i++)
#define f2(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
int i,j;
int temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a,b)<<gp;
    if((a+b)-n>0)
    {
        cout<<((a+b)-n);
    }
        else
        cout<<0;
    return 0;
}


Measured memory_bytes: 256