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

/*struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }*/

int main() {
    int a, b, m;
    cin >> a >> b >> m;
    vector<int> reizouko(a);
    vector<int> renzi(b);
    rep(i, a) cin >> reizouko[i];
    rep(i, b) cin >> renzi[i];
    vector<int> x(m);
    vector<int> y(m);
    vector<int> c(m);
    rep(i, m) cin >> x[i] >> y[i] >> c[i];

    int ans = 200001;
    rep(i, m) {
        int num = reizouko[x[i] - 1] + renzi[y[i] - 1] - c[i];
        ans = min(ans, num);
    }

    sort(reizouko.begin(), reizouko.end());
    sort(renzi.begin(), renzi.end());

    int num = reizouko[0] + renzi[0];
    ans = min(ans, num);

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


Measured memory_bytes: 2176
#include <stdio.h>

int main()
{
        double max,min;
        double n;

        scanf("%lf",&max);
        min=max;
        while(~scanf("%lf",&n)){
                if(min>n)min=n;
                else if(max<n)max=n;
        }
        printf("%lf\n",max-min);
        return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
int N;
ll a[200005];
int u[200005], v[200005];

ll dp[200005];
vector<int> G[200005];
bool used[200005];
int ans[200005];

const ll INF = 2e15;

void dfs(int v){
    used[v] = true;
    auto p = lower_bound(dp, dp+N+2, a[v]);
    int dif = p-dp;
    ll pre = dp[dif];
    dp[dif] = min(a[v], dp[dif]);
    ans[v] = lower_bound(dp, dp+N+2, INF)-dp;
    for(int to : G[v]){
        if(!used[to]){
            dfs(to);
        }
    }
    dp[dif] = pre;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N; i++) cin >> a[i];
    for(int i = 0; i < N-1; i++){
        cin >> u[i] >> v[i];
        u[i]--; v[i]--;
        G[u[i]].push_back(v[i]);
        G[v[i]].push_back(u[i]);
    }
    for(int i = 0; i <= N+2; i++) dp[i] = INF; 
    dfs(0);
    for(int i = 0; i < N; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 31568
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

template<class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int k;

int gcd(int i, int j, int k){
    return __gcd(i,__gcd(j,k));
}

#define K 205

int dp[K+1][K+1][K+1];

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    cin >> k;
    int ans = 0;
    
    rep(i,1,k+1){
        rep(j,1,k+1){
            rep(m,1,k+1) dp[i][j][m] = -1;
        }
    }
    
    rep(i,1,k+1){
        rep(j,1,k+1){
            rep(m,1,k+1){
                //find the number of permutations this can take??
                if(dp[i][j][m]!=-1) ans += dp[i][j][m];
                else {
                    int cur = gcd(i,j,m);
                    dp[i][j][m] = cur; dp[m][j][i] = cur;
                    dp[i][m][j] = cur; dp[m][i][j] = cur;
                    dp[j][i][m] = cur; dp[j][m][i] = cur;
                    ans += dp[i][j][m];
                }
            }
        }
    }

    cout << ans << "\n";

    return 0;
}

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

using namespace std;

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

    int n, x, answer = 0;
    cin >> n >> x;

    vector<int> arr(n);

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

        x -= arr[i];
    }

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

    answer = n;
    answer += x / arr[0];

    cout << answer << '\n';


}


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

int b[200010], w[200010];

int main()
{
    int n; cin>>n;
    string s; cin>>s;
    for(int i=0; i<n; ++i) {
        b[i+1]=b[i]+(s[i]=='#');
        w[i+1]=w[i]+(s[i]!='#');
    }

    int res=1<<30;
    for(int i=0; i<=n; ++i)
        res=min(res, b[i]+(w[n]-w[i]));
    cout<<res<<endl;
}


Measured memory_bytes: 2180
package main

import(
    "fmt"
)



func main() {
    var a,b int
    fmt.Scan(&a,&b)
    ans := "Odd"
    if a*b%2==0{
        ans = "Even"
    }
    fmt.Println(ans)
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <unordered_set>
#include <algorithm>

using namespace std;

template <int base>
int digit_sum(int n)
{
	int sum = 0;
	while (n > 0) {
		sum += n % base;
		n /= base;
	}
	return sum;
}

using ivec = vector<int>;

ivec read_int_args()
{
	int N;
	cin >> N;
	ivec v(N);
	for (auto& e : v) {
		cin >> e;
	}
	return v;
}

int main()
{
	int N;
	cin >> N;
	int a = N * N * N;
	cout << a << endl;
	return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int n,l,t;
int tot;
vector<int>res;
int main()
{
	scanf("%d%d%d",&n,&l,&t);
	for(int i=1;i<=n;i++)
	{
		int x,w;
		scanf("%d%d",&x,&w);
		x+=(3-w*2)*t;
		tot+=x/l;
		tot%=n;
		if(tot<0)tot+=n;
		x%=l;
		if(x<0)x+=l,tot--;
		res.push_back(x);
	}
	sort(res.begin(),res.end());
	for(int i=0;i<n;i++)printf("%d\n",res[(i+tot)%n]);
	return 0;
} 

Measured memory_bytes: 1656
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

N=int(input())
P=nl()
c=0
for i in range(1,N+1):
    if(P[i-1]!=i):
            c+=1

print('YES' if c<=2 else 'NO')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<n; i++)
#define SORT(x) sort(x.begin(), x.end())
using namespace std;
typedef long long ll;


ll minl(ll a, ll b) {
    if(a < b) return a;
    else return b;
}

int main() {
    ll A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> s(A), t(B), x(Q);
    rep(i, A) cin >> s[i];
    rep(i, B) cin >> t[i];
    rep(i, Q) cin >> x[i];
    SORT(t); SORT(s);
    map<ll, ll> stot;
    map<ll, ll> ttos;

    rep(i, A) {
        auto pos = lower_bound(t.begin(), t.end(), s[i]);
        int a, b;
        a = distance(t.begin(), pos);
        if(a) b = a-1; else b = a;
        stot[s[i]] = minl(abs(s[i]-t[a]), abs(s[i]-t[b]));
    }
    rep(i, B) {
        auto pos = lower_bound(s.begin(), s.end(), t[i]);
        int a, b;
        a = distance(s.begin(), pos);
        if(a) b=a-1; else b=a;
        ttos[t[i]] = minl(abs(t[i]-s[a]), abs(t[i]-s[b]));
    }

    
    ll ans, sans, tans;
    rep(i, Q) {
        vector<ll>::iterator spos = lower_bound(s.begin(), s.end(), x[i]);
        vector<ll>::iterator tpos = lower_bound(t.begin(), t.end(), x[i]);
        ll a, b, c, d;
        a = distance(s.begin(), spos);
        if(a > A-1) a = a-1;
        if(a) b = a-1; else b = a;
        sans = minl(ll(abs(x[i]-s[a])+stot[s[a]]), ll(abs(x[i]-s[b])+stot[s[b]]));

        c = distance(t.begin(), tpos);
        if(c) d=c-1; else d=c;
        tans = minl(ll(abs(x[i]-t[c])+ttos[t[c]]), ll(abs(x[i]-t[d])+ttos[t[d]]));

        ans = minl(sans, tans);
        cout << ans << endl;
    }

    return 0;

}

Measured memory_bytes: 16128
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;
 
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
 
typedef long long ll;
typedef pair<ll, ll> P;
 
bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}

int main() {
    ll N, M;
    cin >> N >> M;
    vector<P> v(M);
    for (int i = 0; i < M; ++i){
        ll a,b;
        cin >> a >> b;
        v[i] = P(a,b);
    }
    sort(v.begin(), v.end(), pairCompare);
    ll cut = -1;
    ll ans=0;
    for (int i = 0; i < M; ++i){
        if(v[i].first < cut){
            continue;
        }
        cut = v[i].second;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){

    int N;
    cin >> N;

    vector<int> A(N+1);
    for(int i=1; i<=N; i++) cin >> A.at(i);

    vector<int> ans(N+1);
    for(int i=1; i<=N; i++){

        ans.at(A.at(i)) = i;
    }

    for(int i=1; i<=N; i++) cout << ans.at(i) << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 1664
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>

using namespace std;

int main(void){

    int n, m;
    cin>>n>>m;

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

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

    vector<pair<int, int>> p(m);

    for(int i=0;i<m;i++){
        int b,c;
        cin>>b>>c;

        p[i] = make_pair(c, b);
    }

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

    // for(int i=0;i<n;i++){
    //     cout<<a[i]<<" ";
    // }
    // cout<<endl;



    int begin = 0;
    int start = 0;

    for(int i=m-1;i>=0;i--){

        //cout<<p[i].first<<" "<<p[i].second<<endl;
        start = begin;
        for(int j=begin;j<start+p[i].second;j++){
            //cout<<j<<endl;
            if(a[j] < p[i].first){
                //cout<<"in"<<endl;
                a[j] = p[i].first;
                begin++;
            }else{
                break;
            }
        }

        //cout<<start<<endl;

        // for(int j=0;j<n;j++){
        //     cout<<a[j]<<" ";
        // }
        // cout<<endl;
    }

    long long int sum = 0;
    for(int i=0;i<n;i++){
        sum += a[i];
    }

    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

const int dy[] = {0, -1, 0, 1};
const int dx[] = {1, 0, -1, 0};
int W, H;
string L[50], R[50];
int dis[50][50][50][50];
const int INF = 1 << 30;

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

    while (cin >> W >> H, W) {
        int lsy, lsx, rsy, rsx;
        int lgy, lgx, rgy, rgx;
        REP (i, H) {
            cin >> L[i] >> R[i];
            REP (j, W) {
                if (L[i][j] == 'L') lsy = i, lsx = j;
                if (R[i][j] == 'R') rsy = i, rsx = j;
                if (L[i][j] == '%') lgy = i, lgx = j;
                if (R[i][j] == '%') rgy = i, rgx = j;
            }
        }
        fill_n((int*)dis, 50 * 50 * 50 * 50, INF);
        using P = tuple<int, int, int, int>;
        dis[lsy][lsx][rsy][rsx] = 0;
        queue<P> que;
        que.emplace(lsy, lsx, rsy, rsx);
        int ans = INF;
        while (!que.empty()) {
            int ly, lx, ry, rx;
            tie(ly, lx, ry, rx) = que.front(); que.pop();
            // cout << ly << " " << lx << " " << ry << " " << rx << endl;
            REP (i, 4) {
                int nly = ly + dy[i], nlx = lx + dx[i];
                int nry = ry + dy[i], nrx = rx - dx[i];
                if (!(nly >= 0 && nly < H && nlx >= 0 && nlx < W) || L[nly][nlx] == '#') nly = ly, nlx = lx;
                if (!(nry >= 0 && nry < H && nrx >= 0 && nrx < W) || R[nry][nrx] == '#') nry = ry, nrx = rx;
                if ((L[nly][nlx] == '%') ^ (R[nry][nrx] == '%')) continue;
                if (dis[nly][nlx][nry][nrx] > dis[ly][lx][ry][rx] + 1) {
                    dis[nly][nlx][nry][nrx] = dis[ly][lx][ry][rx] + 1;
                    que.emplace(nly, nlx, nry, nrx);
                }
            }
            if (ans != INF) break;
        }
        cout << (dis[lgy][lgx][rgy][rgx] == INF ? "No" : "Yes") << endl;
    }
}


Measured memory_bytes: 53768
A = []
for _ in range(3):
    a = list(map(int, input().split()))
    A.append(a)

N = int(input())
Bn = set([int(input()) for _ in range(N)])

for b in Bn:
    for i in range(3):
        for j in range(3):
            if A[i][j] == b:
                A[i][j] = 0

ans = False
if A[0][0] == A[1][1] == A[2][2] == 0:
    ans = True

if A[0][2] == A[1][1] == A[2][0] == 0:
    ans = True

# col
for i in range(3):
    cnt = 0
    for j in range(3):
        if A[j][i] == 0:
            cnt += 1
    if cnt == 3:
        ans = True

# row
for i in range(3):
    cnt = 0
    for j in range(3):
        if A[i][j] == 0:
            cnt += 1
    if cnt == 3:
        ans = True

print("Yes" if ans else "No")

Measured memory_bytes: 3064
#include <iostream>

using namespace std;
int main()
{
  int N, Q;
  char s[100000];
  int  l[100000];
  int  r[100000];
  int  a[100000];

  cin >> N >> Q;
  cin >> s;
  for(int i=0; i<Q; ++i)
    cin >> l[i] >> r[i];

  int count = 0;
  for(int i=0; i<N; ++i)
  {
    a[i] = count;
    if(s[i] == 'A' && s[i+1] == 'C')
    {
      ++count;
    }
  }

  for(int i=0; i<Q; ++i)
    cout << a[r[i]-1]-a[l[i]-1] << endl;


  return 0;
}

Measured memory_bytes: 2048
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int q = Integer.parseInt(sc.next());
        Tree tree[] = new Tree[n+1];
        for(int i=0; i<n+1; i++) {
            tree[i] = new Tree();
            tree[i].value = 0;
            tree[i].tree = new Tree();
        }

        for(int i=0; i<n-1; i++) {
            int a = Integer.parseInt(sc.next());
            int b = Integer.parseInt(sc.next());
            tree[b].tree = tree[a];
        }

        for(int i=0; i<q; i++) {
            int p = Integer.parseInt(sc.next());
            int x = Integer.parseInt(sc.next());
            tree[p].value += x;
        }

        for(int i=0; i<n; i++) {
            if (tree[i+1].tree != null)
                tree[i+1].value += tree[i+1].tree.value;
            System.out.print(tree[i+1].value);
            if(i+1 < n)
                System.out.print(" ");
            else
                System.out.println();
        }
    }
}

class Tree {
    int value = 0;
    Tree tree;

    public Tree(){}
}


Measured memory_bytes: 106452
# 2020/04/19
# AtCoder Beginner Contest 163 - B

# Input
n, m = map(int,input().split())
a = list(map(int,input().split()))

# Calc
sum = 0
for i in range(m):
    sum = sum + a[i]

ans = max(n - sum, -1)

# Output
print(ans)


Measured memory_bytes: 10192
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
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; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main(){
  ll a,b,c,d,e,f;
  cin>>a>>b>>c>>d>>e>>f;

  ld ans=-1;
  ll sw,s;
  for(ll i=0;i*100*a<=f;i++){
    for(ll j=0;j*100*b<=f;j++){
      ll wat=i*100*a+j*100*b;
      if(wat>f) continue;
      if(wat==0) continue;
      for(ll k=0;k*c*100<=wat*e;k++) {
        if(wat+k*c>f) continue;
        ll x=min((f-wat-k*c)/d,(wat*e-k*c*100)/(100*d));
        ld koho=(ld)(k*c+x*d)/wat;
        if(ans<koho) {
          sw=wat+k*c+x*d;
          s=k*c+x*d;
        }
        chmax(ans,koho);
      }
    }
  }

  cout << sw << " " << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(i,0,n)cout<<v[i]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define tihs if(fopen("inp.txt","r"))freopen("inp.txt", "r", stdin),freopen("out.txt", "w", stdout);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 

#define M 200010
ll n,m,k;
vll f[M];
vll b[M];

ll p[M],p1[M];
void done(){
	rep(i,0,M)p[i]=i,p1[i]=i;
}
ll find(ll v){
	if(v==p[v]) return v;
	return p[v]=find(p[v]);
}
void join(ll a,ll b){
	a=find(a),b=find(b);
	if(rand()%2)swap(a,b);
	p[b]=a;
}
int main(){
	IOS;
	tihs;
	done();
	cin>>n>>m>>k;
	rep(i,0,m){
		ll u,v;cin>>u>>v;
		f[u].pb(v);f[v].pb(u);
		join(u,v);
	}
	rep(i,0,k){
		ll u,v;cin>>u>>v;
		b[u].pb(v);b[v].pb(u);
	}
	ll ans[n+1];
	rep(i,1,n+1)ans[i]=0;
	rep(i,1,n+1){
		ans[find(i)]++;
	}
	rep(i,1,n+1){
		ans[i]=ans[p[i]];
	}
	rep(i,1,n+1){
		ans[i]--;
		ans[i]-=sz(f[i]);
		for(auto v:b[i]){
			if(find(v)==find(i))ans[i]--;
		}
	}
	rep(i,1,n+1)cout<<ans[i]<< " ";

	
	return 0;
}

Measured memory_bytes: 21492
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e10+100;

ll v;
ll d[105][105];
void floyd(){
    rep(k,v){
        rep(i,v){
            if(d[i][k]==INF) continue;
            rep(j,v){
                if(d[k][j]==INF) continue;
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
}

int main()
{
    ll e;
    cin >> v >> e;
    rep(i,v){
        rep(j,v){
            d[i][j]=((i==j)?0:INF);
        }
    }
    rep(i,e){
         ll s,t,c;
        cin >> s >> t >> c;
        d[s][t]=c;
    }
    floyd();
    bool negative=false;
    rep(i,v){
        if(d[i][i]<0){
            negative=true;
        }
    }
    if(negative){
        cout << "NEGATIVE CYCLE" << endl;
    }
    else{
        rep(i,v){
            rep(j,v){
                if(j) cout << " ";
                if(d[i][j]==INF) cout << "INF";
                else cout << d[i][j];
            }
            cout << endl;
        }
    }
} 


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef priority_queue<int> pq;
typedef priority_queue<int, vi, greater<int>> mpq;

const ll INF = 1e18;
const int mod = 1e9+7;
const int dX[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

#define whatis(x) cerr << #x << " is " << x << endl;
#define endl "\n"
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ft front()
#define bk back()
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define FOR(i, a) for(int i = 0; i < a; i++)
#define FoR(i, a) for(int i = 1; i <= a; i++)
#define ROF(i, a) for (int i = (a)-1; i >= 0; i--)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
//-----------------------| Template By: DakDak |----------------------------
int n;
int main(){
    cin >> n; 
    vector<int> dp(3);
    for(int days = 0; days < n; days++){
        vector<int> dp2(3, 0);
        vector<int> costs(3);
        for(auto &x : costs){
            cin >> x;
        }
        // dp[j] = max cost we can get if i signifies the last choice we took
        // yesterday, so we compare the other 2 costs from yesterday, to maximize
        // our cost today, since we want to brute force, we need to consider all
        // possibilities except the ones that can't happen ex. (i == j)
        FOR(i, 3){
            FOR(j, 3){
                if(i != j){
                    dp2[j] = max(dp2[j], dp[i] + costs[j]);
                }
            }
        }
        dp = dp2;
    }
    cout << max({dp[0], dp[1], dp[2]}) << endl;
    return 0;
    // Read notes to self
}

/* NOTES TO SELF:
 * Check for int vs ll, worst case just switch everything to ll
 * Check for array bounds if you SEGFAULT, especially in range based loops
 * Always initialize everything in global 
 * Edge cases such as n = 1 or 0
 * Make sure to calculate big O complexity
 * You are geniosity you got this
 */





Measured memory_bytes: 256
from itertools import combinations
N,M,X = map(int,input().split())
C = []
for _ in range(N):
  C.append([int(v) for v in input().split()])
Ca,Aa = [],[]
for k in range(1,N+1):
  for v in combinations(C,k):
    tmp = [0]*(M+1)
    for v2 in v:
      for i,v3 in enumerate(v2):
        tmp[i]+=v3
    isOK = True
    for v2 in tmp[1:]:
      if v2 < X:
        isOK = False
        break
    if isOK:
      #print(tmp)
      Ca.append(tmp[0])
if len(Ca) == 0:
  print(-1)
else:
  print(min(Ca))

Measured memory_bytes: 9216
void main() {
	auto ip = readAs!(int[]), N = ip[0], M = ip[1];
	auto arr = new bool[](N);
	auto arr2 = new bool[](N);
	foreach(i; 0..M) {
		auto ip2 = readAs!(int[]), a = ip2[0], b = ip2[1];
		if(a == 1) arr[b-1] = true;
		else if(b == N) arr2[a-1] = true;
	}
	foreach(i, v; arr) {
		if(v && arr2[i]) {
			writeln("POSSIBLE");
			return;
		}
	}
	writeln("IMPOSSIBLE");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 1660
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

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

    vector<int> h;

    for (int i = 0; i < n; ++i) {
        int temp;
        cin >> temp;
        h.push_back(temp);
    }

    int ans = 0;
    int count = 0;

    for (int i = 0; i < n - 1; ++i) {
        if (h[i] >= h[i + 1]) {
            ++count;
        }
        else {
            count = 0;
        }
        
        if (ans < count) ans = count;
    }

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


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    /**
     * 偶数の時は何もしない、奇数の時は一つとなりに1個渡す。
     * ->これを全ての行について行って、最後に右端の列を下に向かって同様に操作する
     */

    i32 h, w; cin >> h >> w;
    vii grid(h, vi(w));
    rep(i,h)rep(j,w) cin >> grid[i][j];

    i32 n = 0;
    using tup = tuple<i32, i32 , i32, i32>;
    vec<tup> vt;
    rep(i,h)rep(j,w-1) {
        if(grid[i][j] & 1) {
            ++n;
            vt.emplace_back(i+1, j+1, i+1, j+1+1);
            --grid[i][j];
            ++grid[i][j+1];
        }
    }
    rep(i,h-1) {
        if(grid[i][w-1] & 1) {
            ++n;
            vt.emplace_back(i+1, w, i+1+1, w);
            --grid[i][w-1];
            ++grid[i+1][w-1];
        }
    }

    //output
    cout << n << '\n';
    for(auto t : vt) {
        cout << get<0>(t) << ' ';
        cout << get<1>(t) << ' ';
        cout << get<2>(t) << ' ';
        cout << get<3>(t) << '\n';
    }

////    Debug
//    cout << '\n';
//    rep(i,h)rep(j,w) cout << grid[i][j] << (j==w-1 ? '\n' : ' ');

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 8304
#include<bits/stdc++.h>
#define M 10001
using namespace std;
int n,k,t,u,v,l,d,c,x,a,s[M];
  
int main(){
  cin>>n>>k>>t>>u>>v>>l;
  for(int i=0;i<n;i++)cin>>d,s[d]=1;
  for(int i=0;i<l;i++){
    if(s[i])
      if(!x||k==c)x=v*t;
      else c++;
    else if(!x&&c)c--,x=v*t;
    if(x)a++,x--;
  }
  printf("%.8f\n",a*1.0/v+(l-a)*1.0/u);
  return 0;
}

Measured memory_bytes: 1232
import math
N, H = list(map(int, input().split()))
maxA = 0
b = []
n = 0
for _ in range(N):
    ta, tb = list(map(int, input().split()))
    maxA = max(maxA, ta)
    b.append(tb)
 
b = list(filter(lambda x: x > maxA, b))
b.sort()

while H > 0 and b:
    H -= b.pop()
    n += 1
print(n + math.ceil(max(H,0)/maxA) )


Measured memory_bytes: 7868
from collections import deque

def bfs():
    memo = [[float("inf")] * w for _ in range(h)]
    memo[0][0] = 0

    que = deque([])
    que.append((0, 0))

    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]

    while que:
        p = que.popleft()

        if p == (h-1, w-1):
            break

        for i in range(4):
            nx = p[0] + dx[i]
            ny = p[1] + dy[i]

            if 0 <= nx <= h-1 and 0 <= ny <= w-1 and maze[nx][ny] == "." and memo[nx][ny] == float("inf"):
                que.append((nx, ny))
                memo[nx][ny] = memo[p[0]][p[1]] + 1
    return memo[h-1][w-1]

h, w = map(int, input().split())
maze = [list(input()) for _ in range(h)]

black = 0
for i in range(h):
    for j in range(w):
        if maze[i][j] == "#":
            black += 1

root = bfs()
if root == float("inf"):
    print(-1)
else:
    print(h * w - root - black - 1)

Measured memory_bytes: 3444
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		boolean[] primes = new boolean[50001];
		Arrays.fill(primes, true);

		for (int i = 2; i < 50001; i++) {
			if (primes[i]) {
				for (int j = 2;; j++) {
					if (i * j > 50000) {
						break;
					}
					primes[i * j] = false;
				}
			}
		}

		while (!(line = br.readLine()).equals("0")) {

			int n = Integer.parseInt(line);
			int c = 0;

			for (int i = 2; i <= n / 2; i++) {
				if (primes[i] && primes[n - i]) {
					c++;
				}
			}
			System.out.println(c);
		}

	}

}

Measured memory_bytes: 25972
#include <stdio.h>

int main(){
  int i, j, tmp, max, maxidx;
  int a[10];

  for(i=0; i<10; i++){
    scanf("%d", &tmp);
    a[i]=tmp;
  }

  for(i=0; i<3; i++){
    max=0;
    for(j=0; j<10; j++){
      if(max<a[j]){
        max=a[j];
        maxidx=j;
      }
    }
    printf("%d\n", max);
    a[maxidx]=0;
  }
  return 0;
}

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

int f(string s,string t){
  if(s.size()!=t.size())return 100000000;
  int res=0;
  for(int i=0;i<s.size();i++)res+=s[i]!=t[i];
  return res;
}

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

signed main(){
  string s,t;cin>>s>>t;
  int ans=1e9;
  for(int i=0;i<s.size();i++)chmin(ans,f(s.substr(i,t.size()),t));
  cout<<ans<<endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
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;}

int main(){
    double a, b, k;
    cin >> a >> b >> k;
    double V = a * a * b;
    double ans;
    if (k > V / 2) {
        double c = 2 * b - (2 * k) / (a * a);
        ans = atan(a / c);
    }
    else{
        double c = (2 * k / (a * b));
        ans = atan(c / b);
    }
    ans = 180 * ans / M_PI;
    ans = 90 - ans;
    printf("%.10f\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define IN(type, n) type n; cin >> n

int main() {
  IN(ll, X);
  IN(ll, K);
  IN(ll, D);

  X = abs(X);
  if (X / D >= K) {
    cout << X - K * D << endl;
  } else {
    ll x1 = X % D;
    ll x2 = abs(x1 - D);
    if ((K - (X / D)) % 2 == 0) cout << x1 << endl;
    else cout << x2 << endl;
  }

  return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>
#define NIL -1
#define N 25

typedef struct{
  int pare,sib,left,right;
}Node;

void preParse(int);
void inParse(int);
void postParse(int);

Node T[N];



int main()
{
  int n=0,m,i,child,root=0,right,left;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      T[i].pare=NIL;
      T[i].sib=NIL;
      T[i].left=NIL;
      T[i].right=NIL;
    }

  for(i=0;i<n;i++)
    {
      scanf("%d",&m);
      
          scanf("%d",&child);
          left=child;
          scanf("%d",&right);
      
          T[right].pare=m;
          T[left].pare=m;
          T[m].left=left;
          T[m].right=right;
    }
  for(i=0;i<n;i++)
    {
      if(T[i].pare==NIL)
        root=i;
    }

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}
    
void preParse(int u)
{
  if(u!=NIL)
    {
  printf(" %d",u);
  preParse(T[u].left);
  preParse(T[u].right);
}
}

void inParse(int u)
{
  if(u!=NIL)
    {
 inParse(T[u].left);
printf(" %d",u);
inParse(T[u].right);
}
}

void postParse(int u)
{
  if(u!=NIL)
    {
  postParse(T[u].left);
  postParse(T[u].right);
  printf(" %d",u);
}
}


Measured memory_bytes: 2104
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>

using namespace std;


/**
   ceil(0, 2) == 0
   ceil(1, 2) == 1
   ceil(2, 2) == 1
   ceil(3, 2) == 2
   ceil(4, 2) == 2
*/
template<class T>
T ceil(T dividend, T divisor)
{
    return (dividend + (divisor - 1)) / divisor;
}

int main()
{
    int64_t H, W;
    std::cin >> H >> W;

    if (H % 3 == 0 || W % 3 == 0) {
        std::cout << 0 << std::endl;
        return 0;
    }

    int64_t m1 = std::min(H, W);

    int64_t m2 = INT64_MAX;
    int64_t m3 = INT64_MAX;

    for (int64_t i = 1; i < H; ++i) {
        int64_t a = i * W;
        int64_t b = (H-i) * ceil(W, (int64_t)2);
        int64_t c = (H-i) * (W/2);

        m2 = std::min(m2, std::max({a, b, c}) - std::min({a, b, c}));
    }

    for (int64_t i = 1; i < W; ++i) {
        int64_t a = i * H;
        int64_t b = (W-i) * ceil(H, (int64_t)2);
        int64_t c = (W-i) * (H/2);

        m3 = std::min(m3, std::max({a, b, c}) - std::min({a, b, c}));
    }

    std::cout << std::min({m1, m2, m3}) << std::endl;
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <set>
#include <queue>
#include <bitset>
#include <cassert>

using namespace std;

struct UnionFind {

    // par[i] is parent of i
    // root of i is par[par[par[../par[i]...]]]
    vector<int> par;
    vector<int> sz;

    UnionFind(int N) : par(N), sz(N) {
        for (int i = 0; i < N; ++i) {
            par[i] = i;
            sz[i] = 1;
        }
    }

    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            // path compression
            return par[x] = find(par[x]);
        }
    }

    bool same(int p, int q) {
        return find(p) == find(q);
    }

    void unite(int p, int q) {

        int pr = find(p);
        int qr = find(q);
        if (pr == qr) {
            return;
        }
        if (sz[pr] < sz[qr]) {
            par[pr] = qr;
            sz[qr] += sz[pr];
        } else {
            par[qr] = pr;
            sz[pr] += sz[qr];
        }
    }

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

    string asString() {
        string sb;
        for (int i = 0; i < par.size() - 1; ++i) {
            sb += to_string(par[i]);
            sb += ",";
        }
        sb += to_string(par[par.size() - 1]);
        return sb;
    }
};

int main() {
    int N;
    cin >> N;
    int M;
    cin>>M;
    UnionFind uf = UnionFind(N);
    for (int i = 0; i < M; ++i) {
        int A, B;
        cin >> A >> B;
        A -= 1;
        B -= 1;
        uf.unite(A, B);
    }
    int m = 0;
    for (int i = 0; i < N; ++i) {
        m = max(m, uf.size(i));
    }
    cout << m << endl;
}


Measured memory_bytes: 4840
// https://atcoder.jp/contests/abc173/tasks/abc173_e
// AtCoder Beginner Contest 173
// E - Multiplication 4

/*
Problem.
N個の整数A1, .., ANについて、
ちょうどK個の要素を選ぶ時、要素の積の最大値を求めよ。

Point.
1. K==Nなら自明
2. 答えが負になるのは、非負数がなく、Kが奇数の場合のみ　（それ以外なら非負：奇数個、負：偶数個で回避できる）
3. 非負数Pを降順、負数Mを昇順で持ち、P0*P1 >= M0*M1ならP0を追加する。それ以外はM0*M1を追加する。
（非負数を２つずつ追加すると、k値が奇数の時に負になり、最大化できない場合があるので注意）
これによりKが残り1個の時は必ず非負数を選べる。
*/

#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int> >;
using pii = pair<int, int>;
using ppi = pair<pii, int>;

#define INF ll(1e9+7)

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  ll n, k; cin >> n >> k;
  vector<ll> a(n);
  int isp = 0;
  for(int i = 0; i < n; i++){
    cin >> a[i];
    if(a[i] >= 0) isp++;
  }
  deque<ll> p, m;
  sort(a.begin(), a.end(), greater<ll>());
  for(int i = 0; i < n; i++){
    if(a[i] >= 0) p.push_back(a[i]);
  }
  sort(a.begin(), a.end());
  for(int i = 0; i < n; i++){
    if(a[i] < 0) m.push_back(a[i]);
  }
  ll ans = 1;

  if(k == n){
    for(int i = 0; i < n; i++){
      ans = ans * a[i] % INF;
    }
  }
  else if(isp == 0 && k%2){
    sort(a.begin(), a.end(), greater<ll>());
    for(int i = 0 ; i < k ; i++){
      ans = ans * a[i] % INF;
    }
  }
  else{
    while(k){
      if(k >= 2 && !(p.size() < 2 && m.size() < 2)){
        if(p.size() >= 2 && m.size() >= 2){
          if(p[0]*p[1] >= m[0]*m[1]){
            ans = ans * p[0] % INF;
            p.pop_front();
            k--;
          }
          else{
            ans = ans * (m[0] * m[1] % INF) % INF;
            m.pop_front(); m.pop_front();
            k -= 2;
          }
        }
        else if(m.size() < 2){
          ans = ans * p[0] % INF;
          p.pop_front();
          k--;
        }
        else if(p.size() < 2){
          ans = ans * (m[0] * m[1] % INF) % INF;
          m.pop_front(); m.pop_front();
          k -= 2;
        }
      }
      else{
        ans = ans * p[0] % INF;
        p.pop_front();
        k--;
      }
    }
  }

  cout << ((ans>=0)? ans : INF+ans) << endl;

  // end-----------------------------------------------
  // cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 6388
#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>

using namespace std;

int main()
{
    long long k,maxn=0,s,i,a,b,n;
    scanf("%lld %lld %lld",&a,&b,&n);
    i=b-1;
    if(i>n)
    {
        i=n;
    }
    s=(a*i)/b-a*(i/b);
    printf("%lld\n",s);
    //system("pause");
    return 0;
}

Measured memory_bytes: 3760
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int w,h,x,y,r;
    	w = sc.nextInt();
    	h = sc.nextInt();
    	x = sc.nextInt();
    	y = sc.nextInt();
    	r = sc.nextInt();

    	if(x+r > w || y+r > h || x-r < 0 || y-r < 0){
    		System.out.println("No");
    	}else{
    		System.out.println("Yes");
    	}


    }
}

Measured memory_bytes: 26232
import math
 
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
 
a,b,c,d=map(int,input().split())
 
c_div=(b//c)-((a-1)//c)
d_div=(b//d)-((a-1)//d)
cd_div=(b//lcm(c,d))-((a-1)//lcm(c,d))
 
ans=(b-a+1)-((c_div)+(d_div)-(cd_div))
print(ans)

Measured memory_bytes: 9204
#include <iostream>
#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
#define MAX 100100
//#define NIL -1

int main() {
    LL n;
    LL k;
    cin >> n >> k;
    vector<LL> num_list(k);
    for(LL i=0; i<k; i++){
        cin >> num_list[i];
    }

    LL ans;

    for(LL i=n; i<100000; i++){
        bool is_ok=true;
        LL kiyu=i;
        LL kbt;
        //cout << i << endl;
        while(kiyu>0){
            kbt=kiyu%10;
            for(LL j=0; j<k; j++){
                if(kbt==num_list[j]){
                    is_ok=false;
                    break;
                }
            }
            kiyu/=10;
            //cout << kiyu << endl;
        }
        if(is_ok==true){
            ans=i;
            break;
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i,0,n) cin >> d[i];
  sort(d.begin(), d.end());
  int ans = d[n/2] - d[n/2-1];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3744
# -*- coding: utf-8 -*-
"""
Created on Mon Sep  7 22:29:36 2020

@author: liang
"""
N, K = map(int, input().split())

P = [1 + (int(p)-1)*0.5 for p in input().split()]
#print(P)

tmp = sum(P[:K])
ans = tmp
for i in range(N-K):
    tmp += P[K+i] - P[i]
    if tmp > ans:
        ans = tmp
    
print(ans)

Measured memory_bytes: 31968
#include <bits/stdc++.h>
#define deb(x)     cerr << (#x) << " : " << (x) << "\n"
#define ll long long int
#define ld long double
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
using namespace std;
 
ll powmod(ll a, ll b, ll mod = MOD){
	if(!a and !b)	return 1ll;
	if(!a)	return a;
	ll res = 1ll;
	b %= (mod - 1ll), a %= mod;
	while(b){
		if(b%2 == 1)	res = (res * a) % mod;
		a = (a * a) % mod;
		b /= 2;
	}
	return res;
}

vector<vector<pair<int, int>>> edges, er;
int ind[300000], dep[300000];
bool vis[300000], state[300000];
int par[300000];

void dfs(int u, int depth = 0, int parent = 0){
	ind[u]--;
	if(par[u] == -1 or (depth) > dep[u])	dep[u] = depth, par[u] = parent;
	if(ind[u] > 0)	return;
	vis[u] = true;
	// if(u == 1)	deb(dep[par[u]]), deb(dep[parent]), deb(parent);
	// if(u == 6)	deb(dep[par[u]]), deb(dep[parent]), deb(depth);
	for(auto v : edges[u]){
		if(!vis[v.first])	dfs(v.first, dep[u] + 1, u);
	}
}
 
int main(){	

 
	ios::sync_with_stdio(false);
	cin.tie(NULL);
 
	int n, m;
	cin >> n >> m;
	edges.resize(n + 1);
	er.resize(n + 1);
	int u, v;
	memset(ind, 0, sizeof(ind));
	memset(vis, false, sizeof(vis));
	memset(par, -1, sizeof(par));
	for(int i = 0; i < (n + m - 1); i++){
		cin >> u >> v;
		edges[u].push_back({v, i});
		er[v].push_back({u, i});
		ind[v]++;
	}

	int root = 1;
	for(int i = 1; i <= n; i++)	if(!ind[i])	root = i;
	dep[root] = 0, dfs(root);

	for(int i = 0; i < (n); i++){
		if(i == (root - 1))	cout << 0 << "\n";
		else	cout << par[i + 1] << "\n";
	}
}

Measured memory_bytes: 20224
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int a,b;
    cin>>a>>b;
    vector<int> s(3);
    s[0]=a+a-1;
    s[1]=b+b-1;
    s[2]=a+b;
    int ans=0;
    rep(i,3){
        ans=max(ans,s[i]);
    }
    cout<<ans<<endl;
}

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

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

using namespace std;

int main(){
	int n,h[100]; cin>>n;
	rep(i,n) cin>>h[i];

	int ans=0,y[100]={};
	rep(_,101){
		bool first=true;
		rep(i,n){
			if(y[i]<h[i]){
				y[i]++;
				if(first) first=false, ans++;
			}
			else first=true;
		}
	}
	cout<<ans<<endl;

	return 0;
}


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

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
typedef long long ll;
bool prime[10000000];
void makePrime(){
  memset(prime,true,sizeof(prime));
  prime[0] = false;
  prime[1] = false;

  for(int i = 0; i * i < 10000000; i++){
    if(prime[i] == false) continue;
    ll x = 2;
    while(x*i < 10000000){
      prime[x*i] = false;
      x++;
    }
  }
}



void solve(ll a, ll b){
  int cnt = 0;
  vector<int> p;
  for(int i = a+1; cnt < 110; i++){
    if(prime[i]){
      p.push_back(i);
      cnt++;
    }
  }
  vector<int> sum;
  rep(i,110){
    for(int j = i; j < 110; j++){
      sum.push_back(p[i]+p[j]);
    }
  }
  sort(sum.begin(), sum.end());
  // rep(i,sum.size()) cout << sum[i] << " ";
  // cout << endl;
  cout << sum[b-1] << endl;
}


int main(){
  ll a,b;
  makePrime();
  while(true){
    cin >> a >> b;
    if(a == -1 && b == -1) break;
    solve(a,b);
  }
  return 0;
}



Measured memory_bytes: 12840
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main(void){
    int a, b, c;

    cin >> a >> b >> c;

    if(a == b && b == c){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256