akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>
#include<cassert>

using namespace std;

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

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;



int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);

 ios_base::sync_with_stdio(false);
 cin.tie(NULL);

 int ans=0,N,num;cin>>N;
 rep(i,N) {
   cin >> num;
   if(i%2 == 0 && num% 2 == 1) ans++;
 }
 cout<<ans;

 return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define sz(v) (ll((v).size()))
#define forn(i,n) for(ll i=0;i<(n);i++)
#define forr(i,n) for(ll i=(n)-1;i>=0;i--)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
#define clr(x) memset(x,0,sizeof(x))

const ll mod =1e9+7;

void add_self(ll &a, ll b){a+=b;if(a>=mod)a-=mod;}
void sub_self(ll &a, ll b){a-=b;if(a<0)a+=mod;}
void mul_self(ll &a, ll b){a*=b;a%=mod;}
void max_self(ll &a, ll b){if(b>a)a=b;}

ll power(ll a, ll x){ll ret=1;while(x){if(x%2)mul_self(ret,a);x/=2;mul_self(a,a);}return ret;}

struct blocks{

	ll w,s,v;
	blocks(){w = s = v =0;}

	bool operator < (blocks const & b){return w+s < b.w+b.s; }

	void read(){cin>>w>>s>>v;}

};

const ll N = 1e4+4;
vector<ll> dp(N,0);

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

    ll n,ans=0;cin>>n;
    vector<blocks> block(N);

    forn(i,n)block[i].read();
    sort(all(block));

	for(auto now: block)
	{
		for(int weight = now.s;weight>=0;weight--)
		{
			ll new_weight = weight + now.w;
			if(new_weight>=N)max_self(ans, dp[weight]+now.v);
			else max_self(dp[new_weight],dp[weight]+now.v);
		}
	}
	forn(i,N)max_self(ans , dp[i]);
	cout<<ans<<endl;

}


Measured memory_bytes: 640
import sys,math
import numpy as np

r=int(sys.stdin.readline())
#n,k=map(int,sys.stdin.readline().split())
#a=np.array(sys.stdin.readline().split(),dtype='int64')
#a=np.array([sys.stdin.readline().split() for i in range(n)],dtype='int64')

print(2*3.141592*r)


Measured memory_bytes: 27144
from statistics import median

n = int(input())
a = [None] * n
b = [None] * n
for i in range(n):
    a[i], b[i] = map(int, input().split())

if n % 2 == 1:
    print(abs(median(b) - median(a)) + 1)
else:
    print(int(abs(median(b) - median(a)) * 2) + 1)


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

#define ll long long
#define MOD 1000000007
#define vi vector<int>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define vvi vector<vector<int>>
#define INF (ll)1e9
#define fora(i,a,b) for(ll i=a;i<b;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define si size()
#define be begin()
#define en end()
#define le length()
#define mp(x,y) make_pair(x,y)
#define mli map<ll,int>
#define mll map<ll,ll>

using namespace std;

int main()
{   ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    ll n,cnt=0;
    cin>>n;
    vll v(n);
    fora(i,0,n)
    {cin>>v[i];
    if(i%2==0&&v[i]%2!=0)
    cnt++;}
    cout<<cnt<<endl;
    return 0;
}




Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> PA;
typedef priority_queue<int, vector<int>, greater<int> > PQG;
#define REP(i, a, n) for(ll i = (ll) a;i < (ll) n;i++)
#define fi first
#define se second
#define pb push_back
#define INF 2000000009
#define MOD 1000000007
#define MAXN 200005
#define MAXM 200005
#define MAXV 1000000009

int n, a[MAXN];

int main()
{
    cin >> n;
    REP(i, 0, n){
        cin >> a[i];
    }
    for(int i = n - 1; i >= 0; i--){
        if(n % 2 == (i + 1) % 2)
            printf("%d ", a[i]);
    }
    for(int i = 0; i < n; i++){
        if(n % 2 != (i + 1) % 2){
            printf("%d ", a[i]);
        }
    }
    printf("\n");



    return 0;
}
/*
*/





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

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

int main(){
  int64_t A, B, N;
  cin >> A >> B >> N;

  int64_t max_x = min(N-A/B+1, N);
  //if(max_x>=B) max_x = B-1;
  int64_t max_y = min(N, B-1);

  int64_t ans_x = (A*max_x)/B - A*int64_t(max_x/B);
  int64_t ans_y = (A*max_y)/B - A*int64_t(max_y/B);
  cout << max(ans_x, ans_y);
  
}

Measured memory_bytes: 3584
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {
    n:usize,
    s:[String;n],
     }
    let mut mp = BTreeMap::new();
    for strn in s.iter() {
        *mp.entry(strn.as_str()).or_insert(0i64) += 1i64;
    }
    for c in ["AC", "WA", "TLE", "RE"].iter() {
        println!("{} x {}", c, *mp.entry(c).or_insert(0));
    }
}


Measured memory_bytes: 7784
#include <iostream>
using namespace std;
int main(){
  double a;
  double b;
  cin >> a >> b;
  if (a < b){
    cout << "a < b" << endl;
  }
  if (a>b){
    cout << "a > b" << endl;
  }
  if (a == b){
    cout << "a == b" << endl;
  }
}


Measured memory_bytes: 3172
//
//  main.cpp
//  1234
//
//  Created by Moha Jain on 14/04/20.
//  Copyright © 2020 Moha Jain. All rights reserved.
//

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<math.h>
#include <iomanip>
using namespace std;

int main()
{
   long long int r;cin>>r;
    long double ans;
    ans=2*(22.0/7.0)*r;
    cout<<setprecision(20)<<ans<<endl;
}


Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <string>
#include <stack>
#include <iomanip>
#include <numeric>
#include <queue>
#include <climits>
#include <set>
#include <complex>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
#define MOD 1000000007
#define INF 1LL << 59

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    //cout << fixed << setprecision(7);

    long n;
    while (scanf("%ld", &n) != EOF)
    {
        cout << n * (n + 1) / 2 + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3176
#include<stdio.h>
int main(){
	int a,b;
	while(scanf("%d %d",&a,&b)!=EOF){
		if(a==0&&b==0)break;
		for(int i=0;i<a;i++){
			for(int j=0;j<b;j++){
				printf("#");
 			}
			printf("\n");
		}
		printf("\n");
	}
}



Measured memory_bytes: 2080
#include <iostream>
#include <numeric>
using namespace std;
int main(void){
    int a,b,k,result,count=0;
    cin >> a >> b >> k;
    for(int i=min(a,b);i>0;i--){
        if(a%i==0 && b%i==0){
            count++;
            if(count==k) result=i;
        }
    }
    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cassert>
#include<vector>
#include<cmath>
#include<cstdio>
#include<algorithm>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)

using namespace std;

struct P
{
  int to,cost;
  P(int to=inf,int cost=inf):to(to),cost(cost){}
};

//
template<typename T>
bool visit(const T& G,int v,vector<int>& order,vector<int>& color)
{
  color[v] = 1;
  for(__typeof((G[v]).begin()) e = G[v].begin();e != G[v].end();e++)
    {
      if(color[e->to] == 2)continue;//テ」ツ?禿」ツ?ョvisitテ、ツサツ・テ・ツ、ツ姪」ツ?ョvisitテ」ツ?ァティツィツェテ」ツつ古」ツ??
      if(color[e->to] == 1)return false;//テ」ツ?禿」ツ?ョvisitテ」ツ?ァティツィツェテ」ツつ古」ツ??
      if(!visit(G,e->to,order,color))return false;
    }
  order.push_back(v);
  color[v] = 2;
  return true;
}

template<typename T>
bool topologicalSort(const T& G,vector<int>& order)
{
  int SizeG = G.size();
  vector<int> color(SizeG); 
  for(int u=0;u<SizeG;u++)
    if(!color[u] && !visit(G,u,order,color))
      return false;
  reverse(order.begin(),order.end());
  return true;
}
//

int n,m,a,b;

int main()
{
  cin >> n >> m;
  assert(n >= 2);
  vector<vector<P> > G(n,vector<P>());
  rep(_,m)
    {
      scanf("%d %d",&a,&b);
      a--,b--;
      G[a].push_back(P(b,1));
    }
  vector<int> order;
  topologicalSort(G,order);
  rep(i,order.size())cout << order[i]+1 << endl;
  int stlen[n],cnt[n];

  rep(i,n)stlen[i] = 0,cnt[i] = 0;
  rep(i,n)rep(j,G[order[i]].size())
    stlen[G[order[i]][j].to] = max(stlen[G[order[i]][j].to],stlen[order[i]]+1);

  //rep(i,n)cout << "stlen[" << i << "] = " << stlen[i] << endl;

  rep(i,n)cnt[stlen[i]]++;

  bool check = false;
  rep(i,n)if(cnt[i] >= 2)check = true;

    cout << check << endl;

  return 0;
}

Measured memory_bytes: 2788
#include<bits/stdc++.h>
using namespace std;
void swap(int &a,int &b)
{
	int c=a;
	a=b;
	b=c;
}
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<b)
		swap(a,b);
	if(a<c)
		swap(a,c);
	if(b<c)
		swap(b,c);
	printf("%d",a*10+b+c);
	return 0;
 } 

Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static         Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static long mod =1000000007;
	public static void main(String[] args) {
		int N=sc.nextInt();
		int K=sc.nextInt();
		ArrayList<Integer> cc = new ArrayList<>(N);
		
		for(int i=0;i<N;i++) {
			cc.add(sc.nextInt());
		}
		Collections.sort(cc);
		int ans=1111111111;
		for(int i=0;i+K-1<N;i++) {
			
			ans=Math.min(cc.get(i+K-1)-cc.get(i),ans);
		}
		p(ans);
	}
	//N==S
	//E==W
//83 S 
	//69E
	//78N
	//87W
	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 61576
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
#%%code
def resolve():
    N,=pin()
    hon=["pon","pon","hon","bon","hon","hon","pon","hon","pon","hon"]
    print(hon[N%10])
#%%submit!
resolve()

Measured memory_bytes: 61920
import sys
def input():
	return sys.stdin.readline()[:-1]

INF = 10**30
n = int(input())
p = [input().split() for _ in range(n)]

"""
[0]: max or min / for
[1]: max or min / against
[2]: max or min / fixed
"""

r = [-INF, -INF, -INF]
l = [INF, INF, INF]
u = [-INF, -INF, -INF]
d = [INF, INF, INF]

for x, y, t in p:
	x, y = int(x), int(y)
	if t == "R":
		r[0] = max(r[0], x)
		l[1] = min(l[1], x)
		u[2] = max(u[2], y)
		d[2] = min(d[2], y)
	elif t == "L":
		r[1] = max(r[1], x)
		l[0] = min(l[0], x)
		u[2] = max(u[2], y)
		d[2] = min(d[2], y)
	elif t == "U":
		r[2] = max(r[2], x)
		l[2] = min(l[2], x)
		u[0] = max(u[0], y)
		d[1] = min(d[1], y)
	else:
		r[2] = max(r[2], x)
		l[2] = min(l[2], x)
		u[1] = max(u[1], y)
		d[0] = min(d[0], y)

#print(r)
#print(l)
#print(u)
#print(d)

timings = set([0])

if r[0] <= r[1] <= r[2]:
	timings.add(abs(r[2]-r[0]))
elif r[0] <= r[2] <= r[1]:
	timings.add(abs(r[1]-r[0])/2)
	timings.add(abs(r[2]-r[0]))
	timings.add(abs(r[1]-r[2]))
elif r[1] <= r[0] <= r[2]:
	timings.add(abs(r[2]-r[0]))
elif r[2] <= r[0] <= r[1]:
	timings.add(abs(r[1]-r[0])/2)

if l[0] >= l[1] >= l[2]:
	timings.add(abs(l[2]-l[0]))
elif l[0] >= l[2] >= l[1]:
	timings.add(abs(l[1]-l[0])/2)
	timings.add(abs(l[2]-l[0]))
	timings.add(abs(l[1]-l[2]))
elif l[1] >= l[0] >= l[2]:
	timings.add(abs(l[2]-l[0]))
elif l[2] >= l[0] >= l[1]:
	timings.add(abs(l[1]-l[0])/2)

if u[0] <= u[1] <= u[2]:
	timings.add(abs(u[2]-u[0]))
elif u[0] <= u[2] <= u[1]:
	timings.add(abs(u[1]-u[0])/2)
	timings.add(abs(u[2]-u[0]))
	timings.add(abs(u[1]-u[2]))
elif u[1] <= u[0] <= u[2]:
	timings.add(abs(u[2]-u[0]))
elif u[2] <= u[0] <= u[1]:
	timings.add(abs(u[1]-u[0])/2)

if d[0] >= d[1] >= d[2]:
	timings.add(abs(d[2]-d[0]))
elif d[0] >= d[2] >= d[1]:
	timings.add(abs(d[1]-d[0])/2)
	timings.add(abs(d[2]-d[0]))
	timings.add(abs(d[1]-d[2]))
elif d[1] >= d[0] >= d[2]:
	timings.add(abs(d[2]-d[0]))
elif d[2] >= d[0] >= d[1]:
	timings.add(abs(d[1]-d[0])/2)

#print(timings)
ans = 10**30
for t in timings:
	if t > 10**10:
		continue
	R, L, U, D = -INF, INF, -INF, INF
	for x, y, di in p:
		if di == "R":
			x, y = int(x)+t, int(y)
		elif di == "L":
			x, y = int(x)-t, int(y)
		elif di == "U":
			x, y = int(x), int(y)+t
		else:
			x, y = int(x), int(y)-t

		R = max(R, x)
		L = min(L, x)
		U = max(U, y)
		D = min(D, y)

	ans = min(ans, (R-L)*(U-D))

print(ans)

Measured memory_bytes: 33852
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  double n,m,a,b,c,d,x,y,z;
  string s,t;
  //

  // ここから
  IN3(a,b,c);
  YES((a+c)/2 == b);
}

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

int main(void)
{
    int N;
    cin >> N;

    vector<int> height(N, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> height.at(i);
    }

    int counter, found = 1;
    ;
    int temp;
    int first = height.at(0);
    for (int i = height.size() - 1; i > 0; i--)
    {
        counter = 0;
        for (int j = i - 1; j >= 0; j--)
        {
            if (height.at(i) >= height.at(j))
                counter++;
            if (counter == i)
                found++;
        }
    }
    cout << found << endl;

    return (0);
}

Measured memory_bytes: 256
N,M = map(int,input().split())
 
H = list(map(int,input().split()))
 
H_peak = list()
for i in range(N):
    H_peak.append(list())
 
for i in range(M):
    A,B = map(int,input().split())
    H_peak[A-1].append(B)
    H_peak[B-1].append(A)
 
good = 0
flag = 1
for i in range(N):
    for j in H_peak[i]:
 
        if H[i] <= H[j-1]:
            flag = 0
    if flag == 1:
 
        good += 1
    flag = 1
 
 
print(good)

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

class Mondai
{
    static void Main()
    {
        var NX = Console.ReadLine().Split(' ').Select(n => Int32.Parse(n)).ToArray();
        var N = NX[0];
        var X = NX[1];
        var L = Console.ReadLine().Split(' ').Select(n => Int32.Parse(n)).ToArray();
        var current = 0;
        var count = 1;
        for (int i=0;i<N;i++)
        {
            current += L[i];
            if (current <= X) count++;
        }
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007 /*998244353*/;
int main(){
    int n;
    cin >> n;
    ll cnt = 0;
    for (int i = 1; i < n; i++){
        for (int j = 1; j <= n / i; j++){
            if(i * j < n)
                cnt++;
        }
    }
    cout << cnt << "\n";
}

Measured memory_bytes: 3584
//#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
    
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    vector<ll> v(n);
    FOR(i,0,n)cin>>v[i];
    sortAl(v);
    ll ans = 0;
    FOR(i,0,n-k){
        ans += v[i];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

  int x, y;
  cin >> x >> y;

  if(x == y){
    cout << 0 << endl;
    return 0;
  }

  int ans;
  if(x < y){
    if(x >= 0 || y <= 0){
      ans = y - x;
    }
    else if(abs(x) <= abs(y)){
      ans = 1 + y - (-x);
    }
    else{
      ans = (-y) - x + 1;
    }
  }
  else{
    if(y >= 0){
      ans = 1 + (-y) - (-x) + ((y != 0) ? 1 : 0);
    }
    else if(x <= 0){
      ans = (-y) - (-x) + 1 + ((x != 0) ? 1 : 0);
    }
    else if(abs(x) <= abs(y)){
      ans = (-y) - x + 1;
    }
    else{
      ans = 1 + y - (-x);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_DEPRECATE
#define _USE_MATH_DEFINES
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <memory.h>
#include <set>
#include <ctime>
#include <map>
#include <cstring>
#include <iterator>
#include <queue>
#include <assert.h>
#include <bitset>
#include <complex>
#include <unordered_map>

//#pragma comment(linker, "/STACK:512000000")

using namespace std;

#define pb emplace_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < (n); ++i)
#define forab(i, a, b) for (int i = (a); i < (b); ++i)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int infi = 1e9 + 7;
const ll infl = (ll)1e18 + (ll)7;

ll ar[100500];

int32_t main() {
    cin.sync_with_stdio(false);
    cin.tie(0);
    //srand(time(NULL));
   // freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    //freopen("customs.in", "r", stdin); freopen("customs.out", "w", stdout);
    ll n, sum = 0;
    cin >> n;
    forn(i, n) {
        cin >> ar[i];
        sum += ar[i] % 2;
    }
    if (sum == 0)
        cout << "second\n";
    else
        cout << "first\n";


    return 0;
}


Measured memory_bytes: 1024
until (n = gets.to_i).zero?
  n.times do
    p = gets.split.map(&:to_i)
    
    avg = p.inject(:+) / 3.0
    
    if p.include?(100) || (p[0] + p[1]) / 2 >= 90 || avg >= 80
      puts "A"
    elsif avg >= 70 || (avg >= 50 && (p[0] >= 80 || p[1] >= 80))
      puts "B"
    else  
      puts "C"
    end
  end
end

Measured memory_bytes: 8892
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    string s;
    cin>>s;
    int ans=0;
    deque<char> que;
    rep(i, s.size()) que.push_back(s[i]);
    bool ok = true;
    while(!que.empty()){
        if(que.size()==1) break;
        else if(que.front() == que.back()){
            que.pop_front();
            que.pop_back();
        }
        else if(que.front() == 'x' && que.back() != 'x'){
            que.pop_front();
            ans++;
        }
        else if(que.front() != 'x' && que.back() == 'x'){
            que.pop_back();
            ans++;
        }
        else {
            ok=false;
            break;
        }
    }
    if(ok){
        cout<<ans<<endl;
    }
    else cout<<-1<<endl;
    return 0;
}

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

int n;
int func(string s, int c) {
  if (c == 0) {
    if (s.find('3') == string::npos) return 0;
    if (s.find('5') == string::npos) return 0;
    if (s.find('7') == string::npos) return 0;
    return stoi(s) <= n;
  }
  
  int sum = 0;
  sum += func(s + '3', c - 1);
  sum += func(s + '5', c - 1);
  sum += func(s + '7', c - 1);
  return sum;
}

int main() {
  cin >> n;
  
  int sum = 0;
  for (int i = 1; i <= 9; ++i) {
    sum += func("", i);
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 16;
const int mod = 1000000007;

int n;
int x[maxn][maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  cin>>n;
  memset(x,-1, sizeof(x));
  for(int i=1;i<=n;i++){
    int m;
    cin>>m;
    while(m--){
      int xx,yy;
      cin>>xx>>yy;
      x[i][xx] = yy;
    }
  }
  int ret = 0;
  for(int i=0;i<(1<<n);i++){
    bool sign = 0;
    int cc = 0;
    for(int j=0;j<n;j++){
      if(i&(1<<j)){
        cc++;
        for(int k=1;k<=n;k++) {
          if (x[j + 1][k] == 0 && (i & (1 << (k - 1))))sign = 1;
          else if(x[j+1][k] == 1 && !(i&(1<<(k-1))))sign=1;
        }

      }
    }
    if(!sign)ret=max(ret,cc);
  }
  cout<<ret<<endl;
  return 0;
}

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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
using vvl = vector<vl>;
using pll = pair<ll,ll>;
using vb = vector<bool>;

const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;

#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define xx first
#define yy second

#define has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define FORD(i,a,b) for (int i=int(b)-1; i>=(a); i--)

#define rv(type,name,count) vector<type> name(count); FOR(_i,0,count) cin >> name[_i];
#define grid(type,name,c1,c2) vector<vector<type>> name(c1, vector<type>(c2)); FOR(_i,0,c1)FOR(_j,0,c2)cin >> name[_i][_j];
vvl nex;
vl values;
vl res;

void dfs(ll n, ll last, ll counter) {
	res[n] = counter + values[n];
	for(ll x : nex[n]) {
		if (x != last) dfs(x, n, res[n]);
	}
}

int main() {
	ll n, q;
	cin >> n >> q;
	nex = vvl(n);
	values = vl(n);
	res = vl(n);
	FOR(i,0,n-1) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		nex[a].pb(b);
		nex[b].pb(a);
	}
	FOR(i,0,q) {
		ll p, x;
		cin >> p >> x;
		p--;
		values[p] += x;
	}
	dfs(0, -1, 0);
	FOR(i,0,n) cout << res[i] << " ";
	cout << endl;
}


Measured memory_bytes: 25856
#include <bits/stdc++.h>
#define int long long
#define mod 998244353
#define foi(i,n) for(int i = 0; i < n ; ++i)
#define pi pair<int,int>
#define pb push_back
#define debug cout << "here" << endl;
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

int dp[100000];

int findProfit(int mask,int arr[16][16]){
	int answer =0 ;
	vector<int> points;
	int ctr =0 ;
	while(mask){
		if(mask&1) points.pb(ctr);
		ctr++;
		mask = mask>>1;
	}

	for(int i = 0 ;i < points.size();i++){
		for(int j = i+1 ; j < points.size();j++) answer += arr[points[i]][points[j]];
	}

	//for(auto y : points ) cout << y << " ";
	//cout << endl;
	return answer;
}

void init(int n,int arr[16][16]){
	dp[0] = 0;

	for(int i = 1 ; i <= (((1)<<n)-1) ; i++){
		int answer = findProfit(i,arr);
		for(int j = i-1 ; j>=0 ; j--){
			if((j|i) == i) answer = max(answer , dp[j] + dp[(i^j)]);
		}
		dp[i] = answer;
	}


}


int32_t main(){

    memset(dp,0,sizeof(dp));

	int n;
	cin >> n;

	int arr[16][16];

	foi(i,n){
		foi(j,n) cin >> arr[i][j] ;
	}

	init(n,arr);

	cout << dp[((1LL)<<n)-1];

}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using  namespace std;
int main()
{
    int n;
    cin>>n;
    int m=n/1000;
    int r=n%1000;
    if(m==0)
        cout<<1000-n<<endl;
    else if(r==0)
        cout<<r<<endl;
    else
    {
        cout<<(m+1)*1000-n<<endl;
    }
}


Measured memory_bytes: 3592
#include "bits/stdc++.h"
#define hhh cerr<<"hhh"<<endl
#define see(x) cerr<<(#x)<<'='<<(x)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pr;
inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}

const int maxn = 1e2+7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+7;

int c[maxn];
int a[maxn][maxn];
int b[maxn];

int main() {
    int n=read(), m=read(), x=read();
    for(int i=0; i<n; ++i) {
        c[i]=read();
        for(int j=1; j<=m; ++j) a[i][j]=read();
    }
    int ans=inf;
    for(int s=0; s<1<<n; ++s) {
        int tmp=0;
        memset(b,0,sizeof(b));
        for(int i=0; i<n; ++i) if(s>>i&1) {
            tmp+=c[i];
            for(int j=1; j<=m; ++j) b[j]+=a[i][j];
        }
        int f=1;
        for(int i=1; i<=m; ++i) {
            if(b[i]<x) { f=0; break; }
        }
        if(f) ans=min(ans,tmp);
    }
    cout<<(ans!=inf?ans:-1)<<endl;
}

Measured memory_bytes: 3644
#include <cstdio>
 
typedef long long ll;
 
int main() {
	ll a, b, c;
	scanf("%lld %lld.%lld", &a, &b, &c);
 
	ll part1 = a * b;
	ll part2 = a * c;
 
	part1 = part1 + (part2 / 100);
	printf("%lld", part1);
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define ar array
#define pb push_back

int n,m;
const int mxn=1e3+2;
vector<vector<char>> adj;
const int INF=0x3f;
int dp[mxn][mxn];
bool vis[mxn][mxn];
const int mod=1e9+7;

bool ok(int x,int y)
{
	if(x>=0&&x<n&&y>=0&&y<m&&!vis[x][y])
	{
		return true;
	}
	return false;
}
void dfs(int x,int y)
{
	vis[x][y]=true;
	if(ok(x+1,y)&&adj[x+1][y]=='.')
	{
		dfs(x+1,y);
		dp[x][y]+=dp[x+1][y];
		cout<<x<<' '<<y<<' '<<dp[x][y]<<'\n';
	}
	if(ok(x,y+1)&&adj[x][y+1]=='.')
	{
		dfs(x,y+1);
		dp[x][y]+=dp[x][y+1];
		cout<<x<<' '<<y<<' '<<dp[x][y]<<'\n';
	}
}


int main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt","r",stdin);
	// 	freopen("outputc.txt","w",stdout);
	// #endif
	
	//int t;
	//cin>>t;
	//while(t--)
	{
		cin>>n>>m;
		adj=vector<vector<char>> (n,vector<char> (m));
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<m;j++)
			{
				cin>>adj[i][j];
			}
		}
		memset(dp,0,sizeof(dp));
		dp[0][0]=1;
		//dfs(0,0);
		//cout<<dp[0][0]<<'\n';
		//for(int i=0;i<n;i++)
		//{
			//for(int j=0;j<m;j++)
			//{
				//cout<<dp[i][j]<<' ';
			//}
			//cout<<'\n';
		//}
		for(int i=0;i<=n-1;i++)
		{
			for(int j=0;j<=m-1;j++)
			{
				if(i+1<=n-1&&adj[i][j]=='.')
				{
					dp[i+1][j]=(dp[i+1][j]+dp[i][j])%mod;
				}
				if(j+1<=m-1&&adj[i][j]=='.')
				{
					dp[i][j+1]=(dp[i][j+1]+dp[i][j])%mod;
				}
			}
		}
		//for(int i=0;i<n;i++)
		//{
			//for(int j=0;j<m;j++)
			//{
				//cout<<dp[i][j]<<' ';
			//}
			//cout<<'\n';
		//}
		cout<<dp[n-1][m-1]<<'\n';
	}
		
}


Measured memory_bytes: 8552
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void) {
  int N;
  scanf("%d", &N);
  char S[N];
  scanf("%s", S);

  int E[N+2], W[N+2];
  E[0] = W[N+1] = 0;
  for (int i = 1; i <= N; i++) {
    int j = N - i + 1;
    E[i] = E[i-1];
    W[j] = W[j+1];
    if (S[i-1] == 'W') E[i]++;
    if (S[j-1] == 'E') W[j]++;
  }

  int min = N;
  for (int i = 1; i <= N; i++) {
    if (min > E[i-1] + W[i+1]) min = E[i-1] + W[i+1];
  }
  printf("%d\n", min);

  return 0;
}

Measured memory_bytes: 2816
//       Author: Mostafa Mounir Shehab
 
#include <bits/stdc++.h>
using namespace std;
 
#define PI  acos(-1)
#define EPS (1e-10)
#define endl "\n"
#define SZ(v) (int)(v.size())
#define IO ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL), cerr.tie(NULL);
typedef long long ll;
typedef long double ld;
 

 
ll MOD=1e9 + 7;
ll OO=1e15;
const int N=1e5 + 5,M=1e5 + 5;
int arr[N];
ll dp[N][3];


int n,m,k,cnt,SU,idx,len,MN,MX,T;
int l,r,mid;
int a,b,c;
int ans;

vector<int> adj[N];

ll Solve(int u,int p,bool color){
	
	ll &ret = dp[u][color];
	if(~ret)
		return ret;
	ret = 1;
	
	for(int i:adj[u]){
		if(i == p) continue;
		
		ll val = Solve(i,u,true);
		if(color)
			val += Solve(i,u,false);
		
		ret*=val;
		ret%=MOD;
	}

	return ret;
}




int main(){
	IO
	
	memset(dp,-1,sizeof dp);
	
	cin>>n;
	for(int i=1;i<n;++i){
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	
	ll val = Solve(1,-1,0)+Solve(1,-1,1);
	val%= MOD;
	
	
	cout<<val<<endl;
	
	
}


Measured memory_bytes: 16384
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define pll pair<ll,ll>
#define pii pair<int,int>
#define F first
#define S second
const int maxn = 2e5 + 5;
vector<pair<int,pair<int,int>>>g[55];
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll dp[55][2555];
    pair<ll,ll>ch[55];
    int n, m, s;
    cin >> n >> m >> s;
    f(m) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        g[a].pb({b,{c,d}});
        g[b].pb({a,{c,d}});
    }
    f1(n) {
        cin >> ch[i].F >> ch[i].S;
    }
    memset(dp,0x3f,sizeof(dp));
    priority_queue<pair<ll,pair<int,int>>,vector<pair<ll,pair<int,int>>>,greater<pair<ll,pair<int,int>>>>pq;
    if (s > 2500) {
        dp[1][2500] = 0;
        pq.push({0,{1,2500}});
    }
    else {
        dp[1][s] = 0;
        pq.push({0,{1,s}});
    }
    while (pq.size()) {
        auto now = pq.top();
        pq.pop();
        if (now.F > dp[now.S.F][now.S.S])continue;
        //int t = 2;
        //while (1) {
            for (auto i:g[now.S.F]) {
                if (now.S.S >= i.S.F) {
                    int nm = now.S.S - i.S.F;
                    ll nc = now.F + i.S.S;
                    if (dp[i.F][nm] > nc) {
                        dp[i.F][nm] = nc;
                        pq.push({nc,{i.F,nm}});
                    }
                }
            }
            now.S.S += ch[now.S.F].F;
            now.F += ch[now.S.F].S;
            now.S.S = min(now.S.S,2500);
            if (dp[now.S.F][now.S.S] > now.F) {
                dp[now.S.F][now.S.S] = now.F;
                pq.push({now.F, {now.S.F,now.S.S}});
            }
        //}
    }
    for (int i = 2 ; i <= n ; i++) {
        ll mi = 1e18;
        fr(j,0,2501) {
            mi = min(mi,dp[i][j]);
        }
        cout << mi << '\n';
    }
}


Measured memory_bytes: 6356
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n ;
  cin >> n;
  vector<long>a1(n);
  vector<long>a2(n);
  for( int i = 0;i<n;i++){
    cin >> a1.at(i);
    a2.at(i) = a1.at(i);
  }
  long ans1 =0;
  int flag1 = 1;
  long sum = 0;
  for( int i=0;i<n;i++){   
    sum += a1.at(i);
    if(flag1 == 1){
      flag1 = -1;
      if(sum <= 0){
        ans1 += -sum + 1;
        sum = 1;
      }
    }
    else if(flag1== -1){
      flag1 = 1;
      if(sum >= 0){
        ans1 += sum + 1;
        sum = -1;
      }
    }
  }
  long ans2 =0;
  flag1 = -1;
  sum = 0;
  for( int i=0;i<n;i++){   
    sum += a2.at(i);
    if(flag1 == 1){
      flag1 = -1;
      if(sum <= 0){
        ans2 += -sum + 1;
        sum = 1;
      }
    }
    else if(flag1== -1){
      flag1 = 1;
      if(sum >= 0){
        ans2 += sum + 1;
        sum = -1;
      }
    }
  }
  cout << min(ans1,ans2) << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<stdlib.h>
using namespace  std;
struct NodeA
{
	int key;
	NodeA *left;
	NodeA *right;
};
NodeA *head = NULL;
void insert(int key)
{
	NodeA *next = head;
	NodeA *prev = NULL;
	bool isLeft = true;
	while (next != NULL)
	{
		prev = next;
		if ((*next).key >= key)
		{
			next = (*next).left;
			isLeft = true;
		}
		else if ((*next).key <= key)
		{
			next = (*next).right;
			isLeft = false;
		}
	}
	if (prev == NULL)
	{
		head = (NodeA *)malloc(sizeof(NodeA));
		(*head).key = key;
		(*head).left = NULL;
		(*head).right = NULL;
		return;
	}
	if (isLeft)
	{
		(*prev).left = (NodeA *)malloc(sizeof(NodeA));
		(*(*prev).left).key = key;
		(*(*prev).left).left = NULL;
		(*(*prev).left).right = NULL;
	}
	else
	{
		(*prev).right = (NodeA *)malloc(sizeof(NodeA));
		(*(*prev).right).key = key;
		(*(*prev).right).left = NULL;
		(*(*prev).right).right = NULL;
	}
	
}
void inOrder(NodeA *h)
{
	if (h == NULL)return;
	inOrder((*h).left);
	cout << " " << (*h).key;
	inOrder((*h).right);
}
void preOrder(NodeA *h)
{
	if (h == NULL)return;
	cout << " " << (*h).key;
	preOrder((*h).left);
	preOrder((*h).right);
}
void print()
{
	inOrder(head);
	cout << endl;
	preOrder(head);
	cout << endl;
}
int main()
{
	int m;
	cin >> m;
	for (int i = 0; i < m; i++)
	{
		string inst;
		cin >> inst;
		if (inst.compare("insert") == 0)
		{
			int key;
			cin >> key;
			insert(key);
		}
		else if (inst.compare("print") == 0)
		{
			print();
		}
	}
	return 0;
}

Measured memory_bytes: 16840
#include <stdio.h>
#include <stdlib.h>

int main(){
    int i;
    int n,l;
    int a[210];
    int sum,min;
    int tmp;
    int z = 0;
    

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

    a[1] = l+1-1;
    tmp = 1;
    sum = a[1];
    min = abs(a[1]);
    for(i = 2 ;i <= n ; i++){
        a[i] = l + i -1;
        sum += a[i];
        if(abs(a[i]) < min){
            min = abs(a[i]);
            tmp = i;
        }
        //printf("%d ",a[i]);
    }
    //printf("%d\n",sum);
    for(i = 1 ; i <= n ; i++){
        if(tmp != i){
            z+=a[i];
        }
      
        
    }
    printf("%d\n",z);


    return 0;


}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second

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

    int h,w,m;cin>>h>>w>>m;
    map<int,int> mph,mpw;
    set<pair<int,int>> st;
    int maxh=0,maxw=0;
    for(int i=0;i<m;i++)
    {
        int y,x;cin>>y>>x;

        mph[y]++;
        mpw[x]++;
        maxh=max(maxh,mph[y]);
        maxw=max(maxw,mpw[x]);
        st.insert({y,x});
    }

    vector<int> vh,vw;

    for(auto mm:mph)
    {
        if(mm.se==maxh)vh.push_back(mm.fi);
    }

    for(auto mm:mpw)
    {
        if(mm.se==maxw)vw.push_back(mm.fi);
    }

    int ans=maxh+maxw-1;

    for(auto ih:vh)for(auto iw:vw)
    {
        if(st.find({ih,iw})==st.end())
        {
            ans++;
            cout<<ans<<"\n";
            return 0;
        }
    }

    cout<<ans<<"\n";

    return 0;
}


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

const int N = 1e5+34;

vector<int> g[N], q[N];

int bio[N], group[N];
void dfs(int u, int c) {
  bio[u] = c;
  ++group[c];
  for (int v: g[u]) {
    if (bio[v]) {
      continue;
    }
    dfs(v, c);
  }
}

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

void solve() {
  int n, m, k; scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i < m; ++i) {
    int u, v; scanf("%d%d", &u, &v);
    g[u-1].push_back(v-1);
    g[v-1].push_back(u-1);
  }
  for (int i = 0; i < k; ++i) {
    int u, v; scanf("%d%d", &u, &v);
    q[u-1].push_back(v-1);
    q[v-1].push_back(u-1);
  }
  int c = 1;
  for (int i = 0; i < n; ++i) {
    if (bio[i]) continue;
    dfs(i, c++);
  }
  for (int i = 0; i < n; ++i) {
    int ans = group[bio[i]]-1;
    ans -= g[i].size();
    for (int v: q[i]) {
      if (bio[v] == bio[i]) --ans;
    }
    printf("%d ", ans);
  }
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

string S;
int N;
vector<int> pre, nxt;
vector<vector<int> > cc;

int dp(int idx, int t) {
    if(idx >= N) return 0;
    int &ret = cc[idx][t];
    if(ret != -1) return ret;

    if(t == 2) {
        if(idx && idx < N - 1 && S[idx - 1] == '1' && S[idx] == '0' && S[idx + 1] == '1') {
            ret = max(ret, nxt[idx] - idx - 1 + dp(nxt[idx] + 1, 0));
            ret = max(ret, dp(idx + 1, 0));
            ret = max(ret, 1 + dp(idx + 3, 1 & (idx + 2 < N && S[idx + 2] != '0')));
            ret = max(ret, nxt[idx] - idx - 2 + dp(nxt[idx], 2));
            return ret;
        }
        else return ret = dp(idx + 1, 0);
    }

    if(idx && idx < N - 1 && S[idx - 1] == '1' && S[idx] == '0' && S[idx + 1] == '1') {
        if(t != 2) ret = max(ret, (idx - pre[idx] - 1 - t) + dp(idx + 3, 1 & (idx + 2 < N && S[idx + 2] != '0')));
        ret = max(ret, nxt[idx] - idx - 1 + dp(nxt[idx] + 1, 0));
        ret = max(ret, dp(idx + 1, 0));
        ret = max(ret, 1 + dp(idx + 3, 1 & (idx + 2 < N && S[idx + 2] != '0')));
        ret = max(ret, nxt[idx] - idx - 2 + dp(nxt[idx], 2));
        return ret;
    }
    else return ret = dp(idx + 1, t & (S[idx] != '0'));
}

int main() {
    cin >> N >> S;

    pre = vector<int>(N);
    nxt = vector<int>(N);

    int bf = -1;
    for(int i = 0; i < N; i++) {
        pre[i] = bf;
        if(S[i] == '0') bf = i;
    }

    bf = N;
    for(int i = N - 1; i >= 0; i--) {
        nxt[i] = bf;
        if(S[i] == '0') bf = i;
    }

    cc = vector<vector<int> >(N, vector<int>(3, -1));
    printf("%d", dp(0, 0));
}


Measured memory_bytes: 71044
#include <stdio.h>

const int MAX_N = 2999;

double heads[1 + MAX_N][1 + MAX_N];

int main() {
  int n;
  scanf("%d", &n);
  heads[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    double pi;
    scanf("%lf", &pi);
    heads[i][0] = heads[i - 1][0] * (1 - pi);
    for (int h = 1; h <= i; h++)
      heads[i][h] = heads[i - 1][h - 1] * pi + heads[i - 1][h] * (1 - pi);
  }
  double answer = 0;
  for (int h = n / 2 + 1; h <= n; h++)
    answer += heads[n][h];
  printf("%.12lf\n", answer);
  return 0;
}


Measured memory_bytes: 68864
a1,b1 = map(int,input().split())
a2,b2 = map(int,input().split())
a3,b3 = map(int,input().split())

l = [a1,a2,a3,b1,b2,b3]
l.sort()

x = True

for i in range(4):
    if l[i] == l[i+1] == l[i+2]:
        x = False

print("YES" if x == True else "NO")


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	REP(i, N) cin >> A[i];
	
	int ans = 0;
	REP(i, N) if (i % 2 == 0 && A[i] % 2 == 1) {
		++ans;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(int, char**)
{
	int n;
	string s;
	cin >> n >> s;
	if (s.size() % 2 != 0)
	{
		cout << "No" << endl;
		return 0;
	}
	if (s.substr(0, n / 2) == s.substr(n / 2))
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<ll>>;
using P = pair<int,int>;
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; }
#define MOD 1000000007
#define INF 1000000
#define PI 3.14159265358979323846264338327950L
#define MAX_N 200010
#define lb lower_bound //[2,4)=lb(4)-lb(2);

map<ll,int> m;

//素因数分解しながら因数の個数も答える関数
ll countPrimes(ll n)
{
  for (ll i=2;i*i<=n;i++)
  {
    while (n%i==0)
    {
      m[i]++;
      n /= i;
    }
  }
  if (n!=1) m[n]++;
  return (m.size());
}

//累積わ
ll cum[1000010];
void cum_init()
{
  cum[1]=1;
  for (int i=2;i<1000010;i++)
  {
	cum[i]=cum[i-1]+i;
  }
}

ll b[1000010];
void init()
{
  for (int i=1;i<1000;i++)
  {
     for (int n=1;n<=48;n++)
     {
       if (cum[i]<=n && n<cum[i+1])
         b[n]=i;
     }
  }
}

int main()
{
  ll n;cin>>n;
  
  countPrimes(n);
  
  cum_init();
  init();
  /*
  for (int i=1;i<=10;i++)
    cout<<"cum["<<i<<"]="<<cum[i]<<endl;
  
  for (int i=1;i<=10;i++)
    cout<<"b["<<i<<"]="<<b[i]<<endl;
    
    */
  
  int ans=0;
  for (auto i=m.begin();i != m.end();i++){
    ans += b[i->second];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 11420
n = int(input())
a = list(map(int, input().split()))

state = -1
res = 1
for i in range(1, n):
    if state == -1:
        if a[i] < a[i-1]:
            state = 0
        elif a[i] > a[i-1]:
            state = 1
    elif (state == 0 and a[i] > a[i-1]) or (state == 1 and a[i] < a[i-1]):
        res += 1
        state = -1

print(res)


Measured memory_bytes: 62704
import math

n = int(input())
x = list(map(int, input().split()))
p1 = math.floor(sum(x) / n)
p2 = math.ceil(sum(x) / n)

result_1 = 0
result_2 = 0
for i in range(n):
    result_1 += (x[i] - p1) ** 2
    result_2 += (x[i] - p2) ** 2
print(min(result_1,result_2))

Measured memory_bytes: 9156
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		int B[] = new int[N];
		int C[] = new int[N - 1];
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt() - 1;
		}
		for(int i = 0; i < N; i++) {
			B[i] = sc.nextInt();
		}
		for(int i = 0; i < N - 1; i++) {
			C[i] = sc.nextInt();
		}
		
		int ans = 0;
		for(int i = 0; i < N; i++) {
			ans += B[A[i]];
			if(i > 0) {
				if(A[i] - A[i - 1] == 1) {
					ans += C[A[i - 1]];
				}
			}
		}
		System.out.println(ans);
	}
}


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

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end(), greater<ll>());
    ll l = 1, r = 1000000000;
    ll m = (l + r) / 2;
    while(r - l > 0) {
        ll Count = 0;
        rep(i, N) {
            if(A[i] > m) {
                Count += A[i] / m;
            }
        }
        if(Count <= K) {
            r = m;
            m = (l + r) / 2;
        } else {
            l = m + 1;
            m = (l + r) / 2;
        }
    }
    cout << m << endl;
}

Measured memory_bytes: 4708
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){
    ll n,k;cin>>n>>k;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    sort(a,a+n);
    vector<ll> ma,pa;
    rep(i,0,n-1){
        if(a[i]<0){
            ma.pb(a[i]);
        }else{
            pa.pb(a[i]);
        }
    }
    //x未満となるような積がk個未満であるようなxのうち最大ものを求めればいい
    ll al=-pow(10,18)-1,ar=pow(10,18)+1;    //alでok  arでng
    ll amid;
    ll msum;
    ll sum;
    ll l,r,mid,j;
    while(ar-al>1){
        amid=(ar+al)/2;
        sum=0;
        msum=0;
        rep(i,0,n-1){
            if(a[i]*a[i]<amid){
                msum++;
            }
            if(a[i]<0){
                //a[i]*a[j]<amidとなるようなjのうち最小のものを見つけたい
                l=0;
                r=n;     //lでng  rでok
                while(r-l>1){
                    mid=(r+l)/2;
                    if(a[i]*a[mid]<amid){
                        r=mid;
                    }else{
                        l=mid;
                    }
                }
                if(a[i]*a[l]<amid){
                    j=l;
                }else{
                    j=r;
                }
                sum+=(n-j);
                
            }else{
                //a[i]+a[j]<amidとなるようなjのうち最大のものを見つけたい
                l=0;
                r=n;     //lでok   rでng
                while(r-l>1){
                    mid=(r+l)/2;
                    if(a[i]*a[mid]<amid){
                        l=mid;
                    }else{
                        r=mid;
                    }
                }
                if(l==0){
                    if(a[i]*a[l]<amid){
                        j=l;
                    }else{
                        j=-1;
                    }
                }else{
                    j=l;
                }
                sum+=(j+1);
                
            }
            //cout<<a[i]<<' '<<j<<endl;
        }
        //cout<<amid<<' '<<sum<<' '<<msum<<endl;
        if(sum-msum<k*2){
            al=amid;
        }else{
            ar=amid;
        }
        
    }
    
    cout<<al<<endl;
    
    return 0;
}



Measured memory_bytes: 4084